Evgenii Stratonikov
d2ccc3b017
vm: make REVERSE consume an item from stack
2019-09-16 15:50:51 +03:00
Evgenii Stratonikov
fd264cb06f
vm: make REVERSE work with structs
...
Also add more tests.
Extend `Array` method of `Element` to work with `StructItem`.
2019-09-16 15:50:51 +03:00
Evgenii Stratonikov
f0426ac2d5
vm: do nothing if SHL/SHR by 0
2019-09-16 15:50:51 +03:00
Evgenii Stratonikov
9eca5ee317
vm: convert SIZE argument to bytearray
2019-09-16 15:50:51 +03:00
Evgenii Stratonikov
9780889239
vm: make NEWARRAY/NEWSTRUCT accept bytearray
2019-09-16 15:50:51 +03:00
Evgenii Stratonikov
09e197eaf3
vm: make PUSH0 create empty bytearray
...
Also make tests expect []byte{} instead of 0.
2019-09-16 15:50:51 +03:00
Evgenii Stratonikov
66501f9ef9
vm: make REMOVE consume array from stack
2019-09-16 15:50:14 +03:00
Evgenii Stratonikov
71cfd14b92
vm: create an array of false
items in NEWARRAY/NEWSTRUCT
2019-09-16 15:24:58 +03:00
Evgenii Stratonikov
bafdb916a0
vm: make PICKITEM accept bytearrays
2019-09-16 15:24:58 +03:00
Evgenii Stratonikov
1881adabb9
vm: fail if NIP has not enough arguments
2019-09-16 15:24:58 +03:00
Evgenii Stratonikov
6e4014547d
vm: fail if DROP has no argument
2019-09-16 15:24:58 +03:00
Evgenii Stratonikov
729b7a0b24
vm: fail if ROT has not enough arguments
2019-09-16 15:24:58 +03:00
Evgenii Stratonikov
cf7fbb80ba
vm: fail if EQUAL has not enough arguments
2019-09-16 15:24:58 +03:00
Evgenii Stratonikov
d257044298
vm: fail if XTUCK argument is 0
2019-09-16 15:24:58 +03:00
Evgenii Stratonikov
56ec097d76
vm: fix codegen for APPEND
2019-09-13 11:24:21 +03:00
Evgenii Stratonikov
68c6c93980
vm: do not allow APPEND to operate on bytearray
2019-09-11 17:17:37 +03:00
Evgenii Stratonikov
723dcc6e25
vm: make APPEND push no value on stack
2019-09-11 17:17:34 +03:00
Roman Khimov
8311bda355
vm: harden LEFT and RIGHT implementations against negative indexes
2019-09-11 14:51:04 +03:00
Roman Khimov
17f3a21e27
vm: harden SUBSTR implementation against bad index/offset values
...
The upper index bound for slices is capacity, not length. Check for negative
values also. Fixes #387 .
2019-09-11 14:37:41 +03:00
Roman Khimov
fc1075bf75
vm: protect PUSHDATA from short reads
...
Same thing done in a2a8981979
for PUSHBYTES,
failing to read the amount of bytes specified should lead to FAULT. Also
makes readUint16() and readUint32() panic as this is the behavior we want in
these cases. Add some tests along the way.
2019-09-11 12:35:37 +03:00
Roman Khimov
392a4c4f39
vm/cli: add some convenience heuristic to ease 'run' use
2019-09-10 23:31:06 +03:00
Roman Khimov
c5911c2f10
vm/cli: add support for bool type as 'run' parameter
2019-09-10 23:31:06 +03:00
Roman Khimov
982bdcd704
vm/cli: make operation mandatory if anything added to run
...
Matches neo-cli behavior.
2019-09-10 23:31:06 +03:00
Roman Khimov
5bd666b786
vm: return NOP as current instruction for just loaded VM
...
Before:
NEO-GO-VM > loadgo h.go
READY: loaded 16 instructions
NEO-GO-VM > ip
instruction pointer at -1 (PUSH0)
After:
NEO-GO-VM > loadgo h.go
READY: loaded 16 instructions
NEO-GO-VM > ip
instruction pointer at -1 (NOP)
I think NOP is a little less scary.
2019-09-10 23:31:06 +03:00
Roman Khimov
e872b6b421
vm/cli: redo the whole thing using abiosoft/ishell
...
Adds history support, better editing and way better help system. Expand on
some helps while at it.
2019-09-10 23:31:06 +03:00
Evgenii Stratonikov
31f4c7486b
vm: add tests for CAT
2019-09-10 17:33:42 +03:00
Evgenii Stratonikov
1289d0f7e9
vm: add tests for NOT
2019-09-10 17:29:10 +03:00
Evgenii Stratonikov
f2393e5efc
vm: implement * -> Boolean conversion
2019-09-10 17:29:10 +03:00
Evgenii Stratonikov
7e14c5a274
vm: implement * -> ByteArray conversion
2019-09-10 17:29:07 +03:00
Evgenii Stratonikov
9b10b4c4d8
vm: add tests for SIGN
2019-09-10 15:08:42 +03:00
Evgenii Stratonikov
52b0d661e0
vm: implement BigInt -> Boolean conversion
2019-09-10 14:19:36 +03:00
Evgenii
0b58ed4a22
vm: do not fault on LEFT with big index
...
Fixes #378 .
2019-09-09 17:29:31 +03:00
Roman Khimov
a039ae6cdb
Merge pull request #374 from nspcc-dev/makefile-and-gofmt
...
Makefile convenience targets and gofmt
2019-09-09 15:05:12 +03:00
Roman Khimov
a2a8981979
vm: fix not failing PUSHBYTES* on short read
...
Add some tests also. Fixes #361 .
2019-09-09 12:09:05 +03:00
Roman Khimov
fabd11699a
*: gofmt -s
...
Appy gofmt for all the source tree.
2019-09-09 12:02:24 +03:00
Roman Khimov
450063de7d
Merge pull request #362 from nspcc-dev/add-missing-opcodes-into-the-list
...
Add missing opcodes into the list
2019-09-09 11:24:39 +03:00
Roman Khimov
7b0c2781d2
vm: expand instruction list with commands from current VM spec
...
Current NEO documentation lists them:
https://docs.neo.org/docs/en-us/tooldev/advanced/neo_vm.html
CALL_* instructions were left out because of conflict with golint (but they're
removed in NEO 3.0 anyway, so wasting time on them makes no sense).
Update autogenerated instruction_string.go accordingly.
2019-09-08 20:46:35 +03:00
Evgenii
bcc8234155
vm: implement Array <-> Struct conversion
...
Reference VM implementation supports convertation from
Struct to Array via NEWARRAY and vice versa.
https://github.com/neo-project/neo-vm/pull/91
2019-09-08 13:40:21 +03:00
Roman Khimov
7e8dc9ad66
vm: uncomment TestForLoopBigIter
...
It works just fine.
2019-09-07 10:10:11 +03:00
Roman Khimov
1c7d203993
compiler: drop TODO comment, #294 was fixed a while ago
2019-09-07 10:09:42 +03:00
Roman Khimov
8169edf04c
vm: expand PUSHBYTES instructions
...
Allows to reliably use String() on any of those. Update autogenerated
instruction_string.go accordingly.
2019-09-06 19:14:47 +03:00
Roman Khimov
aefe572df3
vm: implement UNPACK, REVERSE, REMOVE opcodes
...
Also expand makeStackItem() to accept slices of int for testing
convenience. Fixes #195 .
2019-09-06 19:00:34 +03:00
Roman Khimov
5bd50c7bcd
vm: add some tests for PACK instruction
2019-09-06 13:15:30 +03:00
Roman Khimov
b3ed3d24ee
vm: implement CAT, SUBSTR, LEFT and RIGHT
...
String instruction set.
2019-09-06 12:41:27 +03:00
Roman Khimov
3f40334979
vm: add generic stub for all unimplemented instructions
2019-09-05 17:35:30 +03:00
Roman Khimov
59de72f446
vm: implement INVERT instruction
2019-09-05 17:35:30 +03:00
Roman Khimov
b494e094c0
vm: add XDROP implementation
2019-09-05 17:35:30 +03:00
Roman Khimov
974f5db6bc
vm: add a TUCK implementation with tests
...
Also fix stack's InsertAt for the edge case of inserting into a position that
currently is empty (the first good TUCK test illustrates this).
2019-09-05 17:35:30 +03:00
Roman Khimov
eb224aeebe
vm: add some checks for OVER and PICK, add OVER tests
...
These actually behaved correctly because of deferred sigsegv recover, but I
think it would be nice to print something more meaningful for users.
2019-09-05 17:35:30 +03:00
Roman Khimov
85831e3e92
vm: fix XTUCK implementation, add tests
...
The code that we have actually implements XTUCK and not TUCK. And it's a bit
broken, so fix it and add some tests. The most interesting one (that required
to touch stack code) is the one when we have 1 element on the stack and are
trying to tell XTUCK to push 2 elements deep.
2019-09-05 17:34:25 +03:00