3.3. Stack Operations
-
SQInteger sq_cmp(HSQUIRRELVM v)
- Parameters
v (HSQUIRRELVM) – the target VM
- Returns
> 0 if obj1>obj2
- Returns
== 0 if obj1==obj2
- Returns
< 0 if obj1<obj2
compares 2 object from the top of the stack. obj2 should be pushed before obj1.
-
SQInteger sq_gettop(HSQUIRRELVM v)
- Parameters
v (HSQUIRRELVM) – the target VM
- Returns
an integer representing the index of the top of the stack
returns the index of the top of the stack
-
void sq_pop(HSQUIRRELVM v, SQInteger nelementstopop)
- Parameters
v (HSQUIRRELVM) – the target VM
nelementstopop (SQInteger) – the number of elements to pop
pops n elements from the stack
-
void sq_poptop(HSQUIRRELVM v)
- Parameters
v (HSQUIRRELVM) – the target VM
pops 1 object from the stack
-
void sq_push(HSQUIRRELVM v, SQInteger idx)
- Parameters
v (HSQUIRRELVM) – the target VM
idx (SQInteger) – the index in the stack of the value that has to be pushed
pushes in the stack the value at the index idx
-
void sq_remove(HSQUIRRELVM v, SQInteger idx)
- Parameters
v (HSQUIRRELVM) – the target VM
idx (SQInteger) – index of the element that has to be removed
removes an element from an arbitrary position in the stack
-
SQRESULT sq_reservestack(HSQUIRRELVM v, SQInteger nsize)
- Parameters
v (HSQUIRRELVM) – the target VM
nsize (SQInteger) – required stack size
- Returns
a SQRESULT
ensure that the stack space left is at least of a specified size.If the stack is smaller it will automatically grow. If there’s a metamethod currently running the function will fail and the stack will not be resized, this situation has to be considered a “stack overflow”.
-
void sq_settop(HSQUIRRELVM v, SQInteger v)
- Parameters
v (SQInteger) – the target VM
v – the new top index
resize the stack. If new top is bigger then the current top the function will push nulls.