상속: IStack
예제 #1
0
파일: KOSDelegate.cs 프로젝트: CalebJ2/KOS
 /// <summary>
 /// Assuming normal args are already on the stack,
 /// then the prebound args would have to be inserted
 /// underneath them, which slightly violates the
 /// stack access rules.  So do it through this method
 /// if it's needed.  (If Call() was used, then it's not needed
 /// because Call() does this for you.  But if Call() was
 /// not used and someone just used bare parentheses like so:
 ///    function y { parameter a,b,c. print a+b+c. }
 ///    set x to y@:bind(1,2).
 ///    x(). // instead of saying x:call().
 /// then the prebound args don't get pushed by doing that, and they
 /// have to get pushed under the top by calling this.)
 /// </summary>
 public void InsertPreBoundArgs()
 {
     Stack<object> aboveArgs = new Stack<object>();
     object arg = ""; // doesn't matter what it is as long as it's non-null for the while check below.
     while (arg != null && !(arg is KOSArgMarkerType))
     {
         arg = Cpu.PopStack();
         if (!(arg is KOSArgMarkerType))
             aboveArgs.Push(arg);
     }
     if (arg == null)
         throw new KOSException("KOSDelegate.InsertPreBoundArgs: Stack arg bottom missing.\n" +
                                "Contact the kOS devs.  This message should 'never' happen.");
     // Now re-push the args back, putting the preBound ones at the bottom
     // where they belong:
     Cpu.PushStack(new KOSArgMarkerType());
     foreach (Structure item in PreBoundArgs)
     {
         Cpu.PushStack(item);
     }
     foreach (object item in aboveArgs) // Because this was pushed to a stack, this should show in reverse order.
     {
         Cpu.PushStack(item);
     }
 }
예제 #2
0
파일: FakeCpu.cs 프로젝트: KSP-KOS/KOS
 public FakeCpu()
 {
     fakeStack = new Stack<object>();
 }