Beispiel #1
0
 public void RunProgram(List <Opcode> program, bool silent)
 {
     if (program.Count > 0)
     {
         ProgramContext newContext = new ProgramContext(program);
         newContext.Silent = silent;
         PushContext(newContext);
     }
 }
Beispiel #2
0
        private void PushContext(ProgramContext context)
        {
            _contexts.Add(context);
            _currentContext = _contexts[_contexts.Count - 1];

            if (_contexts.Count > 1)
            {
                _shared.Interpreter.SetInputLock(true);
            }
        }
Beispiel #3
0
        private bool ExecuteInstruction(ProgramContext context)
        {
            Opcode opcode = context.Program[context.InstructionPointer];

            if (!(opcode is OpcodeEOF || opcode is OpcodeEOP))
            {
                opcode.Execute(this);
                context.InstructionPointer += opcode.DeltaInstructionPointer;
                return(true);
            }
            else
            {
                if (opcode is OpcodeEOP)
                {
                    BreakExecution(false);
                }
                return(false);
            }
        }
Beispiel #4
0
        private void PopContext()
        {
            if (_contexts.Count > 0)
            {
                // remove the last context
                ProgramContext contextRemove = _contexts[_contexts.Count - 1];
                _contexts.Remove(contextRemove);
                contextRemove.DisableActiveFlyByWire(_shared.BindingMgr);

                if (_contexts.Count > 0)
                {
                    _currentContext = _contexts[_contexts.Count - 1];
                }
                else
                {
                    _currentContext = null;
                }

                if (_contexts.Count == 1)
                {
                    _shared.Interpreter.SetInputLock(false);
                }
            }
        }