コード例 #1
0
        private void ExecuteInstruction(VMStackFrame frame)
        {
            var instruction = frame.GetCurrentInstruction();
            var opcode      = instruction.Opcode;

            if (opcode >= 256)
            {
                BHAV bhav = null;

                GameIffResource CodeOwner;
                if (opcode >= 8192)
                {
                    CodeOwner = frame.Callee.SemiGlobal.Resource;
                    bhav      = frame.Callee.SemiGlobal.Resource.Get <BHAV>(opcode);
                }
                else if (opcode >= 4096)
                {
                    /** Private sub-routine call **/
                    CodeOwner = frame.CalleePrivate;
                    bhav      = frame.CalleePrivate.Get <BHAV>(opcode);
                }
                else
                {
                    /** Global sub-routine call **/
                    CodeOwner = frame.Global.Resource;
                    bhav      = frame.Global.Resource.Get <BHAV>(opcode);
                }

                var operand = frame.GetCurrentOperand <VMSubRoutineOperand>();
                ExecuteSubRoutine(frame, bhav, CodeOwner, operand);
                return;
            }


            var primitive = Context.GetPrimitive(opcode);

            if (primitive == null)
            {
                throw new Exception("Unknown primitive!");
                //Pop(VMPrimitiveExitCode.ERROR);
                //return;
            }

            VMPrimitiveHandler handler = primitive.GetHandler();
            var result = handler.Execute(frame);

            HandleResult(frame, instruction, result);
        }
コード例 #2
0
 public VMPrimitiveRegistration(VMPrimitiveHandler handler)
 {
     this.Handler = handler;
 }
コード例 #3
0
 public VMPrimitiveRegistration(VMPrimitiveHandler handler)
 {
     this.Handler = handler;
 }