32 lines
755 B
Java
32 lines
755 B
Java
package Models.Expressions;
|
|
|
|
import Exceptions.BaseException;
|
|
import Models.Program.IDictionary;
|
|
import Models.Program.IHeap;
|
|
import Models.Types.IType;
|
|
import Models.Values.IValue;
|
|
|
|
public class VariableExpression implements IExpression {
|
|
private String name;
|
|
|
|
public VariableExpression(String name) {
|
|
this.name = name;
|
|
}
|
|
|
|
public IValue evaluate(IDictionary<String, IValue> table, IHeap heap) throws BaseException {
|
|
return table.get(name);
|
|
}
|
|
|
|
public IExpression copy() {
|
|
return new VariableExpression(name);
|
|
}
|
|
|
|
public String toString() {
|
|
return name;
|
|
}
|
|
|
|
public IType typeCheck(IDictionary<String, IType> typeTable) throws BaseException {
|
|
return typeTable.get(name);
|
|
}
|
|
}
|