Make method_call benchmark use inheritance.
This also fixes a bug where constructors weren't being bound correctly, and eliminates some unneeded instructions when compiling ifs. I also tweaked the other method_call languages to match Wren's. Since Wren needs to do a super call to get to the parent _count, the other languages do now too. This is nice too because it means we're benchmarking super calls.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user