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.
This commit is contained in:
Bob Nystrom
2013-11-23 22:55:05 +00:00
parent f4982f7b21
commit f50453e24e
11 changed files with 229 additions and 19 deletions
+1
View File
@@ -0,0 +1 @@
var _field = "value" // expect error