next up previous contents
Next: svalue Up: The Stack Previous: The Stack   Contents

Pike_sp

Pike_sp is the global stack pointer. Pike_sp[0] always points to the top of the stack. Pike_sp[-1] is the top element on the stack, Pike_sp[-2] the element below, and so on. The example shows a typical fetching of an integer from the top element of the stack.
/*Example of usage:*/
   int number = Pike_sp[-1].u.integer;
When a C level function is called and the arguments are passed to it by the stack, it can find its first argument in Pike_sp[-args], its second in Pike_sp[1-args] and its n'th argument in Pike_sp[n-1-args]. This means that argument i is found in Pike_sp[i-1-args] for every 1 =i=args. The elements of Pike_sp are of type struct svalue.



2003-03-04