Commit Graph

6 Commits

Author SHA1 Message Date
Bob Nystrom
db365ae9fa fix: correct object type label in dumpObject for OBJ_RANGE case
The dumpObject function in wren_debug.c was incorrectly printing "[fn %p]" for
OBJ_RANGE objects instead of the correct "[range %p]" label. This fix ensures
that range objects are properly identified during debug output.
2015-03-16 14:05:40 +00:00
Bob Nystrom
a73ee9a8e7 fix: pass missing argName to wrenStringFormat in validateIntValue and validateIndexValue
The two validation functions in wren_core.c were calling wrenStringFormat with a format
string containing a "$" placeholder but were not passing the argName argument, causing
the placeholder to remain unsubstituted in error messages. This commit adds the missing
argName parameter to both calls.

Additionally, the CONST_STRING macro in wren_value.h was changed from using strlen(text)
to sizeof(text) - 1, which allows the compiler to compute the string length at compile
time rather than at runtime, improving performance for string literal creation.
2015-03-16 06:17:08 +00:00
Bob Nystrom
e95b32188f refactor: replace sizeof-based string length with strlen in CONST_STRING macro
The previous implementation used `sizeof(text) - 1` to determine string length at compile time, which required the argument to be a bare string literal. The new approach uses `strlen(text)` instead, which allows most compilers to evaluate the string length at compile time when a string literal is passed, while also supporting non-literal string arguments. This change trades compile-time guarantee for broader compatibility and compiler optimization potential.
2015-03-16 06:07:20 +00:00
Bob Nystrom
9314cbfd72 refactor: replace manual string concatenation with wrenStringFormat across VM core
Replace ad-hoc string construction using wrenNewString, wrenStringConcat, and sprintf with the new wrenStringFormat helper. This centralizes string formatting logic, reduces code duplication, and eliminates manual length calculations in wren_compiler.c, wren_core.c, wren_value.c, and wren_vm.c. Also introduces CONST_STRING macro for compile-time string literals and changes wrenNewUninitializedString return type from Value to ObjString* for consistency.
2015-03-16 05:32:20 +00:00
Bob Nystrom
d731e554e6 refactor: rename debug print functions to dump and move value printing to wren_debug.c 2015-03-15 17:09:43 +00:00
Bob Nystrom
18cf57d5f5 refactor: split source tree into vm/ and cli/ directories with updated build system
Separate Wren VM library sources from CLI tool sources by moving them into
src/vm/ and src/cli/ subdirectories respectively. Update the Makefile to use
separate wildcard patterns for each directory, generate distinct object file
paths under build/vm/ and build/cli/, and adjust include paths to src/include.
Also update the Xcode project file to reference the new file locations.
2015-03-14 22:00:50 +00:00