Commit Graph

8 Commits

Author SHA1 Message Date
Bob Nystrom
3e5fdc2250 feat: add overloaded IO.print methods accepting 2-16 arguments and printList_ helper
Add 15 static overloads of IO.print in builtin/io.wren and src/wren_io.c, each delegating to a new private printList_ method that iterates over a list of objects. Update all benchmark and test files to use the new multi-argument syntax, removing explicit .toString calls and string concatenation. Add a comprehensive test/io/print.wren verifying single-argument return value, multi-argument null return, and concatenation of up to 16 arguments.
2014-04-09 14:48:35 +00:00
Bob Nystrom
786e20ba93 fix: update delta_blue benchmark setter methods to new Wren syntax
Replace legacy setter syntax `property = value { ... }` with the modern
`property=(value) { ... }` form across all five property setters in the
Variable class (determinedBy, mark, walkStrength, stay, value).
2014-04-09 04:40:31 +00:00
Bob Nystrom
a1365c4183 feat: unify block, function, and method body parsing to support single-expression implicit returns
Refactor `finishBlock` in `wren_compiler.c` to detect single-expression bodies (no newline after `{`) and leave a value on the stack, enabling implicit returns for methods and functions. Add `finishBody` wrapper to handle constructor flag. Update all benchmark and test `.wren` files to remove explicit `return` keywords from getters and single-expression methods, relying on the new implicit return behavior. Remove old `return_null_if_brace.wren` test, add `newline_body.wren`, `newline_in_expression_block.wren`, and `no_newline_before_close.wren` tests for edge cases.
2014-04-03 14:48:19 +00:00
Bob Nystrom
e20da2f070 feat: migrate all function literals from fn syntax to new Fn block syntax
Replace all occurrences of the old `fn` function literal syntax with the new `new Fn {|params| body}` block syntax across benchmark, test, and source files. Update the Wren compiler to handle the pipe operator as a block argument delimiter by removing `TOKEN_PIPE` from the newline-swallowing token list and adding explicit newline matching in `infixOp`. Adjust test expectations in `conditional/precedence.wren` to remove `fn`-based expressions and update `test/assignment/local.wren` to use the new syntax.
2014-04-03 02:41:53 +00:00
Bob Nystrom
81f20caf33 feat: replace CODE_NEW instruction with instantiate method call for class and Fn
Refactor the 'new' operator compilation to emit a method call to 'instantiate' on the class instead of using a dedicated bytecode instruction. This allows built-in types like Fn to override instantiation behavior, enabling `new Fn { ... }` to return the block argument directly. Remove the CODE_NEW opcode from the VM, compiler, and debug printer, and add native methods `class_instantiate`, `fn_instantiate`, `fn_new`, and `object_instantiate` to handle the new dispatch. Update test files to reflect the renamed `Function` class to `Fn`.
2014-04-03 00:42:30 +00:00
Bob Nystrom
b044447464 refactor: replace manual if-else with ternary operator and use .where() for list filtering in delta_blue benchmark
Replace the TODO-marked manual if-else logic in `Strength.weakest` and `Strength.strongest` with the ternary operator, and refactor the manual while-loop list filtering in `Variable.removeConstraint` to use the `.where()` method for cleaner, more idiomatic Wren code.
2014-02-15 19:59:56 +00:00
Bob Nystrom
e3b3fef0fb feat: make this the implicit receiver for method calls inside class bodies
In the compiler, when a bare name is encountered inside a class definition and it does not resolve to a local variable or global, emit an implicit `this.` load before the call, enabling getter, setter, and method calls without explicit receiver. Update all benchmark, builtin, and test files to remove redundant `this.` qualifiers, and add comprehensive test suites for implicit receiver behavior across instance, inherited, static, nested, and shadowing scenarios.
2014-02-13 01:33:35 +00:00
Bob Nystrom
05857c8b47 feat: add delta_blue benchmark with Wren, Lua, and Python implementations
Add the DeltaBlue constraint-solving benchmark ported from Dart to Wren, along with supporting Lua and Python versions for cross-validation. The Wren implementation includes the full constraint hierarchy solver with strength classes, plan execution, and the standard DeltaBlue test harness. Register the benchmark in run_bench with expected output "7032700".
2014-02-10 15:56:11 +00:00