public bool Resolve(MethodStateMachine methodSM) { //Pop away finished method _callStack.Pop(); //Take its return value if needed if (methodSM.Context.ReturnsValue && _callStack.Count != 0) { _callStack.Peek().TakeMethodReturnValue(methodSM.Context.EvalStack); } if (methodSM.MethodDesc.IsEntryPoint && methodSM.MethodDesc.ReturnType != null) { EntryPointRet(methodSM.Context.EvalStack.Peek(), methodSM.MethodDesc.ReturnType); } //Find finally block. If exists, jump to its offset and continue execution. if not, break if (methodSM.FinalliesBeforeReturn()) { methodSM.State.ExecutionInterruption = ExecutionInterruption.None; return(true); } else { return(false); } }
public ReturnFromSubroutineCommand(int address, int operationCode, ICallStack callStack) : base(address, operationCode) { if (operationCode != 0x00EE) throw new ArgumentOutOfRangeException("operationCode"); if (callStack == null) throw new ArgumentNullException("callStack"); _callStack = callStack; _initialTopOfStack = callStack.Peek(); }
private void ProcessCallStack() { while (_callStack.Count != 0) { MethodStateMachine methodSM = _callStack.Peek(); while (true) { methodSM.ExecInstructions(); if (_interruptionResolvers[methodSM.State.ExecutionInterruption].Resolve(methodSM)) { continue; } else { break; } } } }