neoneo-go/pkg/vm/vm_ops_maths.go
BlockChainDev c7fb4c3bdf - Add Add OpCode
- Add Opcode Function map
2019-03-15 22:36:16 +00:00

25 lines
524 B
Go

package vm
import "github.com/CityOfZion/neo-go/pkg/vm/stack"
// Add adds two stack Items together.
// Returns an error if either items cannot be casted to an integer
// or if integers cannot be added together
func Add(ctx *stack.Context, istack *stack.Invocation) error {
operandA, err := ctx.Estack.PopInt()
if err != nil {
return err
}
operandB, err := ctx.Estack.PopInt()
if err != nil {
return err
}
res, err := operandA.Add(operandB)
if err != nil {
return err
}
ctx.Estack.Push(res)
return nil
}