feat: add class parsing and object type system with ObjBlock, ObjClass, and ObjNum structs

Introduce token types TOKEN_CLASS and TOKEN_META for class declaration parsing in the compiler. Refactor the internal object model from a single Obj union to distinct ObjNum, ObjBlock, and ObjClass structs, replacing the old Block type with ObjBlock throughout the compiler, VM, and main entry point. Implement makeClass() and makeBlock() factory functions, update makeNum() to return ObjNum*, and add CODE_CLASS and CODE_DUP bytecodes to support class definition at compile time. Modify the symbol table and method dispatch to use a Method union (primitive or block) stored in ObjClass, and update the VM's callBlock signature and newVM initialization accordingly.
This commit is contained in:
Bob Nystrom
2013-10-24 05:50:04 +00:00
parent ca8f9faf18
commit 816264c21e
6 changed files with 181 additions and 71 deletions
+1
View File
@@ -1,3 +1,4 @@
class Foo {}
var a = 123
var b = 345
a