package midend.symbol; import java.util.ArrayList; import midend.llvm.value.IrValue; public class Symbol { private String name; private SymbolType type; private int line; private ArrayList valueList; private IrValue irValue; public Symbol(String name, SymbolType type, int line) { this.name = name; this.type = type; this.line = line; valueList = new ArrayList<>(); irValue = null; } public void setIrValue(IrValue irValue) { this.irValue = irValue; } public IrValue getIrValue() { return irValue; } public void addValue(int value) { valueList.add(value); } public void addValue(ArrayList valueList) { this.valueList.addAll(valueList); } public ArrayList getValueList() { return valueList; } public int getValue(int index) { return valueList.get(index); } public String getName() { return name; } public String getTypeStr() { return type.toString(); } public SymbolType getType() { return type; } public int getLine() { return line; } public String toString() { return name + " " + type.toString() + "\n"; } public boolean isThatType(int type) { // 0 for normal var, 1 for array, 2 for func if (type == 1) { return this.type == SymbolType.INT_ARRAY || this.type == SymbolType.CONST_INT_ARRAY || this.type == SymbolType.STATIC_INT_ARRAY; } else if (type == 2) { return this.type == SymbolType.INT_FUNC || this.type == SymbolType.VOID_FUNC; } else { return this.type == SymbolType.INT || this.type == SymbolType.CONST_INT || this.type == SymbolType.STATIC_INT; } } }