Files
School/Anul 2/Semestrul 1/Metode avansate de programare/Interpretor/Models/Expressions/VariableExpression.java
T
2024-08-31 12:07:21 +03:00

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);
}
}