Commit Graph

2 Commits

Author SHA1 Message Date
Bob Nystrom
cc117912fa feat: implement list literal syntax and List class with count property
Add support for list literals in the compiler with bracket-delimited syntax and comma-separated elements. Introduce the ObjList runtime type with a contiguous elements array, garbage collection marking, and proper memory deallocation. Expose a `List` class in the core library with a `count` method returning the number of elements. Update the grammar table to register `[` as a prefix token for list compilation instead of an infix subscript operator, and reorder opcode enum entries to place CODE_LIST before the load/store group.
2013-11-24 21:38:31 +00:00
Bob Nystrom
ccbc2f8d4e feat: implement class inheritance with 'is' keyword and superclass method copying
Add support for class inheritance in the compiler by parsing the 'is' keyword to load a superclass and emit a CODE_SUBCLASS instruction. In the VM, extend newClass to accept a superclass parameter, copy inherited methods from the superclass into the new class, and store the superclass pointer in the ObjClass struct. Introduce a root Object class in the core library and set it as the superclass for all built-in types. Add a test file verifying method inheritance and arity-based dispatch.
2013-11-13 19:05:03 +00:00