}}}
(context *funcContext, funcexpr *ast.FunctionExpr, ec *expcontext)
| 1305 | } // }}} |
| 1306 | |
| 1307 | func 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 | |
| 1350 | func compileTableExpr(context *funcContext, reg int, ex *ast.TableExpr, ec *expcontext) { // {{{ |
| 1351 | code := context.Code |
no test coverage detected
searching dependent graphs…