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

Method preCall

stack.go:268–316  ·  view source on GitHub ↗
(function int, resultCount int)

Source from the content-addressed store, hash-verified

266}
267
268func (l *State) preCall(function int, resultCount int) bool {
269 for {
270 switch f := l.stack[function].(type) {
271 case *goClosure:
272 l.callGo(f, function, resultCount)
273 return true
274 case *goFunction:
275 l.callGo(f, function, resultCount)
276 return true
277 case *luaClosure:
278 p := f.prototype
279 l.checkStack(p.maxStackSize)
280 argCount, parameterCount := l.top-function-1, p.parameterCount
281 if argCount < parameterCount {
282 extra := parameterCount - argCount
283 args := l.stack[l.top : l.top+extra]
284 for i := range args {
285 args[i] = nil
286 }
287 l.top += extra
288 argCount += extra
289 }
290 base := function + 1
291 if p.isVarArg {
292 base = l.adjustVarArgs(p, argCount)
293 }
294 ci := l.pushLuaFrame(function, base, resultCount, p)
295 if l.hookMask&MaskCall != 0 {
296 l.callHook(ci)
297 }
298 return false
299 default:
300 tm := l.tagMethodByObject(f, tmCall)
301 switch tm.(type) {
302 case closure:
303 case *goFunction:
304 default:
305 l.typeError(f, "call")
306 }
307 // Slide the args + function up 1 slot and poke in the tag method
308 for p := l.top; p > function; p-- {
309 l.stack[p] = l.stack[p-1]
310 }
311 l.top++
312 l.checkStack(0)
313 l.stack[function] = tm
314 }
315 }
316}
317
318func (l *State) callHook(ci *callInfo) {
319 ci.savedPC++ // hooks assume 'pc' is already incremented

Callers 3

executeSwitchMethod · 0.95
callMethod · 0.95
initFunction · 0.80

Calls 7

callGoMethod · 0.95
checkStackMethod · 0.95
adjustVarArgsMethod · 0.95
pushLuaFrameMethod · 0.95
callHookMethod · 0.95
tagMethodByObjectMethod · 0.95
typeErrorMethod · 0.95

Tested by

no test coverage detected