RoySRC/MiniJavaCompiler

Not sure if the compiler can do runtime polymorphism

Opened this issue · 0 comments

class A {
  public static void main(String[] args) {
    C b;
    b = new B();
    System.out.println(b.a());
  }
}

class B extends C {
  int a;
  public int a() {
    int c;
    c = this.c();
    a = 12 * c;
    return a;
  }
}

class C {
  int c;

  public int c() {
    c = 12;
    return c;
  }
}

should print 144. In order to perform runtime polymorphism we need to implement a vTable. The compiler at this stage has no such implementation.