}}}
(context *funcContext, stmt *ast.NumberForStmt)
| 1048 | } // }}} |
| 1049 | |
| 1050 | func compileNumberForStmt(context *funcContext, stmt *ast.NumberForStmt) { // {{{ |
| 1051 | code := context.Code |
| 1052 | endlabel := context.NewLabel() |
| 1053 | ec := &expcontext{} |
| 1054 | |
| 1055 | context.EnterBlock(endlabel, stmt) |
| 1056 | reg := context.RegTop() |
| 1057 | rindex := context.RegisterLocalVar("(for index)") |
| 1058 | ecupdate(ec, ecLocal, rindex, 0) |
| 1059 | compileExpr(context, reg, stmt.Init, ec) |
| 1060 | |
| 1061 | reg = context.RegTop() |
| 1062 | rlimit := context.RegisterLocalVar("(for limit)") |
| 1063 | ecupdate(ec, ecLocal, rlimit, 0) |
| 1064 | compileExpr(context, reg, stmt.Limit, ec) |
| 1065 | |
| 1066 | reg = context.RegTop() |
| 1067 | rstep := context.RegisterLocalVar("(for step)") |
| 1068 | if stmt.Step == nil { |
| 1069 | stmt.Step = &ast.NumberExpr{Value: "1"} |
| 1070 | stmt.Step.SetLine(sline(stmt.Init)) |
| 1071 | } |
| 1072 | ecupdate(ec, ecLocal, rstep, 0) |
| 1073 | compileExpr(context, reg, stmt.Step, ec) |
| 1074 | |
| 1075 | code.AddASbx(OP_FORPREP, rindex, 0, sline(stmt)) |
| 1076 | |
| 1077 | context.RegisterLocalVar(stmt.Name) |
| 1078 | |
| 1079 | bodypc := code.LastPC() |
| 1080 | compileChunk(context, stmt.Stmts, false) |
| 1081 | |
| 1082 | context.LeaveBlock() |
| 1083 | |
| 1084 | flpc := code.LastPC() |
| 1085 | code.AddASbx(OP_FORLOOP, rindex, bodypc-(flpc+1), sline(stmt)) |
| 1086 | |
| 1087 | context.SetLabelPc(endlabel, code.LastPC()) |
| 1088 | code.SetSbx(bodypc, flpc-bodypc) |
| 1089 | |
| 1090 | } // }}} |
| 1091 | |
| 1092 | func compileGenericForStmt(context *funcContext, stmt *ast.GenericForStmt) { // {{{ |
| 1093 | code := context.Code |
no test coverage detected
searching dependent graphs…