void push( SMValue v ) { if (stackHeight >= stack.Length) { // grow the stack SMValue[] newStack = new SMValue[stackHeight+stackSizeIncrement]; stack.CopyTo(newStack,0); stack = newStack; } if ((traceFlags & TraceOptions.TraceStack) != TraceOptions.None) Console.WriteLine("* push {0}", v); stack[stackHeight++] = v; }
SMValue pop() { if (stackHeight <= 0) throw new RunTimeError("stack underflow"); SMValue result = stack[--stackHeight]; stack[stackHeight] = new SMValue(); if ((traceFlags & TraceOptions.TraceStack) != TraceOptions.None) Console.WriteLine("* {0} popped", result); return result; }