From 7b519eba0dd6b0efd48ee5e9bc602d48bba000e8 Mon Sep 17 00:00:00 2001 From: BlockChainDev Date: Sat, 16 Mar 2019 22:09:04 +0000 Subject: [PATCH] Add RET Opcode --- pkg/vm/vm_ops_flow.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 pkg/vm/vm_ops_flow.go diff --git a/pkg/vm/vm_ops_flow.go b/pkg/vm/vm_ops_flow.go new file mode 100644 index 000000000..7a90638b0 --- /dev/null +++ b/pkg/vm/vm_ops_flow.go @@ -0,0 +1,25 @@ +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) (Vmstate, error) { + + // Pop current context from the Inovation stack + err := istack.RemoveCurrentContext() + if err != nil { + return FAULT, err + } + + // If there are no-more context's left to ran, then we HALT + if istack.Len() == 0 { + return HALT, nil + } + + return NONE, nil +}