Ejemplo n.º 1
0
Archivo: CPU.cs Proyecto: CalebJ2/KOS
 public CPU(SharedObjects shared)
 {
     this.shared = shared;
     this.shared.Cpu = this;
     stack = new Stack();
     globalVariables = new VariableScope(0, -1);
     contexts = new List<ProgramContext>();
     if (this.shared.UpdateHandler != null) this.shared.UpdateHandler.AddFixedObserver(this);
 }
Ejemplo n.º 2
0
Archivo: CPU.cs Proyecto: KSP-KOS/KOS
 public CPU(SafeSharedObjects shared)
 {
     this.shared = shared;
     this.shared.Cpu = this;
     stack = new Stack();
     globalVariables = new VariableScope(0, -1);
     contexts = new List<ProgramContext>();
     mainYields = new List<YieldFinishedDetector>();
     triggerYields = new List<YieldFinishedDetector>();
     if (this.shared.UpdateHandler != null) this.shared.UpdateHandler.AddFixedObserver(this);
 }
Ejemplo n.º 3
0
Archivo: CPU.cs Proyecto: CalebJ2/KOS
        private void SaveAndClearPointers()
        {
            // Any global variable that ends in an asterisk (*) is a system pointer
            // that shouldn't be inherited by other program contexts.  These sorts of
            // variables should only exist for the current program context.
            // This method stashes all such variables in a storage area for the program
            // context, then clears them.  The stash can be used later by RestorePointers()
            // to bring them back into existence when coming back to this program context again.
            // Pointer variables include:
            //   IP jump location for subprograms.
            //   IP jump location for functions.
            savedPointers = new VariableScope(0, -1);
            var pointers = new List<string>(globalVariables.Variables.Keys.Where(v => v.Contains('*')));

            foreach (string pointerName in pointers)
            {
                savedPointers.Variables.Add(pointerName, globalVariables.Variables[pointerName]);
                globalVariables.Variables.Remove(pointerName);
            }
            SafeHouse.Logger.Log(string.Format("Saving and removing {0} pointers", pointers.Count));
        }
Ejemplo n.º 4
0
        private void SaveAndClearPointers()
        {
            // To be honest, I'm a little afraid of this.  It appears to be doing
            // something with locks (and now user functions) whenever you
            // switch contexts from interpreter to program and it seems to be
            // presuming the only such pointers that need to exist are going to be
            // global.  This was written by marianoapp before I added locals,
            // and I don't understand what it's for -- Dunbaratu

            savedPointers = new VariableScope(0, -1);
            var pointers = new List<string>(globalVariables.Variables.Keys.Where(v => v.Contains('*')));

            foreach (var pointerName in pointers)
            {
                savedPointers.Variables.Add(pointerName, globalVariables.Variables[pointerName]);
                globalVariables.Variables.Remove(pointerName);
            }
            SafeHouse.Logger.Log(string.Format("Saving and removing {0} pointers", pointers.Count));
        }