Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class A {
- foo(): Int { self.foo() };
- };
- class Main inherits A {
- foo(): Int { 1 };
- main(): Int { (new SELF_TYPE)@A.foo() };
- };
- // givens:
- \eval{main}{1}{1}
- \eval{main}{\new{SELFTYPE}}{main}
- // goal:
- \eval{main}{mainMain}{1}
- //---------
- //possibles
- //---------
- // method foo class Main
- \eval{c}{1}{x} => \eval{c}{fooMain}{x}
- // method foo class A
- \eval{c}{self.foo}{x} => \eval{c}{fooA}{x}
- // method main class Main
- \eval{main}{\new{SELFTYPE}.fooatA}{x} => \eval{main}{mainMain}{x}
- // static dispatch to foo at A
- \eval{c}{e}{d}, \eval{d}{fooA}{x} => \eval{c}{e.fooatA}{x}
- // dynamic dispatch to foo from self
- \eval{c}{fooC}{x} => \eval{c}{self.foo}{x}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement