(function int, resultCount int)
| 266 | } |
| 267 | |
| 268 | func (l *State) preCall(function int, resultCount int) bool { |
| 269 | for { |
| 270 | switch f := l.stack[function].(type) { |
| 271 | case *goClosure: |
| 272 | l.callGo(f, function, resultCount) |
| 273 | return true |
| 274 | case *goFunction: |
| 275 | l.callGo(f, function, resultCount) |
| 276 | return true |
| 277 | case *luaClosure: |
| 278 | p := f.prototype |
| 279 | l.checkStack(p.maxStackSize) |
| 280 | argCount, parameterCount := l.top-function-1, p.parameterCount |
| 281 | if argCount < parameterCount { |
| 282 | extra := parameterCount - argCount |
| 283 | args := l.stack[l.top : l.top+extra] |
| 284 | for i := range args { |
| 285 | args[i] = nil |
| 286 | } |
| 287 | l.top += extra |
| 288 | argCount += extra |
| 289 | } |
| 290 | base := function + 1 |
| 291 | if p.isVarArg { |
| 292 | base = l.adjustVarArgs(p, argCount) |
| 293 | } |
| 294 | ci := l.pushLuaFrame(function, base, resultCount, p) |
| 295 | if l.hookMask&MaskCall != 0 { |
| 296 | l.callHook(ci) |
| 297 | } |
| 298 | return false |
| 299 | default: |
| 300 | tm := l.tagMethodByObject(f, tmCall) |
| 301 | switch tm.(type) { |
| 302 | case closure: |
| 303 | case *goFunction: |
| 304 | default: |
| 305 | l.typeError(f, "call") |
| 306 | } |
| 307 | // Slide the args + function up 1 slot and poke in the tag method |
| 308 | for p := l.top; p > function; p-- { |
| 309 | l.stack[p] = l.stack[p-1] |
| 310 | } |
| 311 | l.top++ |
| 312 | l.checkStack(0) |
| 313 | l.stack[function] = tm |
| 314 | } |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | func (l *State) callHook(ci *callInfo) { |
| 319 | ci.savedPC++ // hooks assume 'pc' is already incremented |
no test coverage detected