neoneo-go/pkg/vm/vm_ops_flow.go

28 lines
696 B
Go
Raw Normal View History

2019-03-16 22:09:04 +00:00
package vm
import (
"github.com/CityOfZion/neo-go/pkg/vm/stack"
)
// Flow control
// RET Returns from the current context
// Returns HALT if there are nomore context's to run
func RET(op stack.Instruction, ctx *stack.Context, istack *stack.Invocation, rstack *stack.RandomAccess) (Vmstate, error) {
2019-03-16 22:09:04 +00:00
// Pop current context from the Inovation stack
ctx, err := istack.PopCurrentContext()
2019-03-16 22:09:04 +00:00
if err != nil {
return FAULT, err
}
// If this was the last context, then we copy over the evaluation stack to the resultstack
// As the program is about to terminate, once we remove the context
2019-03-16 22:09:04 +00:00
if istack.Len() == 0 {
err = ctx.Estack.CopyTo(rstack)
return HALT, err
2019-03-16 22:09:04 +00:00
}
return NONE, nil
}