Commit Graph

9 Commits

Author SHA1 Message Date
Bob Nystrom
9aee7ee94e feat: grow fiber stack dynamically and replace fixed-size stack with heap-allocated array 2015-12-14 16:00:22 +00:00
Bob Nystrom
0f932e1f3a fix: make UNREACHABLE() macro safe on compilers lacking __builtin_unreachable
Add fallback empty UNREACHABLE() definition for GCC < 4.5 and non-MSVC compilers, and insert return/break statements after all UNREACHABLE() calls to prevent -Wreturn-type warnings when the macro expands to nothing. Also cast malloc result to char* in io.c to suppress C++ compilation warning.
2015-10-17 04:51:30 +00:00
Bob Nystrom
21765218c4 fix: correct wrenUtf8DecodeNumBytes signature to accept single byte and fix range subscript bug
The function was previously taking a string and index, then indexing into the string internally. Changed to accept the byte directly, which fixes incorrect behavior when wrenNewStringFromRange and wrenStringCodePointAt passed a raw byte value instead of a string pointer. Also fixed a typo in wrenNewStringFromRange where wrenUtf8EncodeNumBytes was called instead of wrenUtf8DecodeNumBytes.
2015-09-09 03:59:47 +00:00
Bob Nystrom
a619851cf2 feat: implement UTF-8 aware string subscript ranges with new wrenNewStringFromRange helper
Add wrenNewStringFromRange function to wren_value.c that decodes UTF-8 code points from source string and re-encodes them into result, enabling correct range subscripts on multi-byte characters. Rename wrenUtf8NumBytes to wrenUtf8EncodeNumBytes and make wrenUtf8Encode return written byte count for use in range construction. Add wrenUtf8DecodeNumBytes utility to skip continuation bytes when iterating by byte index. Remove all skip directives from test files and add UTF-8 specific test cases verifying correct slicing across code point boundaries.
2015-09-02 05:14:55 +00:00
Bob Nystrom
f481ea7fe6 test: add tests for incomplete UTF-8 sequences in codePointAt and remove TODO comment
Add test cases for single-byte incomplete two-octet and three-octet UTF-8 sequences
in code_point_at_incomplete.wren, and remove the resolved TODO comment about testing
truncated UTF-8 buffer reads in wrenUtf8Decode.
2015-06-27 15:11:58 +00:00
Bob Nystrom
c3d0b66630 feat: add raw byte access methods and \x escape to String class
Add `byteAt(index)`, `codePointAt(index)`, and `bytes` sequence to String,
enabling direct byte-level manipulation of UTF-8 encoded strings. Introduce
`\x` hex escape sequence in string literals for specifying raw byte values.
Refactor Unicode escape parsing into a generic `readHexEscape` function
supporting variable digit counts. Implement `wrenUtf8Decode` utility for
decoding UTF-8 sequences from byte buffers. Add comprehensive tests for
`byteAt` including boundary conditions and error cases.
2015-03-28 03:44:07 +00:00
Bob Nystrom
b7904a89c9 feat: add String.fromCodePoint static method and refactor UTF-8 encoding into reusable utilities
Implement the `String.fromCodePoint(_)` primitive that creates a string from a Unicode code point, with validation for integer range 0–0x10ffff. Extract inline UTF-8 encoding logic from `readUnicodeEscape` in the compiler into new `wrenUtf8NumBytes` and `wrenUtf8Encode` utility functions in `wren_utils`, and add `wrenStringFromCodePoint` helper in `wren_value`. Update documentation for core classes to add "Methods" and "Static Methods" section headers, and include `String.fromCodePoint` docs with example. Add a test file `from_code_point.wren` covering various code points.
2015-03-27 14:43:36 +00:00
Bob Nystrom
15f9273aab refactor: remove unused WrenVM* parameter from buffer init, string find, and debug print functions
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.
2015-03-23 05:17:40 +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