feat: implement class method definition and instance creation in compiler and VM

Add method parsing and compilation in `statement()` for class bodies, including symbol interning and block constant emission. Introduce `addConstant()` helper in compiler.c. Extend VM with `CODE_METHOD` opcode, `ObjInstance` type, `makeInstance()` factory, metaclass support in `makeClass()`, and `getSymbolName()` for symbol table lookup. Update vm.h with new type enum, struct definitions, and function declarations.
This commit is contained in:
Bob Nystrom
2013-10-25 04:32:17 +00:00
parent 722e1dc638
commit 406826a980
4 changed files with 139 additions and 23 deletions
+6 -5
View File
@@ -1,6 +1,7 @@
var a = {
var b = 234
3
b
class Foo {
bar {
123
}
}
a.call
var a = Foo.new
a.bar