cbc/net/loveruby/cflat/ast/Entity.java

62 lines
1.2 KiB
Java

package net.loveruby.cflat.ast;
import net.loveruby.cflat.type.*;
import net.loveruby.cflat.asm.*;
abstract public class Entity extends Node {
protected String name;
protected boolean isPrivate;
protected TypeNode typeNode;
protected long nRefered;
public Entity(boolean priv, TypeNode type, String name) {
this.name = name;
this.isPrivate = priv;
this.typeNode = type;
this.nRefered = 0;
}
public String name() {
return name;
}
abstract public boolean isDefined();
abstract public boolean isInitialized();
public boolean isParameter() { return false; }
public boolean isPrivate() {
return isPrivate;
}
public TypeNode typeNode() {
return typeNode;
}
public Type type() {
return typeNode.type();
}
public long allocSize() {
return type().allocSize();
}
public long alignment() {
return type().alignment();
}
public void refered() {
nRefered++;
}
public boolean isRefered() {
return (nRefered > 0);
}
abstract public MemoryReference memref();
abstract public AsmOperand address();
public Location location() {
return typeNode.location();
}
}