package Models.Statements; import Exceptions.BaseException; import Models.Expressions.IExpression; import Models.Program.IDictionary; import Models.Program.IQueue; import Models.Program.ProgramState; import Models.Types.IType; import Models.Values.IValue; public class PrintStatement implements IStatement { //region Fields private IExpression expression; //endregion //region Exposed Methods public PrintStatement(IExpression expression){ this.expression = expression; } public String toString(){ return "print(" + expression.toString() + ")"; } public IStatement copy(){ return new PrintStatement(expression.copy()); } public ProgramState execute(ProgramState state) throws BaseException{ IQueue output = state.getOutput(); output.enqueue(expression.evaluate(state.getSymbolTable(), state.getHeap() )); return null; } public IDictionary typeCheck(IDictionary typeTable) throws BaseException{ expression.typeCheck(typeTable); return typeTable; } //endregion }