Change bindMethod return type from void to Value to propagate error string when a foreign method's C function pointer is NULL. The call site in runInterpreter now checks for a string error and triggers a runtime error, preventing silent failures on missing foreign bindings.
Add three test cases: foreign method after static declaration, foreign method with a body, and unknown foreign method that expects the new runtime error message.
Add foreign static eval(source) method to Meta class in meta.wren and implement wrenBindMetaForeignMethod in wren_meta.c to handle its binding. Change the implicit module name from "main" to "core" in wren_vm.c and restrict foreign method lookup to only the "core" module, enabling Meta foreign methods to be resolved alongside IO methods. Relax the IO foreign method binder to return NULL instead of asserting for non-IO classes, allowing fallback to other library binders.
Introduce a new Meta built-in class exposing a static eval(_) method for runtime code interpretation, guarded by the WREN_USE_LIB_META compile-time flag (default on). Include the meta.wren source, C implementation files, header, VM integration in wrenNewVM, test runner update to include the meta test directory, and an initial test for evaluating code that modifies an existing scoped variable.
Simplify the allocation API by dropping the unused `oldSize` argument from `WrenReallocateFn` typedef, its documentation, and all internal callers. Update `wrenReallocate` in `wren_vm.c` to pass only `newSize`, remove the `defaultReallocate` wrapper in favor of direct `realloc`, and adjust `generate_baseline` signature in benchmark script to match.
Implement the `WrenBindForeignMethodFn` callback type and `bindForeignMethodFn` configuration field to allow host applications to resolve foreign method declarations at class definition time. Refactor the IO library to use this new binding mechanism instead of the previous `wrenDefineStaticMethod` approach, adding `foreign` keyword support to the lexer and compiler. Introduce `freeCompiler` helper for cleanup, store module names in `ObjModule`, and update the VM to call the binder when processing `CODE_METHOD_INSTANCE` and `CODE_METHOD_STATIC` opcodes for foreign methods.
Rename the `Upvalue` struct and all related type references to `ObjUpvalue` across
wren_value.c, wren_value.h, and wren_vm.c. This aligns with the existing pattern
where Obj-derived types (like ObjModule, ObjClosure) use the Obj prefix even when
the type is not first-class in the language. The change touches function signatures,
variable declarations, pointer arithmetic in memory tracking, and the struct
definition itself.
Remove the `WrenVM* vm` parameter from `wrenValueBufferInit`, `wrenByteBufferInit`,
`wrenIntBufferInit`, `wrenStringBufferInit`, `wrenSymbolTableInit`,
`wrenMethodBufferInit`, `wrenStringFind`, and `wrenDebugPrintStackTrace`
functions across the compiler, core, debug, utils, value, and VM modules.
Update all call sites and macro definitions to match the simplified signatures,
eliminating dead parameters that were never used within the function bodies.
Add CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES to both Debug and Release Xcode build configurations. Fix the resulting warnings by adding explicit casts in wren_compiler.c (readUnicodeEscape, emit, emitShort, emitByteArg) and wren_vm.c (READ_SHORT macro, makeCallStub bytecode assignment) to prevent unintended truncation or sign extension during implicit integer conversions.
Enable the -Wextra compiler flag in the wren.mk build configuration, which was previously commented out with a TODO. To handle the new unused parameter warnings triggered by -Wextra (particularly for WrenVM* vm parameters in several functions), add -Wno-unused-parameter to suppress them. Also fix a declaration ordering issue in wren_vm.c where the 'static' keyword was placed after the return type in loadIntoCore, moving it to the correct position before the type specifier.
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.
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.
The guard checks if the VM pointer is NULL or if its methodNames count is zero,
which serves as a heuristic to detect an already-freed VM instance. This prevents
a segmentation fault or memory corruption when wrenFreeVM is called multiple times
on the same VM object.