2007-12-24 16:19:51 +08:00
|
|
|
package net.loveruby.cflat.ast;
|
2009-05-24 19:23:29 +08:00
|
|
|
import net.loveruby.cflat.type.Type;
|
2007-12-24 16:19:51 +08:00
|
|
|
|
2009-05-24 19:23:29 +08:00
|
|
|
public class AddressNode extends ExprNode {
|
|
|
|
final ExprNode expr;
|
|
|
|
Type type;
|
2008-01-01 22:21:26 +08:00
|
|
|
|
2009-05-24 19:23:29 +08:00
|
|
|
public AddressNode(ExprNode expr) {
|
|
|
|
this.expr = expr;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ExprNode expr() {
|
|
|
|
return expr;
|
2007-12-24 16:19:51 +08:00
|
|
|
}
|
|
|
|
|
2008-01-01 22:21:26 +08:00
|
|
|
public Type type() {
|
|
|
|
if (type == null) throw new Error("type is null");
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
2008-01-03 19:26:07 +08:00
|
|
|
/** Decides type of this node.
|
2009-05-24 19:23:29 +08:00
|
|
|
* This method is called from DereferenceChecker. */
|
2008-01-01 22:21:26 +08:00
|
|
|
public void setType(Type type) {
|
|
|
|
if (this.type != null) throw new Error("type set twice");
|
|
|
|
this.type = type;
|
|
|
|
}
|
|
|
|
|
2009-05-24 19:23:29 +08:00
|
|
|
public Location location() {
|
|
|
|
return expr.location();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void _dump(Dumper d) {
|
|
|
|
if (type != null) {
|
|
|
|
d.printMember("type", type);
|
|
|
|
}
|
|
|
|
d.printMember("expr", expr);
|
|
|
|
}
|
|
|
|
|
2009-04-12 14:31:12 +08:00
|
|
|
public <S,E> E accept(ASTVisitor<S,E> visitor) {
|
2009-04-04 22:47:11 +08:00
|
|
|
return visitor.visit(this);
|
2007-12-24 16:19:51 +08:00
|
|
|
}
|
|
|
|
}
|