【发布时间】:2013-04-27 10:00:59
【问题描述】:
我正在从事与编译器设计相关的项目。我需要为基于 Java 的语言生成三个地址代码,这意味着使用对象和范围。我想您能否帮我为以下示例生成 TAC(或参考我的教程):
class A {
int x;
String y;
public A(int x, String y) {
this.x = x;
this.y = y;
}
}
import A;
class B {
int f;
A foo;
public B() {
this.foo = null;
this.f = -1;
}
public boolean createFoo() {
this.foo = new A(0, "TAC Example");
return true;
}
public static void main() {
B bar = new B();
A baz = new A(666, "TAC generation");
bar.createFoo();
bar.foo.y = "Hello World";
if(bar.foo.x == 666)
return;
bar.foo.x = baz.x;
}
}
【问题讨论】:
标签: java code-generation compiler-optimization compiler-construction