refactor: replace custom String struct with ObjString* in symbol table and method names
Unify string representation across the codebase by switching SymbolTable and method name storage from a manually-managed `String` struct (char* buffer + length) to `ObjString*` pointers. This eliminates duplicate string allocations in the meta API's `metaGetModuleVariables`, reduces memory management overhead by leveraging the existing GC for symbol strings, and adds `wrenBlackenSymbolTable` to properly trace these GC-roots during collection. The change touches the compiler, debug dumper, VM runtime error formatting, and module variable initialization to use `->value` and `->length` fields directly from `ObjString`.
This commit is contained in:
@@ -52,9 +52,7 @@ void metaGetModuleVariables(WrenVM* vm) {
|
||||
|
||||
for (int i = 0; i < names->elements.count; i++)
|
||||
{
|
||||
String* name = &module->variableNames.data[i];
|
||||
names->elements.data[i] = wrenNewStringLength(vm,
|
||||
name->buffer, name->length);
|
||||
names->elements.data[i] = OBJ_VAL(module->variableNames.data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user