private void MoveToInstruction(VMStackFrame frame, byte instruction, bool continueExecution) { if (frame is VMRoutingFrame) { //TODO: Handle returning false into the pathfinder (indicates failure) return; } ContinueExecution = continueExecution; switch (instruction) { case 255: Pop(VMPrimitiveExitCode.RETURN_FALSE); break; case 254: Pop(VMPrimitiveExitCode.RETURN_TRUE); break; case 253: //attempt to continue along only path available. if (frame.GetCurrentInstruction().TruePointer != 253) { MoveToInstruction(frame, frame.GetCurrentInstruction().TruePointer, continueExecution); return; } else if (frame.GetCurrentInstruction().FalsePointer != 253) { MoveToInstruction(frame, frame.GetCurrentInstruction().FalsePointer, continueExecution); return; } Pop(VMPrimitiveExitCode.ERROR); break; default: frame.InstructionPointer = instruction; if (frame.GetCurrentInstruction().Breakpoint || (ThreadBreak != VMThreadBreakMode.Active && ( ThreadBreak == VMThreadBreakMode.StepIn || (ThreadBreak == VMThreadBreakMode.StepOver && Stack.Count - 1 <= BreakFrame) || (ThreadBreak == VMThreadBreakMode.StepOut && Stack.Count <= BreakFrame) ))) { string result = "Unknown Break"; switch (ThreadBreak) { case VMThreadBreakMode.StepIn: result = "Stepped In."; break; case VMThreadBreakMode.StepOut: result = "Stepped Out."; break; case VMThreadBreakMode.StepOver: result = "Stepped Over."; break; } Breakpoint(frame, result); } break; } ContinueExecution = (ThreadBreak != VMThreadBreakMode.Pause) && ContinueExecution; }
private void ExecuteInstruction(VMStackFrame frame) { var instruction = frame.GetCurrentInstruction(); var opcode = instruction.Opcode; if (opcode >= 256) { ExecuteSubRoutine(frame, opcode, (VMSubRoutineOperand)instruction.Operand); return; } var primitive = VMContext.Primitives[opcode]; if (primitive == null) { HandleResult(frame, instruction, VMPrimitiveExitCode.GOTO_TRUE); return; } VMPrimitiveHandler handler = primitive.GetHandler(); var result = handler.Execute(frame, instruction.Operand); HandleResult(frame, instruction, result); }
private void ExecuteInstruction(VMStackFrame frame) { var instruction = frame.GetCurrentInstruction(); var opcode = instruction.Opcode; if (opcode >= 256) { BHAV bhav = null; GameObject CodeOwner; if (opcode >= 8192) { // Semi-Global sub-routine call bhav = frame.ScopeResource.SemiGlobal.Get <BHAV>(opcode); } else if (opcode >= 4096) { // Private sub-routine call bhav = frame.ScopeResource.Get <BHAV>(opcode); } else { // Global sub-routine call //CodeOwner = frame.Global.Resource; bhav = frame.Global.Resource.Get <BHAV>(opcode); } CodeOwner = frame.CodeOwner; var operand = (VMSubRoutineOperand)instruction.Operand; ExecuteSubRoutine(frame, bhav, CodeOwner, operand); if (Stack.LastOrDefault().GetCurrentInstruction().Breakpoint || ThreadBreak == VMThreadBreakMode.StepIn) { Breakpoint(frame); ContinueExecution = false; } else { ContinueExecution = true; } return; } var primitive = Context.Primitives[opcode]; if (primitive == null) { //throw new Exception("Unknown primitive!"); HandleResult(frame, instruction, VMPrimitiveExitCode.GOTO_TRUE); return; //Pop(VMPrimitiveExitCode.ERROR); } VMPrimitiveHandler handler = primitive.GetHandler(); var result = handler.Execute(frame, instruction.Operand); HandleResult(frame, instruction, result); }
void ExecuteInstruction(VMStackFrame frame) { var instruction = frame.GetCurrentInstruction(); var opcode = instruction.Opcode; if (opcode >= 256) { VMRoutine bhav = null; GameObject CodeOwner; if (opcode >= 8192) { // Semi-Global sub-routine call bhav = (VMRoutine)frame.ScopeResource.SemiGlobal.GetRoutine(opcode); } else if (opcode >= 4096) { // Private sub-routine call bhav = (VMRoutine)frame.ScopeResource.GetRoutine(opcode); } else { // Global sub-routine call //CodeOwner = frame.Global.Resource; bhav = (VMRoutine)frame.Global.Resource.GetRoutine(opcode); } CodeOwner = frame.CodeOwner; var operand = (VMSubRoutineOperand)instruction.Operand; ExecuteSubRoutine(frame, bhav, CodeOwner, operand); #if IDE_COMPAT if (Stack.LastOrDefault().GetCurrentInstruction().Breakpoint || ThreadBreak == VMThreadBreakMode.StepIn) { Breakpoint(frame, "Stepped in."); ContinueExecution = false; } else #endif { ContinueExecution = true; } return; } var primitive = VMContext.Primitives[opcode]; if (primitive == null) { HandleResult(frame, instruction, VMPrimitiveExitCode.GOTO_TRUE); return; } VMPrimitiveHandler handler = primitive.GetHandler(); var result = handler.Execute(frame, instruction.Operand); HandleResult(frame, instruction, result); }
private void MoveToInstruction(VMStackFrame frame, byte instruction, bool continueExecution) { if (frame is VMRoutingFrame) { //TODO: Handle returning false into the pathfinder (indicates failure) return; } switch (instruction) { case 255: Pop(VMPrimitiveExitCode.RETURN_FALSE); break; case 254: Pop(VMPrimitiveExitCode.RETURN_TRUE); break; case 253: Pop(VMPrimitiveExitCode.ERROR); break; default: frame.InstructionPointer = instruction; if (frame.GetCurrentInstruction().Breakpoint || (ThreadBreak != VMThreadBreakMode.Active && ( ThreadBreak == VMThreadBreakMode.StepIn || (ThreadBreak == VMThreadBreakMode.StepOver && Stack.Count - 1 <= BreakFrame) || (ThreadBreak == VMThreadBreakMode.StepOut && Stack.Count <= BreakFrame) ))) { Breakpoint(frame); } break; } ContinueExecution = (ThreadBreak != VMThreadBreakMode.Pause) && continueExecution; }