Skip to content

Commit

Permalink
Rearrange opcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Feb 12, 2024
1 parent ffaec9e commit 9c3bce6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions vm/opcodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ const (
OpDecrementIndex
OpIncrementCount
OpGetIndex
OpSetIndex
OpGetCount
OpGetLen
OpGetGroupBy
OpGetAcc
OpSetAcc
OpSetIndex
OpPointer
OpThrow
OpGroupBy
OpSetAcc
OpBegin
OpEnd // This opcode must be at the end of this list.
)
6 changes: 3 additions & 3 deletions vm/program.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,6 @@ func (program *Program) DisassembleWriter(w io.Writer) {
case OpGetIndex:
code("OpGetIndex")

case OpSetIndex:
code("OpSetIndex")

case OpGetCount:
code("OpGetCount")

Expand All @@ -354,6 +351,9 @@ func (program *Program) DisassembleWriter(w io.Writer) {
case OpSetAcc:
code("OpSetAcc")

case OpSetIndex:
code("OpSetIndex")

case OpBegin:
code("OpBegin")

Expand Down
8 changes: 4 additions & 4 deletions vm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,10 +460,6 @@ func (vm *VM) Run(program *Program, env any) (_ any, err error) {
case OpGetIndex:
vm.push(vm.scope().Index)

case OpSetIndex:
scope := vm.scope()
scope.Index = vm.pop().(int)

case OpGetCount:
scope := vm.scope()
vm.push(scope.Count)
Expand All @@ -481,6 +477,10 @@ func (vm *VM) Run(program *Program, env any) (_ any, err error) {
case OpSetAcc:
vm.scope().Acc = vm.pop()

case OpSetIndex:
scope := vm.scope()
scope.Index = vm.pop().(int)

case OpPointer:
scope := vm.scope()
vm.push(scope.Array.Index(scope.Index).Interface())
Expand Down

0 comments on commit 9c3bce6

Please sign in to comment.