Replace the TODO placeholder for rootDirectory initialization in the REPL
with a call to getcwd (with _getcwd fallback for MSVC), enabling module
imports to resolve relative to the user's working directory at startup.
Renamed the native function identifiers for left and right bitwise shift operations
in wren_core.c to use the more explicit names num_bitwiseLeftShift and
num_bitwiseRightShift, replacing the abbreviated Lsh and Rsh suffixes. Updated
both the DEF_NATIVE macro definitions and the corresponding NATIVE registrations
in wrenInitializeCore to use the new names.
Rename the token enum values and all references in the compiler to use the more concise
TOKEN_LTLT and TOKEN_GTGT names for the '<<' and '>>' operators, updating both the
token type definitions and the grammar rule table entries.
Add comprehensive test files for bitwise lsh, rsh, and xor operations
covering basic cases, max u32 boundary, past max u32 wrap, and operand
type error checks for non-numeric right operands.
Implement three new native methods on the Num class: `^` (bitwise XOR), `<<` (left shift), and `>>` (right shift). Each operates on 32-bit unsigned integers, matching the existing bitwise AND/OR convention. The new primitives are registered in `wrenInitializeCore` alongside the existing bitwise operators.
Add TOKEN_LEFT_SHIFT, TOKEN_RIGHT_SHIFT, and TOKEN_CARET to the token enum, implement lexing for '^' as single-char token and '<<'/'>>' as two-char tokens in nextToken(), and register them as infix operators at PREC_BITWISE precedence in the grammar rules table.
Add four new benchmark scripts (maps.lua, maps.py, maps.rb, maps.wren) that measure
hash map insertion, lookup, and deletion performance across 100,000 elements.
Register the new "maps" benchmark in run_bench.py with expected output 5000050000.
- Relocate benchmark/run_bench to script/run_bench.py
- Replace WREN_DIR with HOME_DIR and update BENCHMARK_DIR construction
- Change wren binary path from relative "../wren" to absolute using HOME_DIR
The FNV-1a hash initializer constant 2166136261 exceeds the maximum value
for a signed 32-bit integer, causing GCC to emit a constant unsigned error
when compiling as C++. Adding the 'u' suffix explicitly marks the literal
as unsigned, resolving the compilation issue without changing behavior.
Add comprehensive test coverage for strings containing null bytes (\0) to ensure
all string operations correctly handle 8-bit clean data. Tests verify that
concatenation, substring search, length counting, boundary checks, equality
comparisons, index lookups, iteration, joining, and conversion to string all
treat embedded null bytes as regular characters rather than terminators.
Previously, the corner case for empty strings only returned true when both the source and search strings were empty. This fix changes the condition to return true whenever the search string is empty, as the empty string is always contained within any string.
The function signature was changed from accepting null-terminated C strings to accepting explicit length parameters, with -1 indicating automatic strlen calculation. All call sites were updated to pass -1 for both lengths, and internal implementation switched from strcpy to memcpy to handle embedded null bytes correctly.
Implement wrenStringFind function in wren_value.c that uses the Boyer-Moore-Horspool algorithm with a 256-entry shift table for full 8-bit character support. Update string_contains and string_indexOf native methods in wren_core.c to call the new function instead of strstr, fixing substring searches on strings containing null bytes or extended ASCII characters.
The length field in ObjString struct is updated to use uint32_t instead of int,
ensuring consistent unsigned semantics for string size representation across
the codebase and preventing potential issues with negative length values.
Add handling for the null character escape sequence '\0' in the
readString function within the Wren compiler. This allows string
literals to include null bytes via the standard C escape syntax,
matching the existing support for other escape sequences like '\a',
'\b', and '\f'.
The debug instruction printer was dereferencing string arrays directly instead of accessing their .buffer member, causing incorrect symbol name display for LOAD_GLOBAL, STORE_GLOBAL, CALL, SUPER, METHOD_INSTANCE, and METHOD_STATIC instructions. Updated all six printf calls to use vm->globalNames.data[global].buffer and vm->methodNames.data[symbol].buffer respectively.
Replace the `char*` buffer element type with a `String` struct that holds both the buffer pointer and its length. This eliminates O(n) `strlen()` calls in `wrenSymbolTableFind` and ensures length is always available without scanning for the null terminator. Update `wrenSymbolTableAdd` to populate the new `length` field, `wrenSymbolTableClear` to free via `symbol.buffer`, and all call sites (e.g., `methodNotFound` in `wren_vm.c`) to access `.buffer` explicitly.
Replace the single-bit FLAG_MARKED enum and ObjFlags bitfield with a direct bool 'marked' field on the Obj struct. This simplifies the garbage collector's mark-sweep logic by removing unnecessary bitwise operations (|, &, ~) and the associated enum definition, making the intent clearer and reducing cognitive overhead when reading GC-related code paths.
Remove the entire wren_math.c and wren_math.h implementation files, delete all math test scripts under test/math/, and strip the WREN_USE_LIB_MATH compile flag from wren_common.h. Also remove the wrenLoadMathLibrary call from wren_vm.c and delete the wren_math.c/h entries from both the MSVC project file and its filters file.
The diff reorders includes across multiple source files to place standard library headers before project headers, removes the `_CRT_SECURE_NO_WARNINGS` define from `wren_common.h`, and adds it as a preprocessor definition in both Debug and Release configurations of the MSVC 2013 project file.
Add wren_math.c and wren_math.h to the MSVC 2013 project files, including both the .vcxproj and .vcxproj.filters. Also fix the indentation of the WREN_COMPUTED_GOTO comment in wren_common.h and correct a conditional guard bug in wren_vm.c where wrenLoadMathLibrary was guarded by WREN_USE_LIB_IO instead of WREN_USE_LIB_MATH.
Implement the Math standard library module for Wren, including absolute value, ceiling, floor, integer/fractional decomposition, trigonometric functions (sin, cos, tan), degree/radian conversion, and a seeded xorshift random number generator. Add WREN_USE_LIB_MATH compile-time flag to wren_common.h and provide comprehensive test suite under test/math/.
Implement a new optional Math module for the Wren standard library, gated behind the WREN_USE_LIB_MATH flag (default on). The module provides double-precision math functions (abs, ceil, floor, int, frac, sin, cos, tan, deg, rad) and a xorshift-based pseudo-random number generator with srand/rand methods. Includes comprehensive test files for each function and an all_tests runner.
Disable optimization for wrenPinObj and wrenUnpinObj functions under Microsoft Visual Studio 2013 to prevent the compiler from incorrectly inlining them, which triggers a memory access violation. The pragma directives bracket only these two functions to minimize the impact on the rest of the compilation unit.
Add MSVC 2013 project scaffolding under project/msvc2013/ including wren.sln solution file, wren.vcxproj with Debug/Release Win32 configurations using v120 toolset, and wren.vcxproj.filters organizing source and header files from ../src/ into Visual Studio filter categories.
Enforce a consistent include ordering convention across the codebase: wren_common.h (as configuration header) first, followed by the module's own header, then other wren_*.h headers in lexicographic order, and finally standard library includes. Also add missing wren_common.h include to main.c and wren_io.c, and add _CRT_SECURE_NO_WARNINGS define for MSVC in wren_common.h.
The WREN_COMPUTED_GOTO macro is now conditionally set to 0 when
compiling with _MSC_VER, as Microsoft's compiler does not support
the computed-goto extension used by the VM dispatch loop.
In `src/wren_value.h`, change three flexible array members (`char value[]`, `Upvalue* upvalues[]`, `Value fields[]`) to explicit zero-sized arrays (`char value[0]`, `Upvalue* upvalues[0]`, `Value fields[0]`) to resolve compiler warnings about non-standard zero-sized array usage in structs `ObjString`, `ObjClosure`, and `ObjInstance`.