Programming-Language-Design / src / ast / expression / classes / Cast.java
Cast.java
Raw
package ast.expression.classes;

import ast.expression.AbstractExpression;
import ast.expression.Expression;
import ast.type.Type;
import visitor.Visitor;

public class Cast extends AbstractExpression {

    Expression value;
    Type dataType;

    public Cast(int line, int column, Type dataType, Expression value) {
        super(line, column);
        this.value = value;
        this.dataType = dataType;
    }

    public Expression getValue() {
        return value;
    }

    public void setValue(Expression value) {
        this.value = value;
    }

    public Type getDataType() {
        return dataType;
    }

    @Override
    public String toString() {
        return "(" + getDataType() + ")" + getValue();
    }

    @Override
    public <TP, TR> TR accept(Visitor<TP, TR> v, TP param) {
        return v.visit(this, param);
    }
}