Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vm: add new opcodes PUSHT & PUSHF #247

Merged
merged 2 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/validate-pr-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ jobs:
- uses: actions/checkout@v3
- uses: psf/black@stable
with:
options: '--target-version py310'
version: '22.8.0'
src: "neo3/ examples/ tests/"
type-checking:
needs: setup
Expand Down
6 changes: 4 additions & 2 deletions neo3/vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class OpCode(IntEnum):
PUSHINT64 = 0x03
PUSHINT128 = 0x04
PUSHINT256 = 0x05
PUSHT = 0x08
PUSHF = 0x09
PUSHA = 0x0A
PUSHNULL = 0x0B
PUSHDATA1 = 0x0C
Expand Down Expand Up @@ -268,9 +270,9 @@ def emit_push(self, value) -> ScriptBuilder:
return self.emit(OpCode.PUSHNULL)
elif isinstance(value, bool):
if value is True:
return self.emit(OpCode.PUSH1)
return self.emit(OpCode.PUSHT)
else:
return self.emit(OpCode.PUSH0)
return self.emit(OpCode.PUSHF)
elif isinstance(value, str):
self.emit_push(value.encode("utf-8"))
return self
Expand Down
2 changes: 1 addition & 1 deletion tests/test_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_emit_push_simple(self):
sb.emit_push(None)
sb.emit_push(True)
sb.emit_push(False)
expected = vm.OpCode.PUSHNULL + vm.OpCode.PUSH1 + vm.OpCode.PUSH0
expected = vm.OpCode.PUSHNULL + vm.OpCode.PUSHT + vm.OpCode.PUSHF
self.assertEqual(expected, sb.to_array())

def test_emit_push_strings(self):
Expand Down