School Commit Init

This commit is contained in:
2024-08-31 12:07:21 +03:00
commit 0b130ee18c
2801 changed files with 4720552 additions and 0 deletions
@@ -0,0 +1,39 @@
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<IValue> output = state.getOutput();
output.enqueue(expression.evaluate(state.getSymbolTable(), state.getHeap() ));
return null;
}
public IDictionary<String, IType> typeCheck(IDictionary<String, IType> typeTable) throws BaseException{
expression.typeCheck(typeTable);
return typeTable;
}
//endregion
}