feat: implement static methods as local variables in implicit class scope
Refactor the compiler to treat static methods as local variables defined in an implicit scope surrounding the class, eliminating the need for VM-level static method support. This changes `declareVariable` to use the previously consumed token, adds `declareNamedVariable` for explicit token consumption, and updates `parameterList` to use the new function. Adjusts VM bytecode ordering for `CODE_METHOD_INSTANCE` and `CODE_METHOD_STATIC` to pop the class before the function body. Adds comprehensive test coverage for static fields including closures, nested classes, default null values, instance method access, and error cases for field usage outside classes or in static methods.
This commit is contained in:
@@ -6,3 +6,6 @@ class Foo {
|
||||
var foo = new Foo
|
||||
IO.print(foo is Foo) // expect: true
|
||||
IO.print(foo.toString) // expect: Foo
|
||||
|
||||
// TODO: Get rid of this. If you're defining a class, it's because you have
|
||||
// some state to initialize. if you don't, it shouldn't be a class.
|
||||
|
||||
Reference in New Issue
Block a user