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

Function compileGenericForStmt

compile.go:1092–1122  ·  view source on GitHub ↗

}}}

(context *funcContext, stmt *ast.GenericForStmt)

Source from the content-addressed store, hash-verified

1090} // }}}
1091
1092func compileGenericForStmt(context *funcContext, stmt *ast.GenericForStmt) { // {{{
1093 code := context.Code
1094 endlabel := context.NewLabel()
1095 bodylabel := context.NewLabel()
1096 fllabel := context.NewLabel()
1097 nnames := len(stmt.Names)
1098
1099 context.EnterBlock(endlabel, stmt)
1100 rgen := context.RegisterLocalVar("(for generator)")
1101 context.RegisterLocalVar("(for state)")
1102 context.RegisterLocalVar("(for control)")
1103
1104 compileRegAssignment(context, stmt.Names, stmt.Exprs, context.RegTop()-3, 3, sline(stmt))
1105
1106 code.AddASbx(OP_JMP, 0, fllabel, sline(stmt))
1107
1108 for _, name := range stmt.Names {
1109 context.RegisterLocalVar(name)
1110 }
1111
1112 context.SetLabelPc(bodylabel, code.LastPC())
1113 compileChunk(context, stmt.Stmts, false)
1114
1115 context.LeaveBlock()
1116
1117 context.SetLabelPc(fllabel, code.LastPC())
1118 code.AddABC(OP_TFORLOOP, rgen, 0, nnames, sline(stmt))
1119 code.AddASbx(OP_JMP, 0, bodylabel, sline(stmt))
1120
1121 context.SetLabelPc(endlabel, code.LastPC())
1122} // }}}
1123
1124func compileLabelStmt(context *funcContext, stmt *ast.LabelStmt, isLastStmt bool) { // {{{
1125 labelId := context.NewLabel()

Callers 1

compileStmtFunction · 0.85

Calls 12

compileRegAssignmentFunction · 0.85
slineFunction · 0.85
compileChunkFunction · 0.85
NewLabelMethod · 0.80
EnterBlockMethod · 0.80
RegisterLocalVarMethod · 0.80
RegTopMethod · 0.80
AddASbxMethod · 0.80
SetLabelPcMethod · 0.80
LastPCMethod · 0.80
LeaveBlockMethod · 0.80
AddABCMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…