Retoor software development Projects Research SearchXNG
Register Sign In

23 lines
435 B
Plaintext
Raw Normal View History

feat: implement superclass method dispatch with new SUPER bytecodes and named call compiler Add CODE_SUPER_0 through CODE_SUPER_16 bytecodes to the VM for invoking inherited methods, along with a `namedCall` compiler helper that parses method names and argument lists after a dot. The interpreter dispatches super calls by walking up the class hierarchy from the receiver's immediate class, skipping methods defined on that class. Includes three test cases covering calling a different superclass method, calling the same method name, and indirectly inherited methods. Also fixes error formatting to handle newline tokens gracefully and adds a TODO note about not deduplicating placeholder constants for super calls.
2013-12-13 17:37:49 +01:00
class Base {
foo {
io.write("Base.foo")
}
}
class Derived is Base {
bar {
io.write("Derived.bar")
super.foo
}
}
Derived.new.bar
// expect: Derived.bar
// expect: Base.foo
// TODO(bob): Super constructor calls.
// TODO(bob): Super operator calls.
// TODO(bob): Calling super outside of a class.
// TODO(bob): Super calls inside nested functions in methods.
// TODO(bob): Super where there is no inherited method.
Reference in New Issue Copy Permalink
07c3dff92f
wren/test/super/call_other_method.wren
Response time: 26ms
Mail Licenses API