refactor: replace Foo.new constructor syntax with new Foo and simplify superclass constructor calls

Remove the `this new` constructor declaration syntax in favor of a `new` keyword that creates instances directly. Superclass constructors are now invoked via bare `super(args)` instead of `super.new(args)`, eliminating the semantic weirdness of calling a constructor on a partially-constructed instance. Update the compiler to treat `new` as a keyword token, replace the `isMethod` flag with `methodName`/`methodLength` fields, and change the VM's `NEW` opcode to pop the class from the stack before creating the instance. Add a default `new` native method on Object that returns `this`. Update all benchmarks and tests to use the new syntax.
This commit is contained in:
Bob Nystrom
2013-12-19 15:02:27 +00:00
parent f5a61e4241
commit 0e70d98169
30 changed files with 171 additions and 190 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ class Derived is Base {
}
}
Derived.new.bar
(new Derived).bar
// expect: Derived.bar
// expect: Base.foo
+1 -1
View File
@@ -11,6 +11,6 @@ class Derived is Base {
}
}
Derived.new.foo
(new Derived).foo
// expect: Derived.foo
// expect: Base.foo
+1 -1
View File
@@ -13,6 +13,6 @@ class C is B {
}
}
C.new.foo
(new C).foo
// expect: C.foo
// expect: A.foo