MCPcopy
hub / github.com/expr-lang/expr / emitLoopBackwards

Method emitLoopBackwards

compiler/compiler.go:1206–1222  ·  view source on GitHub ↗
(body func())

Source from the content-addressed store, hash-verified

1204}
1205
1206func (c *compiler) emitLoopBackwards(body func()) {
1207 c.emit(OpGetLen)
1208 c.emit(OpInt, 1)
1209 c.emit(OpSubtract)
1210 c.emit(OpSetIndex)
1211 begin := len(c.bytecode)
1212 c.emit(OpGetIndex)
1213 c.emit(OpInt, 0)
1214 c.emit(OpMoreOrEqual)
1215 end := c.emit(OpJumpIfFalse, placeholder)
1216
1217 body()
1218
1219 c.emit(OpDecrementIndex)
1220 c.emit(OpJumpBackward, c.calcBackwardJump(begin))
1221 c.patchJump(end)
1222}
1223
1224func (c *compiler) PredicateNode(node *ast.PredicateNode) {
1225 c.compile(node.Node)

Callers 1

BuiltinNodeMethod · 0.95

Calls 3

emitMethod · 0.95
calcBackwardJumpMethod · 0.95
patchJumpMethod · 0.95

Tested by

no test coverage detected