mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-07 05:07:36 +00:00
Make Next() method on Context failable
refactor peekContext and Peek
This commit is contained in:
parent
48413900ca
commit
9eb11d2822
3 changed files with 23 additions and 11 deletions
|
@ -41,12 +41,12 @@ func (c *Context) Context() (*Context, error) {
|
|||
}
|
||||
|
||||
// Next return the next instruction to execute.
|
||||
func (c *Context) Next() Instruction {
|
||||
func (c *Context) Next() (Instruction, error) {
|
||||
c.ip++
|
||||
if c.ip >= len(c.prog) {
|
||||
return RET
|
||||
return RET, errors.New("program pointer is more than the length of program. RETURNING")
|
||||
}
|
||||
return Instruction(c.prog[c.ip])
|
||||
return Instruction(c.prog[c.ip]), nil
|
||||
}
|
||||
|
||||
// IP returns the absolute instruction without taking 0 into account.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue