Evgenii Stratonikov
40bacc6775
compiler: support variable shadowing
...
Closes #1131 .
2020-06-30 10:31:52 +03:00
Evgenii Stratonikov
1ee4acbdbc
compiler: manage variables in a separate varScope struct
...
Abstract var scope management from the funcScope.
2020-06-30 10:31:51 +03:00
Roman Khimov
372dd71708
Merge pull request #1108 from nspcc-dev/neo3/compiler/nef
...
compiler: support *.nef and *.manifest.json generation
2020-06-29 20:55:47 +03:00
Anna Shaleva
dc5da4f37e
compiler: fix unhandled error
2020-06-29 20:44:03 +03:00
Anna Shaleva
66b6a27b09
compiler: fix DebugInfo JSON marshalling
...
MethodDebugInfo.Parameters should be marshalled as `params`
MethodDebugInfo.ReturnType --> `return`
EventDebugInfo.Parameters --> `params`
(see https://github.com/ngdseattle/design-notes/blob/master/NDX-DN11%20-%20NEO%20Debug%20Info%20Specification.md#v11-format )
2020-06-29 20:42:03 +03:00
Anna Shaleva
45213dda49
compiler: remove unnecessary structures
2020-06-29 09:15:29 +03:00
Anna Shaleva
2f6065f541
compiler, cli: introduce *.manifest.json
...
Add ability to generate NEO3-compatable *.manifest.json into compiler.
This file represets contract manifest and includes ABI information, so
we don't need to create separate *.abi.json file. NEO3 debugger also
needs *.manifest.json only. So, switched from *.abi.json to
*.manifest.json file.
2020-06-29 09:15:29 +03:00
Anna Shaleva
c7746da023
cli, compiler: switch from .avm to .nef
...
We don't generate clear .avm instructions anymore. Instead, use .nef
files with additional metadata.
2020-06-29 09:15:29 +03:00
Evgenii Stratonikov
057e1e2806
compiler: support ...
variadic calls
2020-06-27 10:42:30 +03:00
Evgenii Stratonikov
a88ac44147
compiler: support variadic function definitions
...
Pack variadic arguments into a slice. This currently doen't work with
byte slices though.
2020-06-26 20:05:10 +03:00
Evgenii Stratonikov
c57d4cfff2
compiler: count current amount of locals correctly
2020-06-26 20:05:10 +03:00
Roman Khimov
9ca87855a6
Merge pull request #1101 from nspcc-dev/feature/convert
...
Support type conversions
2020-06-25 18:30:03 +03:00
Evgenii Stratonikov
6ddaed3927
compiler: allow to omit struct field names in literals
2020-06-24 19:33:58 +03:00
Evgenii Stratonikov
5a615d8178
compiler: allow to omit types for nested slices
2020-06-24 19:25:08 +03:00
Evgenii Stratonikov
2c5ab95b8a
compiler: convert to ByteArray for string variables
...
Convert to ByteArray when converting variable to `string`, because
underlying byte-slice changes should not affect result string.
2020-06-24 18:59:36 +03:00
Evgenii Stratonikov
1d275ceb65
compiler: distinguish between type conversions and function calls
...
RN every identifier in call expression is considered to be lambda.
But it also can be type expression, so we need to distinguish between
these cases.
2020-06-24 18:46:32 +03:00
Roman Khimov
53f2e130c0
Merge pull request #1100 from nspcc-dev/neo3/compiler/dbgjson
...
compiler: update debug.json format
2020-06-24 18:35:08 +03:00
Evgenii Stratonikov
904b2136fc
compiler: emit CONVERT opcode for type assertions
...
Emit CONVERT for converting between different types. NeoVM behavior is
different from that of Go (e.g. assertions of `int` and `uint32` are
equivalent).
2020-06-24 18:00:26 +03:00
Anna Shaleva
6cc3d9bcc3
compiler: remove entrypoint from debug info
...
part of #1088
2020-06-24 16:50:56 +03:00
Anna Shaleva
4d07d72677
compiler: add Hash to debug info
...
part of #1088
2020-06-24 16:50:34 +03:00
Roman Khimov
954c8ff8d6
compiler: support nil checks
2020-06-24 10:43:58 +03:00
Evgenii Stratonikov
e54149d547
compiler: do not load map key twice in for-range loop
2020-06-22 13:43:59 +03:00
Evgenii Stratonikov
1847c28b42
compiler: do not load values which will be dropped
2020-06-22 13:43:59 +03:00
Evgenii Stratonikov
72be5412f4
compiler: optimize argument reversing
...
Do not reverse arguments if there is no more than 1.
2020-06-22 13:43:59 +03:00
Evgenii Stratonikov
3729865860
compiler: reimplement for-range loops without syscalls
...
System.Enumerator.Next costs 1_000_000 gas which is rather big for a
single iteration. Reimplement this by saving current counters on stack.
This approach will use 2 PICKITEMS (270_000 gas) for maps, which is
still cheaper that *.Next syscall.
2020-06-22 13:43:58 +03:00
Roman Khimov
b483c38593
block/transaction: add network magic into the hash
...
We make it explicit in the appropriate Block/Transaction structures, not via a
singleton as C# node does. I think this approach has a bit more potential and
allows better packages reuse for different purposes.
2020-06-18 12:39:50 +03:00
Roman Khimov
5f276de003
Merge pull request #1057 from nspcc-dev/fix/newaddress
...
Update addresses to NEO3 format
2020-06-17 16:25:32 +03:00
Evgenii Stratonikov
7b4ca57e33
*: change address to the new format
...
NEO3 uses new prefix for address (53 = 0x35), thus string representations as
well as encrypted WIFs should be changed.
2020-06-17 15:58:21 +03:00
Evgenii Stratonikov
61cae8d8b1
compiler: implement missing System.Contract.*
interops
...
Support System.Contract.IsStandard/CreateStandardAccount syscall.
2020-06-17 11:38:34 +03:00
Evgenii Stratonikov
3762ebdd08
core: implement System.Runtime.GetInvocationCounter syscall
2020-06-17 11:24:11 +03:00
Evgenii Stratonikov
75e597f880
core: implement System.Runtime.GetNotifications syscall
2020-06-17 11:24:11 +03:00
Evgenii Stratonikov
afd8f3b87a
compiler: push Null item for nil
values
2020-06-17 11:24:11 +03:00
Evgenii Stratonikov
a4e4439967
core,vm: implement System.Runtime.GasLeft syscall
2020-06-17 11:24:11 +03:00
Evgenii Stratonikov
ad2a75a500
core: move System.ExecutionEngine.* interops to System.Runtime.*
2020-06-16 12:30:55 +03:00
Evgenii Stratonikov
becb8a0f72
compiler: support System.Json.*
syscalls
2020-06-16 11:35:08 +03:00
Evgenii Stratonikov
f2f01a08c9
vm: move MaxArraySize and MaxItemSize to stackitem package
2020-06-16 11:32:16 +03:00
Evgenii Stratonikov
18066143bd
core,vm: adjust binary (de-)serialization syscalls
...
Related #1027 .
1. Move System.Runtime.(De)serialize to System.Binary.*
2. Rename compiler stubs.
3. Adjust opcode prices.
2020-06-16 11:00:38 +03:00
Evgenii Stratonikov
bda94c74c3
vm: check calling flags on syscall invocation
2020-06-11 13:16:07 +03:00
Evgenii Stratonikov
f8a11f61b6
core: update *.Contract.* interops
...
1. Remove GetScript, IsPayable, GetStorageContext.
2. Revert 82319538
related to GetStorageContext.
3. Rename Migrate to Update.
4. Move remaining to System.Contract.*.
Related #1031 .
2020-06-11 10:50:35 +03:00
Evgenii Stratonikov
76a2f62fbd
cli: use manifest during contract deployment
2020-06-11 10:45:25 +03:00
Evgenii Stratonikov
38d020d1a2
core: move Neo.Storage.* interops to System.*
2020-06-10 12:13:35 +03:00
Evgenii Stratonikov
0472a0b0b1
core: move Neo.Runtime/Enumerator/Iterator.* interops to System.*
2020-06-10 12:13:35 +03:00
Evgenii Stratonikov
97c6ac7a73
core: move Neo.Blockchain.* syscalls to System.*
2020-06-10 12:13:18 +03:00
Evgenii Stratonikov
3d3fe9398e
core: remove Neo.Header/Witness/Account.* interops
...
They are not present in NEO3.
2020-06-10 12:13:18 +03:00
Anna Shaleva
8b7abd36c9
core: remove Block.GetTransactions, Block.GetTransactionsCount interops
...
Updated System.Blockchain.GetBlock interop replaced the functionality of
the following interops:
System.Block.GetTransactions
System.Block.GetTransactionCount
Neo.Block.GetTransactions
Neo.Block.GetTransactionsCount
2020-06-09 23:24:11 +03:00
Anna Shaleva
7a2d37cf7e
core: update System.Blockchain.GetBlock interop
...
closes #1025
Now we put on stack stackitem.Array instead of Interop, so we're able to
use all available block properties without extra interop getters.
Removed Neo.Blockchain.GetBlock interop as we don't need it anymore.
2020-06-09 23:24:04 +03:00
Anna Shaleva
e2187c0a96
core: remove Block.GetTransaction interops
...
Removed Neo.Block.GetTransaction and System.Block.GetTransaction
interops. These interops were replaced by new
System.Blockchain.GetTransactionFromBlock interop.
2020-06-09 22:54:21 +03:00
Anna Shaleva
d692de5ea4
core: add System.Blockchain.GetTransactionFromBlock interop
2020-06-09 22:54:16 +03:00
Anna Shaleva
1e63ae4b3f
core: update System.Blockchain.GetTransactionHeight interop
...
Update System.Blockchain.GetTransactionHeight and removed
Neo.Blockchain.GetTransactionHeight interop as we don't need it.
2020-06-09 22:04:18 +03:00
Anna Shaleva
53655c5ac2
core: implement new System.Blockchain.GetTransaction interop
...
closes #1023
Now we put on stack stackitem.Array instead of Interop, so we don't
need old transaction-related interops anymore. Removed the following
interops:
System.Transaction.GetHash
Neo.Transaction.GetAttributes
Neo.Transaction.GetHash
Neo.Transaction.GetWitnesses
Neo.Attribute.GetData
Neo.Attribute.GetUsage
Also removed the following duplicated NEO interop:
Neo.Blockchain.GetTransaction
2020-06-09 22:04:13 +03:00
Evgenii Stratonikov
ed45ff98e3
compiler: process interop together with package
...
Closes #913 .
Provide package info in the funcScope to check if function is defined
insided an interop package. As a good side-effect bytecode for builtins from `util`
is no longer emitted.
Related #941 .
2020-06-09 12:41:33 +03:00
Anna Shaleva
783f5ecb01
vm: move StackItem to a separate package
...
closes #912
2020-06-08 13:27:08 +03:00
Roman Khimov
a986e2a064
*: drop support for old on-chain assets
...
You no longer can transfer them, so creating/renewing/storing doesn't make
much sense.
2020-06-05 19:21:37 +03:00
Roman Khimov
709146f295
transaction: drop Inputs and Outputs, forget UTXO
2020-06-05 19:20:16 +03:00
Roman Khimov
21efccd300
transaction: remove type field, set Version to 0
...
Two changes being done here, because they require a lot of updates to
tests. Now we're back into version 0 and we only have one type of
transaction.
It also removes GetType and GetScript interops, both are obsolete in Neo 3.
2020-06-05 19:20:16 +03:00
Evgenii Stratonikov
f39b51deee
compiler: restore support for GetUnspentCoins
...
Revert a587274
.
2020-05-27 12:01:50 +03:00
Roman Khimov
7e96f82a5b
compiler/interop: add support for working with witnesses
2020-05-27 12:01:50 +03:00
Roman Khimov
e32d0e01af
compiler|transaction: remove transaction.GetUnspentCoins support
...
It's useless. Even though there is Neo.Transaction.GetUnspentCoins syscall
that can be used, its return type is an interop structure that's not accepted
by any other syscall, so you can't really do anything with it. And there is no
such interface for the .net Framework.
2020-05-27 12:01:50 +03:00
Roman Khimov
1cbd75ab9e
compiler|transaction: fix transaction.GetScript build, add to interop
...
There is no such syscall as Neo.Transaction.GetScript and GetScript should be
available for contract's use.
2020-05-27 12:01:50 +03:00
Roman Khimov
559e8a16da
compiler/storage: add read-only related interops
2020-05-27 12:01:50 +03:00
Roman Khimov
6d2b2d7263
compiler/iterator: add missing iterator.Concat function
...
We have a syscall for it, so it should be exposed.
2020-05-27 12:01:50 +03:00
Roman Khimov
4e21e43e72
compiler: add support for enumerator interop package
2020-05-26 20:07:19 +03:00
Roman Khimov
14409addd9
compiler/interop: expose GetTransactionHeight
...
And sort syscall names as they change the indentation anyway.
2020-05-26 19:55:21 +03:00
Roman Khimov
9718891d79
compiler: add support for attribute syscalls
2020-05-26 19:53:28 +03:00
Roman Khimov
6fac273d5d
compiler: add missing asset syscalls, sort them
2020-05-26 19:52:46 +03:00
Roman Khimov
41337732be
compiler: add support for account syscalls
...
Turns out, they never functioned correctly.
2020-05-26 19:52:24 +03:00
Evgenii Stratonikov
f4fa712440
vm: make PUSH0 emit Integer
2020-05-22 14:16:32 +03:00
Evgenii Stratonikov
8cf7871c26
compiler: support nested slice element assignment
2020-05-21 08:30:32 +03:00
Evgenii Stratonikov
5b0e73ddf0
compiler: initialize struct fields explicitly
...
By default VM initializes every field of a new struct to a Boolean.
If field contains another struct, we need to initialize it to default
value explicitly. This commit sets default values for uninitialized
field.
2020-05-21 08:30:32 +03:00
Evgenii Stratonikov
051e3608ff
compiler: support nested struct fielid assignment
2020-05-21 08:30:32 +03:00
Evgenii Stratonikov
1e40f9dac0
compiler: support nested struct reading
2020-05-21 08:30:31 +03:00
Evgenii Stratonikov
1a4a0c154b
compiler: support var-declaration of byte slices
...
Related #801 .
2020-05-20 17:45:56 +03:00
Evgenii Stratonikov
3a4ed7dfe8
compiler: emit Buffer for byte slices
...
All byte slices are mutable so buffer is a right stack item.
2020-05-20 17:45:56 +03:00
Evgenii Stratonikov
b4f1142149
compiler: emit byte constants properly
2020-05-20 17:45:56 +03:00
Evgenii Stratonikov
1b105a9f1d
compiler: allow using OP= with struct fields and slice elements
...
Do it in a generic way, there is no need in restricting to only
variables.
Port of #954 .
2020-05-20 14:14:29 +03:00
Evgenii Stratonikov
fdb217ec81
compiler: process _ as a special variable
...
It is more convenient to drop values inside `emitStoreVar` because this
makes other code has less special cases.
2020-05-20 14:14:29 +03:00
Evgenii Stratonikov
3926456d86
compiler: add test for iterating over map with range
2020-05-20 14:14:29 +03:00
Evgenii Stratonikov
d0735257ce
compiler: support range loops with value variables
...
Closes #958 .
2020-05-20 14:14:29 +03:00
Evgenii Stratonikov
b126056f04
compiler: use iterators in range loops
...
It is simpler than having some counters on stack and will help us to
support maps in future.
2020-05-20 14:14:29 +03:00
Evgenii Stratonikov
34a4c15932
compiler: support byte slice declaration
2020-05-20 11:10:02 +03:00
Evgenii Stratonikov
582469028b
compiler: emit default values in a generic way
2020-05-20 11:10:01 +03:00
Evgenii Stratonikov
2cc58c3c9e
compiler: allow to declare multiple compound types in a var decl
2020-05-19 16:57:02 +03:00
Evgenii Stratonikov
b4bad11699
compiler: count the number of variables correctly
2020-05-19 16:47:43 +03:00
Evgenii Stratonikov
0629479560
compiler: support non-struct methods
...
There is no need to restrict ourselves just to structs.
2020-05-19 16:40:26 +03:00
Evgenii Stratonikov
87f6ba34db
compiler: process index expresstions in a generic way
...
All type errors such as string index in slice will be catched during parse phase.
2020-05-19 16:40:26 +03:00
Evgenii Stratonikov
aeaa4a8210
compiler: process bool literals in a generic way
2020-05-19 16:40:26 +03:00
Evgenii Stratonikov
70d0ff869d
compiler: refactor typeinfo functions
2020-05-19 16:40:26 +03:00
Evgenii Stratonikov
89b5e92b83
compiler: add tests for function literal
...
Add test forgotten in #934 .
2020-05-12 16:23:09 +03:00
Evgenii Stratonikov
e21015233b
compiler: implement shadowing of global variables
...
Before introducing slots it was hard to change global variables
preserving changes across multiple function calls.
This commit implements such possibility.
Closes #638 .
2020-05-12 16:23:09 +03:00
Evgenii Stratonikov
0cb6dc47e4
vm: implement slot-related opcodes
...
1. Slot is a new mechanism for storing variables during execution
which is more convenient than alt.stack. This commit implements
support for slot opcodes in both vm and compiler.
2. Remove old alt.stack opcodes.
3. Do not process globals at the start of every function, but instead
load them single time at main.
2020-05-12 16:23:08 +03:00
Evgenii Stratonikov
75fb3af48f
compiler: add basic support for function literals
...
Implement basic support for function literals.
Nested function literals and variables from closure are not supported for now.
2020-05-12 12:56:52 +03:00
Roman Khimov
b83ee77698
Merge pull request #938 from nspcc-dev/fix/appcall
...
vm: remove APPCALL, TAILCALL
2020-05-08 13:11:02 +03:00
Evgenii Stratonikov
73c82584a3
vm,compiler: replace APPCALL with System.Contract.Call
...
Contract calls are performed via syscall System.Contract.Call
in NEO3. This implements this in compiler and removes APPCALL from the
VM.
2020-05-07 14:52:03 +03:00
Evgenii Stratonikov
7ac15a7557
compiler: support implicit type in function arguments
...
Go supports declaring multiple arguments of the same type without
duplicating type name. Now we support this too.
2020-05-07 11:33:09 +03:00
Evgenii Stratonikov
b0a89e8a1a
compiler: support named returns
2020-05-06 18:22:52 +03:00
Evgenii Stratonikov
156a2eddc5
compiler: support using return
in some branches
...
When `return` is used in one codepath, but not the other,
we do not clean altstack properly. This commit fixes it.
2020-05-06 18:22:52 +03:00
Evgenii Stratonikov
770cff8b91
compiler: allow to use return
with no arguments
2020-05-06 18:22:52 +03:00
Evgenii Stratonikov
d18199ce42
vm: implement REVERSE* opcodes
...
Use new opcodes in the compiler instead of XSWAP/ROLL.
2020-05-06 13:03:49 +03:00
Anna Shaleva
2ec1d76320
compiler: add ability to generate .abi.json file
...
A part of integration with NEO Blockchain Toolkit (see #902 ). To be
able to deploy smart-contract compiled with neo-go compiler via NEO
Express, we have to generate additional .abi.json file. This file
contains the following information:
- hash of the compiled contract
- smart-contract metadata (title, description, version, author,
email, has-storage, has-dynamic-invoke, is-payable)
- smart-contract entry point
- functions
- events
However, this .abi.json file is slightly different from the one,
described in manifest.go, so we have to add auxilaury stractures for
json marshalling. The .abi.json format used by NEO-Express is described
[here](https://github.com/neo-project/neo-devpack-dotnet/blob/master/src/Neo.Compiler.MSIL/FuncExport.cs#L66 ).
2020-05-04 08:37:39 +03:00
Anna Shaleva
ab7f2cb4fb
compiler: fix bug with missing methods parameters
...
Method `methodInfoFromScope(...)` always returned an empty parameters
set, so we were missing this information in both .abi.json and
.debug.json files. Fixed now.
2020-05-04 08:37:39 +03:00