Commit graph

305 commits

Author SHA1 Message Date
Roman Khimov
5f22bdfecf
Merge pull request #1375 from nspcc-dev/compiler/types
Smartcontract types definition in interops
2020-09-16 14:43:50 +03:00
Evgenii Stratonikov
bcc11cbd74 compiler: support removing slice elements
Go-way of removing elements from slice is via `append` builtin.
There is a separate opcode for removing elements from
Arrays, which is cheaper and supported in this commit.
2020-09-15 16:33:43 +03:00
Evgenii Stratonikov
78948ef7af compiler: emit error for non-byte subslices
They are not supported for now, as VM has only
`SUBSTR` opcode for Buffers (`[]byte` in Go).
2020-09-15 16:21:44 +03:00
Evgenii Stratonikov
37f7363386 interop: return struct pointers where needed
`Transaction`, `Block` and `Contract` are represented as
`Array`s in VM, so we must return pointers.

Revert a1f98f92.
2020-09-09 13:10:04 +03:00
Evgenii Stratonikov
25f8545cdf compiler: extend manifest generation with custom types 2020-09-09 13:06:44 +03:00
Evgenii Stratonikov
7483e3b054 compiler: support delete() builtin 2020-09-06 15:49:41 +03:00
Evgenii Stratonikov
18369c489e compiler: do not allocate slotes for unused "_" vars 2020-09-06 15:27:46 +03:00
Evgenii Stratonikov
0b44a43043 compiler: do not allocate static slot for constants
Their value is known at compile time.
2020-09-06 15:20:17 +03:00
Roman Khimov
18204ec21a
Merge pull request #1383 from nspcc-dev/compiler/switchtag
compiler: fix a bug with type conversion in switch
2020-09-03 14:40:17 +03:00
Anna Shaleva
70a58b6522 compiler: do not convert methods to manifest methods
Close #1381
2020-09-02 22:41:54 +03:00
Anna Shaleva
058da7c2bd compiler: getFuncNameFromDecl for methods on pointers
Declaration has *ast.StarExpr type in case of method on pointer.
2020-09-02 22:41:54 +03:00
Evgenii Stratonikov
74dda0ac66 compiler: allow to use type conversion in range 2020-09-02 15:35:20 +03:00
Evgenii Stratonikov
3af7ce8c6b compiler: allow to use copy() return value 2020-09-02 15:29:59 +03:00
Evgenii Stratonikov
3d8c7af66c compiler: handle void call to recover()
Other builtins such as `len` and `make` can be ignored,
because not-assigning `make` result is catched by parser.
2020-09-02 15:20:43 +03:00
Evgenii Stratonikov
7d61a567d5 compiler: fix a bug with type conversion in switch
It was incorrectly parsed as void call.
2020-09-02 14:48:19 +03:00
Evgenii Stratonikov
5d82b82efb compiler: support recover() 2020-08-27 10:28:50 +03:00
Evgenii Stratonikov
14ea3c2228 compiler: do not log panic message
In NEO3 THROW accepts an argument and exceptions can be handled, so
there is no need to log it.
2020-08-27 10:28:50 +03:00
Evgenii Stratonikov
fa1d1a8b00 compiler: support defer statement
Compile `defer` statement to a TRY/ENDFINALLY opcode pair.
2020-08-27 10:28:50 +03:00
Evgenii Stratonikov
b18a7f200c compiler: calculate local variables properly
In case when right-hand side of an assignment is a function,
left-hand side should be used.
2020-08-27 10:28:50 +03:00
Evgenii Stratonikov
84c36326f5 compiler: allow init statement in if 2020-08-27 10:28:50 +03:00
Evgenii Stratonikov
d73f3cd24c compiler: support calling function literals 2020-08-27 10:28:50 +03:00
Roman Khimov
962f45f35e
Merge pull request #1361 from nspcc-dev/feature/iota
compiler: support `iota`
2020-08-25 15:50:20 +03:00
Evgenii Stratonikov
05ef951055 compiler: support iota 2020-08-25 10:22:58 +03:00
Roman Khimov
a1fbe51bca
Merge pull request #1352 from nspcc-dev/compiler/make
Fix MEMCPY, support `copy` and `make` in compiler
2020-08-25 09:33:16 +03:00
Evgenii Stratonikov
69989e1227 compiler: support copy() 2020-08-25 08:53:29 +03:00
Evgenii Stratonikov
931dc6c64f compiler: remove debug PrintOps() from tests 2020-08-25 08:53:29 +03:00
Evgenii Stratonikov
0f11116040 compiler: support make() 2020-08-25 08:53:28 +03:00
Evgenii Stratonikov
354645fbe3 compiler: allow to use switch without tag 2020-08-24 19:35:25 +03:00
Evgenii Stratonikov
e58616b975 compiler: drop unused call results
Close #683.
2020-08-24 19:34:51 +03:00
Evgenii Stratonikov
f70cb4f34a compiler: do not use voidCalls when calculating stack size
This was probably a part of some earlier logic.
2020-08-24 19:34:51 +03:00
Roman Khimov
d8badd9a8d
Merge pull request #1351 from nspcc-dev/compiler/jmps
Make use of extended JMP* opcodes
2020-08-24 19:22:24 +03:00
Evgenii Stratonikov
9dc3edf351 compiler: make use of extended JMP* opcodes 2020-08-24 11:19:54 +03:00
Evgenii Stratonikov
51f3baf68e compiler: refactor BinaryExpr handling
Reuse code between if conditions and expression context.
2020-08-24 09:46:11 +03:00
Evgenii Stratonikov
4d04c56efb compiler: make toShortForm accept an opcode 2020-08-24 09:44:44 +03:00
Evgenii Stratonikov
1be1b8de9e compiler: merge && and || processing 2020-08-24 09:44:44 +03:00
Evgenii Stratonikov
59367c96d1 compiler: allow to use += on strings 2020-08-24 09:44:44 +03:00
Evgenii Stratonikov
fd7af77895 compiler: refactor convertToken func
Move `getEqualityOpcode` into `convertToken`.
`convertToken` does not need codegen.
2020-08-24 09:44:44 +03:00
Evgenii Stratonikov
ae88c77a8a compiler: process nil comparisons separately 2020-08-24 09:44:16 +03:00
Roman Khimov
9c72ea1d64 core/interop: add base58 encoding/decoding syscalls
Follow neo-project/neo#1833.
2020-08-23 17:19:56 +03:00
Evgenii Stratonikov
e4af295080 compiler: process constant first in BinaryExpr handling 2020-08-23 12:24:03 +03:00
Evgenii Stratonikov
2b73508561 compiler: emit short jumps while short-circuiting
Unless there is some `ast.Walk` between current instruction and jump
target, we can calculate the offset precisely.
2020-08-21 09:43:05 +03:00
Evgenii Stratonikov
984aba3113 compiler: process last instructin in writeJumps
It is unlikely that we will emit a script with a JMP in the end,
but `writeJumps` must work correctly even in such case.
2020-08-21 09:43:05 +03:00
Evgenii Stratonikov
cfa62e7051 compiler: emit short jumps where possible
Convert long jumps to short ones if the offset
can be represented in a single byte.

Close #805.
2020-08-21 09:43:05 +03:00
Evgenii Stratonikov
681e81420a vm: make (*Context).IP() return instruction pointer
It is misleading to return +1 in code, and user representation
can always be altered.
2020-08-21 08:44:32 +03:00
Evgenii Stratonikov
181569c2a1 compiler: allow to alias interop packages
Fix #397.
2020-08-19 10:13:36 +03:00
Roman Khimov
40bcd4c0bc
Merge pull request #1231 from nspcc-dev/fix/printops
vm: pretty-print remaining opcodes
2020-08-14 14:43:29 +03:00
Evgenii Stratonikov
7854dcfd8f core: replace interop names with named constants 2020-08-14 14:21:54 +03:00
Evgenii Stratonikov
f3650e20b0 vm: move InteropNameToID to a separate package 2020-08-14 13:54:11 +03:00
Anna Shaleva
9456f729be compiler: generate methods names with lowercased first letter
Methods names from debuginfo should match methods names from manifest.
Original method names are stored in ID field.
2020-08-13 13:28:20 +03:00
Anna Shaleva
3c170271c4 compiler: provide namespace for events names
For proper NEO3 debugger work we should provide namespaces for events
names in .debug.json files. But we don't have namespaces in .yml
configuration files and don't need this information for .manifest.json
generation, so let's just keep namespaces empty. This do not prevents
debugger from accepting our .debug.json files.
2020-08-13 10:44:46 +03:00