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

Function callGFunction

vm.go:200–265  ·  view source on GitHub ↗
(L *LState, tailcall bool)

Source from the content-addressed store, hash-verified

198}
199
200func callGFunction(L *LState, tailcall bool) bool {
201 frame := L.currentFrame
202 gfnret := frame.Fn.GFunction(L)
203 if tailcall {
204 L.currentFrame = L.RemoveCallerFrame()
205 }
206
207 if gfnret < 0 {
208 switchToParentThread(L, L.GetTop(), false, false)
209 return true
210 }
211
212 wantret := frame.NRet
213 if wantret == MultRet {
214 wantret = gfnret
215 }
216
217 if tailcall && L.Parent != nil && L.stack.Sp() == 1 {
218 switchToParentThread(L, wantret, false, true)
219 return true
220 }
221
222 // this section is inlined by go-inline
223 // source function is 'func (rg *registry) CopyRange(regv, start, limit, n int) ' in '_state.go'
224 {
225 rg := L.reg
226 regv := frame.ReturnBase
227 start := L.reg.Top() - gfnret
228 limit := -1
229 n := wantret
230 newSize := regv + n
231 // this section is inlined by go-inline
232 // source function is 'func (rg *registry) checkSize(requiredSize int) ' in '_state.go'
233 {
234 requiredSize := newSize
235 if requiredSize > cap(rg.array) {
236 rg.resize(requiredSize)
237 }
238 }
239 if limit == -1 || limit > rg.top {
240 limit = rg.top
241 }
242 for i := 0; i < n; i++ {
243 srcIdx := start + i
244 if srcIdx >= limit || srcIdx < 0 {
245 rg.array[regv+i] = LNil
246 } else {
247 rg.array[regv+i] = rg.array[srcIdx]
248 }
249 }
250
251 // values beyond top don't need to be valid LValues, so setting them to nil is fine
252 // setting them to nil rather than LNil lets us invoke the golang memclr opto
253 oldtop := rg.top
254 rg.top = regv + n
255 if rg.top < oldtop {
256 nilRange := rg.array[rg.top:oldtop]
257 for i := range nilRange {

Callers 3

mainLoopFunction · 0.70
mainLoopWithContextFunction · 0.70
initFunction · 0.70

Calls 8

switchToParentThreadFunction · 0.70
SpMethod · 0.65
PopMethod · 0.65
LastMethod · 0.65
RemoveCallerFrameMethod · 0.45
GetTopMethod · 0.45
TopMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…