Commit Graph

7 Commits

Author SHA1 Message Date
Bob Nystrom
c72db7d594 feat: rename IO.write to IO.print and add Unicode escape support in strings
Rename the IO.write method to IO.print, which now prints without a trailing newline, and add a new IO.print method that appends a newline after output. Update all benchmark, example, and test files to use IO.print instead of IO.write. Additionally, implement Unicode escape sequence parsing in the compiler's string tokenizer, supporting \uXXXX and \u{...} syntax with proper UTF-8 encoding for code points up to U+10FFFF.
2014-01-05 20:27:12 +00:00
Bob Nystrom
8bb1a94a25 refactor: convert IO from singleton instance to static class with metaclass native methods
Replace the global `io` singleton object with a static `IO` class, moving the `write` native from the instance to the metaclass. Update all benchmark, example, and test files to use `IO.write()` instead of `io.write()`.
2013-12-22 03:25:09 +00:00
Bob Nystrom
d9255666f4 fix: add list newline handling and resolve multiple test TODOs across compiler and test suite
- Add TOKEN_LINE matching after list elements in compiler to allow newlines before commas or closing brackets
- Add tests for list newline handling, EOF after comma/element, and class name inside body
- Remove resolved TODOs for default constructors, inherited fields, metaclass is checks, zero comparison, and bitwise not behavior
2013-12-20 20:42:11 +00:00
Bob Nystrom
34db2b2b9f chore: remove author attribution from TODO comments across multiple source files
Remove "(bob)" author prefix from all TODO comments in benchmark/method_call.wren, include/wren.h, src/main.c, src/wren_common.h, src/wren_compiler.c, src/wren_core.c, src/wren_value.c, src/wren_value.h, and src/wren_vm.c. Update the TODO_PATTERN regex in metrics script to match the new format without author parentheses. Also refactor test file counting in metrics to use os.walk with fnmatch for recursive directory traversal instead of glob.iglob.
2013-12-14 23:28:18 +00:00
Bob Nystrom
d8c31a4391 feat: add wrenBindMethod to patch field indices and superclass dispatch in inherited methods
When a class is defined, its superclass is not known until runtime since class definitions are imperative statements. This adds a new wrenBindMethod function that walks the bytecode of a method after it is bound to a class, adjusting LOAD_FIELD/STORE_FIELD indices to account for inherited fields and patching superclass dispatch targets. The newClass function now correctly accumulates numFields from the superclass chain, and the VM calls wrenBindMethod when binding methods to a class. Includes new test files for inherited field access and the is operator.
2013-12-11 00:13:25 +00:00
Bob Nystrom
6996f5a48d feat: replace per-type equality primitives with unified object_eqeq and wrenGetClass
Move equality and inequality primitives from Bool and Function to a single Object-level implementation using valuesEqual, and add wrenGetClass to return the runtime class of any value. Refactor newSingleClass to inherit methods from superclass and wire metaclass superclass to classClass. Add type-checking tests for all built-in types and class inheritance.
2013-11-26 15:52:37 +00:00
Bob Nystrom
266881994f feat: add is operator for type checking and refactor primitives registration
Add TOKEN_IS token and CODE_IS bytecode to support runtime type checking via the `is` keyword. Refactor primitive registration by replacing `registerPrimitives` with `loadCore`, which compiles a core library string to define built-in classes (Bool, Class, Function, Num, Null, String, IO) and then attaches primitive methods to them. Update Primitive typedef to remove unused numArgs parameter, and add findGlobal helper to retrieve globals by name. Include test files for class syntax, class instantiation, and the new `is` operator.
2013-11-08 01:07:32 +00:00