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

Function Info

debug.go:313–391  ·  view source on GitHub ↗

Info gets information about a specific function or function invocation. To get information about a function invocation, the parameter where must be a valid activation record that was filled by a previous call to Stack or given as an argument to a hook (see Hook). To get information about a functio

(l *State, what string, where Frame)

Source from the content-addressed store, hash-verified

311//
312// This function returns false on error (for instance, an invalid option in what).
313func Info(l *State, what string, where Frame) (d Debug, ok bool) {
314 var f closure
315 var fun value
316 if what[0] == '>' {
317 where = nil
318 fun = l.stack[l.top-1]
319 switch fun := fun.(type) {
320 case closure:
321 f = fun
322 case *goFunction:
323 default:
324 panic("function expected")
325 }
326 what = what[1:] // skip the '>'
327 l.top-- // pop function
328 } else {
329 fun = l.stack[where.function]
330 switch fun := fun.(type) {
331 case closure:
332 f = fun
333 case *goFunction:
334 default:
335 l.assert(false)
336 }
337 }
338 ok, hasL, hasF := true, false, false
339 d.callInfo = where
340 ci := d.callInfo
341 for _, r := range what {
342 switch r {
343 case 'S':
344 d = functionInfo(d, f)
345 case 'l':
346 d.CurrentLine = -1
347 if where != nil && ci.isLua() {
348 d.CurrentLine = l.currentLine(where)
349 }
350 case 'u':
351 if f == nil {
352 d.UpValueCount = 0
353 } else {
354 d.UpValueCount = f.upValueCount()
355 }
356 if lf, ok := f.(*luaClosure); !ok {
357 d.IsVarArg = true
358 d.ParameterCount = 0
359 } else {
360 d.IsVarArg = lf.prototype.isVarArg
361 d.ParameterCount = lf.prototype.parameterCount
362 }
363 case 't':
364 d.IsTailCall = where != nil && ci.isCallStatus(callStatusTail)
365 case 'n':
366 // calling function is a known Lua function?
367 if where != nil && !ci.isCallStatus(callStatusTail) && where.previous.isLua() {
368 d.Name, d.NameKind = l.functionName(where.previous)
369 } else {
370 d.NameKind = ""

Callers 6

checkUpValueMethod · 0.85
internalHookFunction · 0.85
TracebackFunction · 0.85
ArgumentErrorFunction · 0.85
pushGlobalFunctionNameFunction · 0.85
WhereFunction · 0.85

Calls 9

upValueCountMethod · 0.95
functionInfoFunction · 0.85
isLuaMethod · 0.80
currentLineMethod · 0.80
isCallStatusMethod · 0.80
apiPushMethod · 0.80
collectValidLinesMethod · 0.80
assertMethod · 0.45
functionNameMethod · 0.45

Tested by

no test coverage detected