MCPcopy Index your code
hub / github.com/Shopify/go-lua / SetTop

Method SetTop

lua.go:556–572  ·  view source on GitHub ↗

SetTop accepts any index, or 0, and sets the stack top to index. If the new top is larger than the old one, then the new elements are filled with nil. If index is 0, then all stack elements are removed. If index is negative, the stack will be decremented by that much. If the decrement is larger tha

(index int)

Source from the content-addressed store, hash-verified

554//
555// http://www.lua.org/manual/5.2/manual.html#lua_settop
556func (l *State) SetTop(index int) {
557 f := l.callInfo.function
558 if index >= 0 {
559 if apiCheck && index > l.stackLast-(f+1) {
560 panic("new top too large")
561 }
562 i := l.top
563 for l.top = f + 1 + index; i < l.top; i++ {
564 l.stack[i] = nil
565 }
566 } else {
567 if apiCheck && -(index+1) > l.top-(f+1) {
568 panic("invalid new top")
569 }
570 l.top += index + 1 // 'subtract' index (index is negative)
571 }
572}
573
574// Remove the element at the given valid index, shifting down the elements
575// above index to fill the gap. This function cannot be called with a

Callers 12

PopMethod · 0.95
TestToBooleanOutOfRangeFunction · 0.95
debug.goFile · 0.80
nextFunction · 0.80
finishProtectedCallFunction · 0.80
base.goFile · 0.80
table.goFile · 0.80
readLineFunction · 0.80
PackageOpenFunction · 0.80
pushGlobalFunctionNameFunction · 0.80
LoadFileFunction · 0.80
os.goFile · 0.80

Calls

no outgoing calls

Tested by 1

TestToBooleanOutOfRangeFunction · 0.76