+inline-end
(L *LState, nargs int, haserror bool, kill bool)
| 174 | } // +inline-end |
| 175 | |
| 176 | func 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 | |
| 200 | func callGFunction(L *LState, tailcall bool) bool { |
| 201 | frame := L.currentFrame |