MCPcopy Index your code
hub / github.com/yuin/gopher-lua / switchToParentThread

Function switchToParentThread

_vm.go:81–103  ·  view source on GitHub ↗

+inline-end

(L *LState, nargs int, haserror bool, kill bool)

Source from the content-addressed store, hash-verified

79} // +inline-end
80
81func switchToParentThread(L *LState, nargs int, haserror bool, kill bool) {
82 parent := L.Parent
83 if parent == nil {
84 L.RaiseError("can not yield from outside of a coroutine")
85 }
86 L.G.CurrentThread = parent
87 L.Parent = nil
88 if !L.wrapped {
89 if haserror {
90 parent.Push(LFalse)
91 } else {
92 parent.Push(LTrue)
93 }
94 }
95 L.XMoveTo(parent, nargs)
96 L.stack.Pop()
97 offset := L.currentFrame.LocalBase - L.currentFrame.ReturnBase
98 L.currentFrame = L.stack.Last()
99 L.reg.SetTop(L.reg.Top() - offset) // remove 'yield' function(including tailcalled functions)
100 if kill {
101 L.kill()
102 }
103}
104
105func callGFunction(L *LState, tailcall bool) bool {
106 frame := L.currentFrame

Callers 3

callGFunctionFunction · 0.70
threadRunFunction · 0.70
initFunction · 0.70

Calls 8

PushMethod · 0.65
PopMethod · 0.65
LastMethod · 0.65
RaiseErrorMethod · 0.45
XMoveToMethod · 0.45
SetTopMethod · 0.45
TopMethod · 0.45
killMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…