This website requires JavaScript.
Retoor software development
Projects
Research
SearchXNG
Register
Sign In
6 lines
76 B
Plaintext
Raw
Normal View
History
Unescape
Escape
feat: add instance field support with lexer, compiler, and GC tracing Add TOKEN_FIELD token type and '_' prefix handling in lexer to distinguish field identifiers from regular names. Extend Compiler struct with fields symbol table pointer for tracking enclosing class fields. Implement field() parse function and CODE_LOAD_FIELD/CODE_STORE_FIELD bytecodes in VM. Modify ObjClass to store numFields count and ObjInstance to use flexible array member for field storage. Update GC markInstance to trace all instance fields. Add newClass signature to accept numFields parameter. Include test cases for field default null, multiple fields, object references with GC, and use-before-set ordering.
2013-11-23 23:55:05 +01:00
class Foo {
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 04:25:09 +01:00
write { IO.write(_field) }
feat: add instance field support with lexer, compiler, and GC tracing Add TOKEN_FIELD token type and '_' prefix handling in lexer to distinguish field identifiers from regular names. Extend Compiler struct with fields symbol table pointer for tracking enclosing class fields. Implement field() parse function and CODE_LOAD_FIELD/CODE_STORE_FIELD bytecodes in VM. Modify ObjClass to store numFields count and ObjInstance to use flexible array member for field storage. Update GC markInstance to trace all instance fields. Add newClass signature to accept numFields parameter. Include test cases for field default null, multiple fields, object references with GC, and use-before-set ordering.
2013-11-23 23:55:05 +01:00
}
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 16:02:27 +01:00
(new Foo).write // expect: null
Reference in New Issue
Copy Permalink
b72a42eedd
wren
/
test
/
field
/
default_to_null.wren