summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/d5/tengo/compiler/instructions.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/d5/tengo/compiler/instructions.go')
-rw-r--r--vendor/github.com/d5/tengo/compiler/instructions.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/vendor/github.com/d5/tengo/compiler/instructions.go b/vendor/github.com/d5/tengo/compiler/instructions.go
index b04b2826..80c88d13 100644
--- a/vendor/github.com/d5/tengo/compiler/instructions.go
+++ b/vendor/github.com/d5/tengo/compiler/instructions.go
@@ -57,3 +57,16 @@ func FormatInstructions(b []byte, posOffset int) []string {
return out
}
+
+func iterateInstructions(b []byte, fn func(pos int, opcode Opcode, operands []int) bool) {
+ for i := 0; i < len(b); i++ {
+ numOperands := OpcodeOperands[Opcode(b[i])]
+ operands, read := ReadOperands(numOperands, b[i+1:])
+
+ if !fn(i, b[i], operands) {
+ break
+ }
+
+ i += read
+ }
+}