public Variable execute( ArrayList Parameters, ArrayList ParentTable, Linker MyLinker, boolean function, boolean loop) throws Exception { try { MyModel.incrementIterationCounter(getLine()); if (MyModel.getExceptionRaised() != null) throw (MyModel.getExceptionRaised()); HashMap MyTable = new HashMap(); ParentTable.add(MyTable); if (!MyModel.getRunAllCode()) { if (Statements.size() > 0) while (Comparison.evaluate(ParentTable, MyLinker, function, loop).truthValue()) { for (int i = 0; i < Statements.size(); i++) { Statement TempStatement = (Statement) Statements.get(i); TempStatement.execute(Parameters, ParentTable, MyLinker, function, true); } } } else { // We must be attempting to run all code. Comparison.evaluate(ParentTable, MyLinker, function, loop); for (int i = 0; i < Statements.size(); i++) { Statement TempStatement = (Statement) Statements.get(i); TempStatement.execute(Parameters, ParentTable, MyLinker, function, loop); } } ParentTable.remove(ParentTable.size() - 1); } catch (Exception e) { if (e instanceof ModelReturn) // Pop from the stack if we're here. ParentTable.remove(ParentTable.size() - 1); if (e instanceof ModelBreak) return (null); if (!(e instanceof ModelError)) throw (new ModelError("Runtime error on line " + getLine() + " when running while loop")); else throw (e); } return (null); }
public void killExecution() { if (ParentModel != null) ParentModel.killExecution(); }