Пример #1
0
 public ProgramState execute(ProgramState programState)
 {
     int pointer = programState.getHeap().size() + 1;
     programState.getHeap().put(pointer,expression.eval(programState.getMyDictionary(), programState.getHeap()));
     programState.getMyDictionary().put(variableName, pointer);
     return null;
 }
Пример #2
0
 public ProgramState execute(ProgramState programState)
 {
     int val = expression.eval(programState.getMyDictionary(), programState.getHeap());
     //insert or update
     programState.getMyDictionary().put(variableName, val);
     return null;
 }
Пример #3
0
 public ProgramState execute(ProgramState programState)
 {
     //IMyStatement statement = programState.getExecutionStack().pop();
     int seconds = time.eval(programState.getMyDictionary(), programState.getHeap());
     if (seconds != 0)
     {
         programState.getExecutionStack().push(new SleepStatement(new ConstantExpression(seconds - 1)));
     }
     return null;
 }
Пример #4
0
        public ProgramState execute(ProgramState programState)
        {
            IMyStack<IMyStatement> stack = new WrapperStack<IMyStatement>();
            stack.push(statement);

            IMyDictionary<String, int> copyDictionary = new WrapperDictionary<String, int>();

            copyDictionary.addAll(programState.getMyDictionary().getMap());
            return new ProgramState(stack, copyDictionary, programState.getOutput(), programState.getHeap(), statement);
        }
Пример #5
0
 public ProgramState execute(ProgramState programState)
 {
     if (expression.eval(programState.getMyDictionary(), programState.getHeap()) != 0)
     {
         programState.getExecutionStack().push(thenStatement);
     }
     else
     {
         programState.getExecutionStack().push(elseStatement);
     }
     return null;
 }
Пример #6
0
 public ProgramState execute(ProgramState programState)
 {
     IHeap<int, int> heap = programState.getHeap();
     IMyDictionary<String, int> myDictionary = programState.getMyDictionary();
     IMyList<String> output = programState.getOutput();
     IMyStack<IMyStatement> secondStack = new WrapperStack<IMyStatement>();
     ProgramState secondProgramState = new ProgramState(secondStack, myDictionary, output, heap, getStatement());
     while (getExpression().eval(myDictionary, heap) != 0)
     {
         runAllSteps(secondProgramState);
         secondStack.push(getStatement());
     }
     return null;
 }
Пример #7
0
 public ProgramState execute(ProgramState programState)
 {
     programState.getHeap().put(programState.getMyDictionary().lookUp(variableName), expression.eval(programState.getMyDictionary(), programState.getHeap()));
     return null;
 }
Пример #8
0
 public ProgramState execute(ProgramState programState)
 {
     IMyList<String> output = programState.getOutput();
     output.add(expression.eval(programState.getMyDictionary(), programState.getHeap()).ToString());
     return null;
 }