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,33 @@
package Models.Statements;
import Exceptions.BaseException;
import Models.Program.GenericStack;
import Models.Program.IDictionary;
import Models.Program.ProgramState;
import Models.Types.IType;
public class ForkStatement implements IStatement {
private IStatement statement;
public ForkStatement(IStatement statement) {
this.statement = statement;
}
public ProgramState execute(ProgramState state) throws BaseException {
ProgramState forkedProgramState = new ProgramState(new GenericStack<IStatement>(), state.getSymbolTable().copy(), state.getOutput(), state.getFileTable(), state.getHeap(), this.statement);
return forkedProgramState;
}
public IStatement copy() {
return new ForkStatement(this.statement.copy());
}
public String toString() {
return "fork(" + this.statement.toString() + ")";
}
public IDictionary<String, IType> typeCheck(IDictionary<String, IType> typeTable) throws BaseException {
this.statement.typeCheck(typeTable.copy());
return typeTable;
}
}