package com.example.Models.Expressions;

import com.example.Exceptions.BaseException;
import com.example.Models.Program.IDictionary;
import com.example.Models.Program.IHeap;
import com.example.Models.Types.IType;
import com.example.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);
    }
}
