Commit Graph
4 Commits
Author SHA1 Message Date
Michel Hermier 0f74a07c86 feat: add wrenStringEqualStrLength and wrenStringsEqual helpers for string comparison
Introduce two new inline functions in wren_value.h: wrenStringEqualStrLength
compares an ObjString against a raw C string with known length, while
wrenStringsEqual compares two ObjString instances using hash pre-check and
delegating to wrenStringEqualStrLength. Refactor wrenSymbolTableFind in
wren_utils.c and wrenValuesEqual in wren_value.c to use these new helpers,
replacing inline memcmp calls for improved code clarity and reuse.
2018-03-29 07:12:32 +00:00
Michel Hermier 4e53cda68d 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`.
2018-03-28 16:12:50 +00:00
Michel Hermier 44e0714458 refactor: move Obj* forward declarations to wren_common.h and unify struct naming
Consolidate all Obj* type forward declarations from wren_value.h into wren_common.h
to centralize type definitions and reduce header dependencies. Convert anonymous
typedef structs to named structs with sObj* tags for consistent naming convention
across all object types.
2018-03-28 15:51:34 +00:00
Michel Hermier 28b3234fa5 fix: correct opcode argument counts and field offset patching in wrenBindMethodCode
The getNumArguments function had CODE_IMPORT_MODULE incorrectly listed as a 1-argument
opcode and CODE_IMPORT_VARIABLE as a 2-argument opcode. This swap caused incorrect
bytecode parsing during method binding. Additionally, wrenBindMethodCode had two bugs:
the instruction fetch was incrementing ip before reading the opcode, and field offset
patching was using ip++ instead of ip+1, corrupting subsequent bytecode. The super
instruction handling also had an incorrect ip+=2 skip that removed the symbol offset
before reading the constant index.
2018-01-11 10:56:03 +00:00