package de.dhbwstuttgart.strucTypes4.syntaxtree;


import de.dhbwstuttgart.strucTypes4.typeVars.TypeVarStore;

/**
 * Created by sebastian on 07.04.17.
 */
public class Expression extends ExpressionAbstract {

    ExpressionAbstract receiver;
    ExpressionAbstract caller;

    public Expression(ExpressionAbstract receiver, ExpressionAbstract caller) {
        this.receiver = receiver;
        this.caller = caller;
    }


    public ExpressionAbstract getReceiver() {
        return receiver;
    }

    public void setReceiver(ExpressionAbstract receiver) {
        this.receiver = receiver;
    }

    public ExpressionAbstract getCaller() {
        return caller;
    }

    public void setCaller(ExpressionAbstract caller) {
        this.caller = caller;
    }


   // @Override
    public String toString() {
        return receiver.toString() + caller.toString();
    }


    @Override
    public String toCodeTPH() {
        return String.format(" [[ %s ]  %s ]:%s   " , receiver.toCodeTPH() , caller.toCodeTPH() , getTypePlaceHolder());
    }




    @Override
    public String toCodeTyped(TypeVarStore typeVarStore) {
        return String.format(" [[ %s ]  %s ]:%s   " , receiver.toCodeTyped(typeVarStore) , caller.toCodeTyped(typeVarStore) , typeVarStore.getTypeVarByTPH(getTypePlaceHolder()));
    }
}
