feat: refactor method_call benchmark to use inheritance and fix constructor binding

Refactor the method_call benchmark across Lua, Python, Ruby, and Wren to use proper inheritance with super calls instead of direct state manipulation. This ensures all languages benchmark super method invocations consistently.

Fix a bug in the Wren compiler where constructors weren't being bound correctly by extracting method binding logic into a dedicated `bindMethod` function that properly handles both instance and static methods against the class object.

Optimize if-statement compilation by restructuring jump instruction emission to eliminate unnecessary CODE_JUMP instructions when no else branch exists, reducing bytecode size for conditional blocks.

Update the superclass constructor test to verify inherited field access through super constructor chains, confirming correct field initialization across multiple inheritance levels.
This commit is contained in:
Bob Nystrom
2013-12-18 15:37:41 +00:00
parent e26afd7de3
commit 7ac04b9e3d
7 changed files with 62 additions and 61 deletions
+13
View File
@@ -1,19 +1,28 @@
class A {
this new(arg) {
io.write("A.new " + arg)
_field = arg
}
aField { return _field }
}
class B is A {
this otherName(arg1, arg2) super.new(arg2) {
io.write("B.otherName " + arg1)
_field = arg1
}
bField { return _field }
}
class C is B {
this create super.otherName("one", "two") {
io.write("C.create")
_field = "c"
}
cField { return _field }
}
var c = C.create
@@ -23,3 +32,7 @@ var c = C.create
io.write(c is A) // expect: true
io.write(c is B) // expect: true
io.write(c is C) // expect: true
io.write(c.aField) // expect: two
io.write(c.bField) // expect: one
io.write(c.cField) // expect: c