Advertisement
NLinker

DeduceIt #5.2

Apr 3rd, 2013
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.70 KB | None | 0 0
  1. class A {
  2.     foo(): Int { self.foo() };
  3. };
  4.  
  5. class Main inherits A {
  6.     foo(): Int { 1 };  
  7.     main(): Int { (new SELF_TYPE)@A.foo() };
  8. };
  9.  
  10. // givens:
  11. \eval{main}{1}{1}
  12. \eval{main}{\new{SELFTYPE}}{main}
  13. // goal:
  14. \eval{main}{mainMain}{1}
  15.  
  16.  
  17. //---------
  18. //possibles
  19. //---------
  20.  
  21. // method foo class Main
  22. \eval{c}{1}{x}        => \eval{c}{fooMain}{x}
  23.  
  24. // method foo class A
  25. \eval{c}{self.foo}{x} => \eval{c}{fooA}{x}
  26.  
  27. // method main class Main
  28. \eval{main}{\new{SELFTYPE}.fooatA}{x} => \eval{main}{mainMain}{x}
  29.  
  30. // static dispatch to foo at A
  31. \eval{c}{e}{d}, \eval{d}{fooA}{x} => \eval{c}{e.fooatA}{x}
  32.  
  33. // dynamic dispatch to foo from self
  34. \eval{c}{fooC}{x} => \eval{c}{self.foo}{x}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement