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

Function compileFunctionExpr

compile.go:1307–1348  ·  view source on GitHub ↗

}}}

(context *funcContext, funcexpr *ast.FunctionExpr, ec *expcontext)

Source from the content-addressed store, hash-verified

1305} // }}}
1306
1307func compileFunctionExpr(context *funcContext, funcexpr *ast.FunctionExpr, ec *expcontext) { // {{{
1308 context.Proto.LineDefined = sline(funcexpr)
1309 context.Proto.LastLineDefined = eline(funcexpr)
1310 if len(funcexpr.ParList.Names) > maxRegisters {
1311 raiseCompileError(context, context.Proto.LineDefined, "register overflow")
1312 }
1313 context.Proto.NumParameters = uint8(len(funcexpr.ParList.Names))
1314 if ec.ctype == ecMethod {
1315 context.Proto.NumParameters += 1
1316 context.RegisterLocalVar("self")
1317 }
1318 for _, name := range funcexpr.ParList.Names {
1319 context.RegisterLocalVar(name)
1320 }
1321 if funcexpr.ParList.HasVargs {
1322 if CompatVarArg {
1323 context.Proto.IsVarArg = VarArgHasArg | VarArgNeedsArg
1324 if context.Parent != nil {
1325 context.RegisterLocalVar("arg")
1326 }
1327 }
1328 context.Proto.IsVarArg |= VarArgIsVarArg
1329 }
1330
1331 compileChunk(context, funcexpr.Stmts, false)
1332
1333 context.Code.AddABC(OP_RETURN, 0, 1, 0, eline(funcexpr))
1334 context.EndScope()
1335 context.CheckUnresolvedGoto()
1336 context.Proto.Code = context.Code.List()
1337 context.Proto.DbgSourcePositions = context.Code.PosList()
1338 context.Proto.DbgUpvalues = context.Upvalues.Names()
1339 context.Proto.NumUpvalues = uint8(len(context.Proto.DbgUpvalues))
1340 for _, clv := range context.Proto.Constants {
1341 sv := ""
1342 if slv, ok := clv.(LString); ok {
1343 sv = string(slv)
1344 }
1345 context.Proto.stringConstants = append(context.Proto.stringConstants, sv)
1346 }
1347 patchCode(context)
1348} // }}}
1349
1350func compileTableExpr(context *funcContext, reg int, ex *ast.TableExpr, ec *expcontext) { // {{{
1351 code := context.Code

Callers 2

compileExprFunction · 0.85
CompileFunction · 0.85

Calls 12

slineFunction · 0.85
elineFunction · 0.85
raiseCompileErrorFunction · 0.85
compileChunkFunction · 0.85
patchCodeFunction · 0.85
RegisterLocalVarMethod · 0.80
AddABCMethod · 0.80
EndScopeMethod · 0.80
CheckUnresolvedGotoMethod · 0.80
PosListMethod · 0.80
NamesMethod · 0.80
ListMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…