Get static methods fully working.

They are compiled as local variables defined in an implicit
scope surrounding the class. This has the right semantics and,
better, means that there's no VM support needed for them.

They're purely syntax sugar.
This commit is contained in:
Bob Nystrom
2014-01-19 13:01:51 -08:00
parent 2a68c8ee1d
commit 83b5968340
15 changed files with 307 additions and 81 deletions
+5 -7
View File
@@ -154,15 +154,13 @@ typedef enum
// Pop a superclass off the stack, then push a new class that extends it.
CODE_SUBCLASS,
// Define a method for symbol [arg] whose body is the function popped off the
// top of the stack. The class receiving the method is on top of the stack
// (after the function is popped off) and remains after this.
// Define a method for symbol [arg]. The class receiving the method is popped
// off the stack, then the function defining the body is popped.
CODE_METHOD_INSTANCE,
// Define a method for symbol [arg] whose body is the function popped off the
// top of the stack. The class receiving the method is the metaclass of the
// class on top of the stack (after the function is popped off) and remains
// after this.
// Define a method for symbol [arg]. The class whose metaclass will receive
// the method is popped off the stack, then the function defining the body is
// popped.
CODE_METHOD_STATIC,
// This pseudo-instruction indicates the end of the bytecode. It should