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

Function switchToParentThread

vm.go:176–198  ·  view source on GitHub ↗

+inline-end

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

Source from the content-addressed store, hash-verified

174} // +inline-end
175
176func switchToParentThread(L *LState, nargs int, haserror bool, kill bool) {
177 parent := L.Parent
178 if parent == nil {
179 L.RaiseError("can not yield from outside of a coroutine")
180 }
181 L.G.CurrentThread = parent
182 L.Parent = nil
183 if !L.wrapped {
184 if haserror {
185 parent.Push(LFalse)
186 } else {
187 parent.Push(LTrue)
188 }
189 }
190 L.XMoveTo(parent, nargs)
191 L.stack.Pop()
192 offset := L.currentFrame.LocalBase - L.currentFrame.ReturnBase
193 L.currentFrame = L.stack.Last()
194 L.reg.SetTop(L.reg.Top() - offset) // remove 'yield' function(including tailcalled functions)
195 if kill {
196 L.kill()
197 }
198}
199
200func callGFunction(L *LState, tailcall bool) bool {
201 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…