Skip to content

Commit

Permalink
[WIP] Implement subroutine opcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Peppece committed Jun 29, 2020
1 parent 8e8703a commit e166ab0
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions eth/vm/logic/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from eth.vm.computation import BaseComputation
from eth.vm.opcode_values import (
JUMPDEST,
BEGINSUB,
)


Expand Down Expand Up @@ -57,3 +58,40 @@ def gas(computation: BaseComputation) -> None:
gas_remaining = computation.get_gas_remaining()

computation.stack_push_int(gas_remaining)


def beginsub(computation: BaseComputation) -> None:
#TODO: raise OOG exception
pass


def jumpsub(computation: BaseComputation) -> None:
sub_loc = computation.stack_pop1_int()

temp = computation.code.program_counter
computation.code.program_counter = sub_loc

next_opcode = computation.code.peek()

if next_opcode != BEGINSUB:
#TODO: abort execution
pass

else:
computation.code.program_counter += 1

if computation.rstack.length >= 1023:
#TODO: abort execution
pass

computation.rstack_push_int(temp + 1)


def returnsub(computation: BaseComputation) -> None:

if computation.rstack.length == 0:
#TODO: abort execution
pass

computation.code.program_counter = computation.rstack_pop1_int()

0 comments on commit e166ab0

Please sign in to comment.