return bl
}
+// perLoopStep is part of the encoding of loop-spanning control flow
+// for function range iterators. Each multiple of two encodes a "return false"
+// passing control to an enclosing iterator; a terminal value of 1 encodes
+// "return true" (i.e., local continue) from the body function, and a terminal
+// value of 0 encodes executing the remainder of the body function.
+const perLoopStep = 2
+
// editBranch returns the replacement for the branch statement x,
// or x itself if it should be left alone.
// See the package doc comment above for more context.
// Set next to break the appropriate number of times;
// the final time may be a continue, not a break.
- next = 2 * depth
+ next = perLoopStep * depth
if x.Tok == syntax.Continue {
next--
}
list = append(list, r.ifNext(syntax.Lss, 0, retStmt(r.useVar(r.false))))
}
if loop.checkBreak {
- list = append(list, r.ifNext(syntax.Geq, 2, retStmt(r.useVar(r.false))))
+ list = append(list, r.ifNext(syntax.Geq, perLoopStep, retStmt(r.useVar(r.false))))
}
if loop.checkContinue {
- list = append(list, r.ifNext(syntax.Eql, 1, retStmt(r.useVar(r.true))))
+ list = append(list, r.ifNext(syntax.Eql, perLoopStep-1, retStmt(r.useVar(r.true))))
}
}