示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
 public VMPrimitiveRegistration(VMPrimitiveHandler handler)
 {
     this.Handler = handler;
 }
 public VMPrimitiveRegistration(VMPrimitiveHandler handler)
 {
     this.Handler = handler;
 }