Skip to content

Commit e377e53

Browse files
committed
[WIP] Implement simple subroutine opcodes]
1 parent e99c054 commit e377e53

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

eth/vm/computation.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,17 @@ def stack_push_int(self) -> Callable[[int], None]:
324324
@cached_property
325325
def stack_push_bytes(self) -> Callable[[bytes], None]:
326326
return self._stack.push_bytes
327+
328+
#
329+
# Return Stack Management
330+
#
331+
@cached_property
332+
def rstack_push_int(self) -> Callable[[int], None]:
333+
return self._rstack.push_int
334+
335+
@cached_property
336+
def rstack_pop1_int(self) -> Callable[[int]], None]:
337+
return self._rstack.pop1_int
327338

328339
#
329340
# Computation result

eth/vm/rstack.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@
2323
For the same reason, the class RStack doesn't inherit from the abc StackAPI, as it would require to implement all the abstract methods defined.
2424
"""
2525

26+
27+
def _busted_type(item_type: type, value: Union[int, bytes]) -> ValidationError:
28+
return ValidationError(
29+
"Stack must always be bytes or int, "
30+
f"got {item_type!r} type, val {value!r}"
31+
)
32+
2633
class RStack():
2734
"""
2835
VM Return Stack
@@ -46,7 +53,7 @@ def push_int(self) -> int:
4653
self._append((int, value))
4754

4855

49-
def pop1_int(self) -> int:
56+
def pop1_int(self) -> int:
5057
#
5158
# Note: This function is optimized for speed over readability.
5259
#
@@ -61,10 +68,3 @@ def pop1_int(self) -> int:
6168
else:
6269
raise _busted_type(item_type, popped)
6370

64-
def _busted_type(item_type: type, value: Union[int, bytes]) -> ValidationError:
65-
return ValidationError(
66-
"Stack must always be bytes or int, "
67-
f"got {item_type!r} type, val {value!r}"
68-
)
69-
70-

0 commit comments

Comments
 (0)