Commit Graph

5 Commits

Author SHA1 Message Date
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
0e70d98169 refactor: replace Foo.new constructor syntax with new Foo and simplify superclass constructor calls
Remove the `this new` constructor declaration syntax in favor of a `new` keyword that creates instances directly. Superclass constructors are now invoked via bare `super(args)` instead of `super.new(args)`, eliminating the semantic weirdness of calling a constructor on a partially-constructed instance. Update the compiler to treat `new` as a keyword token, replace the `isMethod` flag with `methodName`/`methodLength` fields, and change the VM's `NEW` opcode to pop the class from the stack before creating the instance. Add a default `new` native method on Object that returns `this`. Update all benchmarks and tests to use the new syntax.
2013-12-19 15:02:27 +00:00
Bob Nystrom
7ac04b9e3d feat: refactor method_call benchmark to use inheritance and fix constructor binding
Refactor the method_call benchmark across Lua, Python, Ruby, and Wren to use proper inheritance with super calls instead of direct state manipulation. This ensures all languages benchmark super method invocations consistently.

Fix a bug in the Wren compiler where constructors weren't being bound correctly by extracting method binding logic into a dedicated `bindMethod` function that properly handles both instance and static methods against the class object.

Optimize if-statement compilation by restructuring jump instruction emission to eliminate unnecessary CODE_JUMP instructions when no else branch exists, reducing bytecode size for conditional blocks.

Update the superclass constructor test to verify inherited field access through super constructor chains, confirming correct field initialization across multiple inheritance levels.
2013-12-18 15:37:41 +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
6ba77ea2cd fix: add explicit return statements in benchmark functions and add method_call benchmark suite 2013-12-08 02:43:39 +00:00