Evgenii Stratonikov
b2a3a0851e
emit: accept multiple opcodes in Opcode()
2020-10-06 18:03:25 +03:00
Evgenii Stratonikov
5f3b8c6d51
compiler: allow variables in byte-slice literals
2020-09-24 20:20:34 +03:00
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
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
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
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
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
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
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
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
181569c2a1
compiler: allow to alias interop packages
...
Fix #397 .
2020-08-19 10:13:36 +03:00
Evgenii Stratonikov
7854dcfd8f
core: replace interop names with named constants
2020-08-14 14:21:54 +03:00
Evgenii Stratonikov
553e57c2c4
compiler: make sequence points on global var/const declarations
2020-08-11 11:12:30 +03:00
Evgenii Stratonikov
40fa7c0f6e
compiler: emit all used files in DebugInfo.Documents
2020-08-11 11:12:29 +03:00
Roman Khimov
e1d3223505
Merge pull request #1247 from nspcc-dev/feature/pointers
...
Support pointers in compiler
2020-08-06 13:53:08 +03:00
Evgenii Stratonikov
f2107bfbc4
compiler: copy structs when passing as arguments
...
In Go structs must be copied when used as arguments.
To do so we must clone struct on VM level.
This is done by appending this struct to an intermediate array.
2020-08-05 13:14:38 +03:00
Evgenii Stratonikov
4488f61777
compiler: compile init
even if there are no globals
...
`init` can be useful even if no globals are present,
e.g. we can use some syscall inside.
2020-08-05 12:59:53 +03:00
Evgenii Stratonikov
6f2759be3a
compiler: process packages in deterministic order
2020-08-05 11:00:25 +03:00
Evgenii Stratonikov
b771d2d024
compiler: allow to use init
function
...
Process `init()` functions after global variables has been processed.
It's body is saved into the `_initialize` method where all
initialization is performed.
2020-08-05 11:00:25 +03:00
Evgenii Stratonikov
d54c60ded3
compiler: support pointer dereferencing for structs
...
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-08-04 11:14:07 +03:00
Evgenii Stratonikov
eb047b12a7
compiler: support creating pointers to struct
...
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-08-04 11:14:07 +03:00
Evgenii Stratonikov
a781d299e0
compiler: use fully-qualified names for tracking functions
...
Function name now consists of 3 parts:
1) full package path
2) method receiver type (if any)
3) function name itself .
Fix #1150 .
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-31 12:07:06 +03:00
Evgenii Stratonikov
528c184f00
compiler: allow to use exported constants
...
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-31 12:06:42 +03:00
Evgenii Stratonikov
6df019913d
compiler: allow to use exported variables
...
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-31 12:06:42 +03:00
Evgenii Stratonikov
b8d7e93459
compiler: make ForEachFile
accept a package
...
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-31 12:06:42 +03:00
Evgenii Stratonikov
7009417325
compiler: allow to declare global variables in multiple files
...
Traverse and count globals across all used files.
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-31 12:06:42 +03:00
Evgenii Stratonikov
685d44dbc1
*: support _initialize
method in contracts
...
Invoke `_initialize` method on every call if present.
In NEO3 there is no entrypoint and methods are invoked by offset,
thus `Main` function is no longer required.
We still have special `Main` method in tests to simplify them.
2020-07-27 13:00:35 +03:00