Anna Shaleva
7126637f73
core: remove Neo.Crypto.CheckMultisigWithECDsaSecp256k1
...
Koblitz RIP.
2021-03-10 21:46:05 +03:00
Anna Shaleva
cdaca7be3e
core: use Neo.Crypto.CheckSig for standard signature verification
2021-03-10 21:45:58 +03:00
Anna Shaleva
4e6c1092b8
core: add Neo.Crypto.CheckSig interop
2021-03-10 19:24:19 +03:00
Anna Shaleva
14ade42101
core: remove System.Binary.[Serialize, Deserialize] syscalls
...
And move their tests to native StdLib.
2021-03-10 19:24:19 +03:00
Anna Shaleva
5c9c168ee5
core: remove System.Binary.[Base64*, Base58*] syscalls
...
And move their tests to native StdLib.
2021-03-10 19:24:19 +03:00
Anna Shaleva
4d2ad4b9e2
core: remove System.Json.[Serialize, Deserialize] interops
...
And move their tests to native StdLib.
2021-03-10 19:24:19 +03:00
Anna Shaleva
f65485b735
core: remove System.Binary.Itoa and System.Binary.Atoi syscalls
...
And move their tests to native StdLib.
2021-03-10 19:24:19 +03:00
Anna Shaleva
2b90d4455f
native: implement StdLib contract
2021-03-10 19:24:19 +03:00
Anna Shaleva
078870fceb
compiler: fix contract.IsStandard syscall test
2021-03-10 19:24:19 +03:00
Evgeniy Stratonikov
100f2db3fb
native: implement CryptoLib contract
2021-03-10 19:24:19 +03:00
Evgeniy Stratonikov
7160675ac1
compiler/interop: improve conversion to bytes interops
...
Allow to convert to both `Buffer` and `ByteString`
and explicitly mention VM types. Rename `ToByteArray` to `ToBytes`
to avoid ambiguity.
2021-03-10 13:38:44 +03:00
Evgeniy Stratonikov
55009153a9
vm/emit: emit Boolean values correctly
...
We should convert both `true` and `false` values.
2021-03-09 13:34:22 +03:00
Evgeniy Stratonikov
fd4174ad31
core/state: remove IsConst
from StorageItem
2021-03-09 11:59:08 +03:00
Evgeniy Stratonikov
7c62df1253
compiler: add tests for syscall handling
2021-03-05 10:17:35 +03:00
Evgeniy Stratonikov
ffd85dd51d
native/policy: remove MaxBlockSize and MaxBlockSystemFee
2021-03-04 16:59:19 +03:00
Evgeniy Stratonikov
7b8533b67c
native/policy: move MaxTransactionsPerBlock to config
2021-03-04 16:59:19 +03:00
Roman Khimov
924de3e090
Merge pull request #1796 from nspcc-dev/compiler/pow
...
Add syscalls for POW and SQRT opcodes
2021-03-04 16:56:15 +03:00
Evgeniy Stratonikov
8f8c7d2839
compiler: fix import alias handling
2021-03-04 14:41:20 +03:00
Evgeniy Stratonikov
d66ce43239
compiler/interop: replace int64
with int
2021-03-04 13:20:43 +03:00
Evgeniy Stratonikov
0b54870bfe
compiler: add missing math routines
...
Add interops for ABS, SIGN, MIN, MAX, WITHIN opcodes
2021-03-04 13:05:33 +03:00
Evgeniy Stratonikov
56fe6574c9
compiler: simplify convert.To*
processing
...
With inlining there is no need for special logic in compiler.
2021-03-04 13:05:33 +03:00
Evgeniy Stratonikov
e754ca62db
compiler: do not emit CONVERT for syscall results
...
When we encounter type assertion CONVERT is emitted.
This isn't needed for SYSCALL (or opcode) results
because value already has needed type.
Problems can arise when result is converted to invalid type
but `neogointernal` package shouldn't be used directly anyway.
2021-03-04 13:05:33 +03:00
Evgeniy Stratonikov
5f4385d3fa
compiler: implement syscalls for POW and SQRT opcodes
2021-03-04 13:05:33 +03:00
Evgeniy Stratonikov
578bbabd1d
compiler: allow to emit opcodes directly
2021-03-04 13:03:05 +03:00
Anna Shaleva
2c81fc8b8e
*: upgrade tests to use T.Cleanup()
2021-03-01 17:08:00 +03:00
Evgeniy Stratonikov
7577bbef22
compiler: copy locals slice during inline
...
Consider function call `f(1, g(2, 3))` when
both `f` and `g` are inlined. If `f` contains some locals,
inlining `g` will replace them with it's another locals map,
because slices in Go reuse storage on `append`.
Thus scope needs to be copied.
2021-03-01 11:48:42 +03:00
Evgeniy Stratonikov
b66b853285
compiler: drop stack after inline
...
Some control-flow statements drop stack items, for example
`return` when it is used inside of `range` loop.
For inlined calls this `return` should drop only portion of stack
which belongs to inlined call.
2021-03-01 11:48:42 +03:00
Roman Khimov
f264996f74
Merge pull request #1777 from nspcc-dev/fix/vote
...
core: fix native method call flags
2021-02-25 18:55:10 +03:00
Evgeniy Stratonikov
4db5ef05f8
core: fix call flags for System.Contract.Call
...
Follow neo-project/neo#2292 .
2021-02-25 18:12:38 +03:00
Evgeniy Stratonikov
cbda20aca3
core: fix native method call flags
...
Replace `WriteStates` with `States`.
Follow neo-project/neo#2339.
Close #1775 .
Related #1725 .
2021-02-25 18:07:33 +03:00
Evgeniy Stratonikov
0a4ff9d3e4
compiler: allow to use inlined functions to init globals
2021-02-25 15:12:16 +03:00
Evgeniy Stratonikov
df5314f286
compiler: refactor syscall handling
...
Close #941 .
2021-02-24 12:51:15 +03:00
Evgeniy Stratonikov
f7b9861c11
compiler: count locals for vararg inline functions
2021-02-24 12:45:47 +03:00
Roman Khimov
abee3b5b05
Merge pull request #1722 from nspcc-dev/fix/nep11
...
smartcontract: add NEP-11 standard check
2021-02-22 22:27:09 +03:00
Anna Shaleva
c82b11eebe
compiler: add CreateMultisigAccount interop
2021-02-19 17:34:23 +03:00
Evgeniy Stratonikov
b38443fe20
smartcontract: add checks for onNEP*Payable methods
...
When they are present in contract, we want them
to have correct signature.
2021-02-19 17:06:07 +03:00
Evgeniy Stratonikov
d89f055697
smartcontract: add checks for parameter names
...
It can be annoying to use parameter names as specified by standard,
so a separate `CheckABI` is supported.
2021-02-19 17:06:07 +03:00
Evgeniy Stratonikov
d16ef53653
compiler: support ellipsis for append of non-byte slices
...
NeoVM lacks opcode for array append, thus some
kind of loop is needed for this.
2021-02-17 17:14:32 +03:00
Evgeniy Stratonikov
fc3b840335
compiler: append bytes >0x80 properly
...
NeoVM encoding for int(0x80) is []byte{0x80, 0x00} and
byte constant can be used both as integer and as an element
of byte-slice. Thus special case needs to be taken in
`append`.
2021-02-17 16:34:34 +03:00
Evgeniy Stratonikov
cf459002f7
compiler: allow to inline global variables
2021-02-15 18:48:33 +03:00
Evgeniy Stratonikov
6e560c6c9f
compiler: allow to inline var arg functions
2021-02-15 18:48:33 +03:00
Evgeniy Stratonikov
339187a56d
compiler: count locals number properly
2021-02-15 18:48:33 +03:00
Evgeniy Stratonikov
57a0377c81
compiler: load nil
directly on inline
2021-02-15 18:48:33 +03:00
Evgeniy Stratonikov
3484025065
compiler: load constants directly on inline
2021-02-15 18:48:33 +03:00
Evgeniy Stratonikov
27e60455c7
compiler: do not introduce excessive locals on inline
...
When function call-site parameter is an identifier,
we may load it directly. Currently it can be also modified,
this will be fixed in a separate commit.
2021-02-15 18:48:33 +03:00
Evgeniy Stratonikov
1ae0d022dd
compiler: support basic inlining
2021-02-15 18:48:33 +03:00
Evgeniy Stratonikov
1f238ce6fd
compiler: do not emit RET twice for nested BlockStmt
...
When function finishes with `*ast.BlockStmt`, last return
in that block should be looked for.
2021-02-15 18:48:33 +03:00
Roman Khimov
754c985424
Merge pull request #1736 from nspcc-dev/preview5-compatibility-fixes
...
core: preview-5 states difference fixes
2021-02-12 23:58:22 +03:00
Anna Shaleva
0f1473897b
core: temp manifest.Extra marshalling fix
...
Manifest.Extra still serialized as JSON message with undefined order
of items, so it affects contract states dumps.
2021-02-12 23:48:30 +03:00
Roman Khimov
ca08a559fa
interop: allow transfer calls to read states
...
Follow-up to #1734 .
2021-02-12 12:56:15 +03:00
Evgeniy Stratonikov
560aff6155
compiler: adjust init/_deploy method offsets during optimization
...
Because `_initialize` and `_deploy` methods encompass multiple
Go functions, their offsets are stored differently and need
special treatment.
2021-02-11 15:59:02 +03:00
Evgeniy Stratonikov
e1d2a5b5b7
state: split ContractBase and UpdateCounter
...
Latter doesn't make sense for native contracts.
2021-02-11 12:24:09 +03:00
Evgeniy Stratonikov
18b7584cb4
compiler/interop: add Manifest to Contract struct
2021-02-08 13:13:11 +03:00
Evgeniy Stratonikov
6cf40749a9
compiler: add tests for native wrappers
2021-02-08 13:13:10 +03:00
Evgeniy Stratonikov
73a75cc27a
compiler: do not convert interop types on assertion
2021-02-08 13:11:39 +03:00
Evgeniy Stratonikov
2f6345f2d9
compiler: add Hash compatibility test
2021-02-08 13:09:41 +03:00
Evgeniy Stratonikov
69c011b3e7
compiler: implement Ledger contract wrapper
2021-02-08 13:09:41 +03:00
Evgeniy Stratonikov
2f26490e59
compiler: implement RoleManagement contract wrapper
2021-02-08 11:44:39 +03:00
Evgeniy Stratonikov
3c237e2a29
compiler: implement NameService contract wrapper
2021-02-08 11:44:39 +03:00
Evgeniy Stratonikov
6e866b622a
compiler: implement NEO contract wrapper
2021-02-08 11:44:39 +03:00
Evgeniy Stratonikov
e5d8c1c985
compiler: allow conversion to types from external packages
2021-02-08 11:02:45 +03:00
Roman Khimov
ac527650eb
native: add Ledger contract, fix #1696
...
But don't change the way we process/store transactions and blocks. Effectively
it's just an interface for smart contracts that replaces old syscalls.
Transaction definition is moved temporarily to runtime package and Block
definition is removed (till we solve #1691 properly).
2021-02-04 13:12:11 +03:00
Evgeniy Stratonikov
c1cc7e6f9d
native: add additional parameters to deploy
...
1. Management contract has 2 overloads of `deploy` method.
2. Normal contracts should have `_deploy` with 2 parameters.
2021-01-29 12:19:08 +03:00
Evgeniy Stratonikov
f0fe03117a
compiler: optimize struct copy a bit
...
POPITEM is cheaper than PUSH + PICKITEM.
2021-01-19 09:46:01 +03:00
Evgeniy Stratonikov
9b1a7021ba
core: add PickN flags to Storage.Find
...
Allow to pick items by index from serialized struct or array.
2021-01-15 21:12:10 +03:00
Evgeniy Stratonikov
44af99fd07
core: add Deserialize flag to Storage.Find
...
Allow to deserialize values being iterated over.
2021-01-15 21:12:10 +03:00
Evgeniy Stratonikov
7fc0c04dba
core: add flags to Storage.Find
...
It can be iterated over keys, values or both.
Prefix can be stripped.
2021-01-15 21:12:08 +03:00
Evgeniy Stratonikov
2130e17f0c
core,vm: remove System.Enumerator.*
interops
...
Map iterator now returns key-value pair, while array/byte-array
iterators work like old enumerators.
Follow neo-project/neo#2190 .
2021-01-15 21:11:32 +03:00
Evgeniy Stratonikov
d04b000748
vm: remove iterator/enumerator Concat API
...
Follow neo-project/neo#2170 .
2021-01-15 21:08:59 +03:00
Evgenii Stratonikov
1c0c331e25
core: update System.Contract.Call
syscall
...
1. Remove `System.Contract.CallEx`.
2. Extend number of parameters.
3. Add return value count to `VM.Context`.
2021-01-14 18:23:36 +03:00
Evgenii Stratonikov
dbe81f9b80
smartcontract: move flags to a separate package
2021-01-14 17:52:09 +03:00
Evgeniy Stratonikov
0b26b46234
state: store NEF instead of script for contract
...
NEFs for native contracts are set statically, thus
field values are taken from the reference implementation.
2021-01-13 15:34:10 +03:00
Roman Khimov
459ad521ab
*: fix misspellings spotted by goreportcard
2020-12-28 17:27:04 +03:00
Roman Khimov
811f38eaed
*: gofmt -s
2020-12-28 17:23:30 +03:00
Roman Khimov
ab12eee346
native: move contract deployment to management contract
...
See neo-project/neo#2119 .
2020-12-14 15:23:46 +03:00
Roman Khimov
fc361213a7
Merge pull request #1608 from nspcc-dev/core/callflags
...
core: adjust call flags
2020-12-11 19:23:15 +03:00
Anna Shaleva
fadbae8997
core: rename call flags
...
Also new States flag is added and ReadOnly flag is adjusted.
2020-12-11 10:34:01 +03:00
Evgenii Stratonikov
4dc5877674
compiler: remove unused code and simplify error handling
...
After cbf26f3
some errors can't occur.
2020-12-10 18:56:08 +03:00
Evgenii Stratonikov
2341ae0c53
compiler: specify safe methods in config
2020-12-10 18:00:43 +03:00
Evgenii Stratonikov
d7194e4da5
compiler: do not check for main package in ConvertToManifest
2020-12-10 17:45:23 +03:00
Evgenii Stratonikov
9fd8577dd9
compiler: use Options
in ConvertToManifest()
2020-12-10 17:43:25 +03:00
Roman Khimov
a3f91ba8c5
Merge pull request #1603 from nspcc-dev/compiler/types
...
compiler: enforce `Hash160` and `Hash256` size in literals
2020-12-10 14:55:03 +03:00
Roman Khimov
f3e64e08d7
Merge pull request #1602 from nspcc-dev/fix/test
...
vmcli/test: run shell after providing input
2020-12-10 14:42:30 +03:00
Evgenii Stratonikov
ff4880249d
compiler: enforce Hash160
and Hash256
size in literals
...
Can be useful to prevent small typos.
2020-12-10 14:11:28 +03:00
Evgenii Stratonikov
37a8550215
compiler: add contract.CallEx
interop
2020-12-10 13:45:10 +03:00
Evgenii Stratonikov
ec58bec803
compiler: fix global constant traversal
...
There can be no global variables, but some global constants.
Introduced in 0b44a430
.
2020-12-10 13:45:10 +03:00
Evgenii Stratonikov
b807fd9e7f
compiler: rename engine.AppCall()
to contract.Call()
2020-12-10 13:45:10 +03:00
Evgenii Stratonikov
c7ce9cd4f6
compiler: defer dir removal right after creation
2020-12-10 13:40:29 +03:00
Roman Khimov
d828096cbf
Merge pull request #1599 from nspcc-dev/compiler/debuginfo
...
compiler: save both VM and smartcontract types
2020-12-09 23:30:59 +03:00
Evgenii Stratonikov
cbf26f315c
compiler: save both VM and smartcontract types
...
VM types are used in debugger, while smartcontract ones are used in
manifest. We can't save only one of them, because conversion in either
side is lossy:
1. VM has `Array` and `Struct` but smartcontract only has `Array`.
2. Smartcontract has `Hash160` etc, which are all `ByteString` or
`Buffer` in VM.
And to spice things a bit more, return type in debugger can be `Void`,
which corresponds to no real stackitem type (as it must exist).
2020-12-09 22:35:22 +03:00
Evgenii Stratonikov
b7e86fa6a3
manifest: add Safe
flag to method descriptor
...
`interop.Contex.AddMethod` sets `Safe` flag for native
contracts. This allows not to forget to change manifest
when changing call flags.
Also fixed invalid `Safe` flags for `Notary` and `Designate` contracts.
2020-12-08 13:27:43 +03:00
Evgenii Stratonikov
573d1d10c0
cli: add tests for contract
command
2020-12-04 11:05:48 +03:00
Roman Khimov
1cf1fe5d74
*: introduce stable contract hashes
...
Follow neo-project/neo#2044 .
2020-11-27 21:47:08 +03:00
Roman Khimov
b92ea2a48a
manifest/compiler: drop hashes from ABI and debug info
...
See neo-project/neo-devpack-dotnet#391 and neo-project/neo#2044 .
2020-11-26 18:30:49 +03:00
Evgenii Stratonikov
75a9a42403
compiler: check emitted event names
...
Check that all `Notify` invocations in source correspond to some event
in manifest.
Helpful for typos such as `transfer` instead of `Transfer`.
2020-11-26 13:49:58 +03:00
Evgenii Stratonikov
25f1db6de0
compiler: check supported standards
...
Check that emitted manifest complies with supported standards.
This can be made a separate flag.
2020-11-26 12:51:39 +03:00
Evgenii Stratonikov
7d91a3a89e
pkg: move internal/ package to the root directory
...
This way we can use it in scripts and cli.
2020-11-24 16:39:56 +03:00
Evgenii Stratonikov
c849176be7
manifest: include contract Name
2020-11-24 11:23:44 +03:00
Evgenii Stratonikov
1869d6d460
core: allow to use state root in header
2020-11-20 17:16:32 +03:00
Roman Khimov
286d9185f4
smartcontract: remove contract features
...
We're featureless now, all contracts have access to storage and payable status
is to be determined via new NEP. Follow neo-project/neo#2060 .
2020-11-13 21:26:23 +03:00
Evgenii Stratonikov
d193e16662
compiler: support System.Binary.Atoi/Itoa
syscalls
2020-11-10 16:15:10 +03:00
Evgenii Stratonikov
01ccaefe2f
compiler: refactor void calls processing
...
Call result is not used only if it occurs inside a `ExprStmt`.
Otherwise (`IfStmt`, `BinExpr`...) it is used.
Fix #1495 .
2020-10-19 10:43:47 +03:00
Roman Khimov
e9a8e957f8
Merge pull request #1488 from nspcc-dev/fix/compiler
...
compiler: fix manifest method offset
2020-10-14 15:12:57 +03:00
Evgenii Stratonikov
1f2d76a1c2
compiler: fix manifest method offset
...
While optimizing jumps, old offsets should be compared
with the method offset before optimization, not with
the constantly changing value.
2020-10-14 15:04:33 +03:00
Anna Shaleva
f8d5c40928
compiler: do not DROP return value with type assertion
...
The same problem as with IF. Example:
```
func foo() interface{} {
...
}
func Main() int{} {
return foo().(int) <--- panic here
}
```
2020-10-13 19:14:44 +03:00
Anna Shaleva
dbce3c9a19
compiler: do not DROP unary expression value inside IF stmt
...
We dropped values from such calls because they where marked as unused
(consequently, were followed by DROP instructions). Example:
if !foo() { <--- panic here
...
}
This commit prevents the following runtime error during script execution:
```
"error encountered at instruction ** (NOT): runtime error: invalid memory address or nil pointer dereference"
```
2020-10-13 19:14:44 +03:00
Evgenii Stratonikov
c4a8770215
compiler: support _deploy
method
2020-10-06 19:12:35 +03:00
Evgenii Stratonikov
6701e8cda0
compiler: allow to use local variables in init()
...
Because body of multiple `init()` functions constitute single
method in contract, we initialize slot with maximum amount of
locals encounterered in any of `init()` functions and clear them
before emitting body of each instance of `init()`.
2020-10-06 19:08:32 +03:00
Evgenii Stratonikov
b2a3a0851e
emit: accept multiple opcodes in Opcode()
2020-10-06 18:03:25 +03:00
Evgenii Stratonikov
fd52dee79f
compiler: process literals in analyzeVoidCalls
...
Function call can occur in the slice or map literal
and its result surely isn't unused.
2020-09-25 15:34:49 +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
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
Anna Shaleva
44aefe76b4
compiler: add events to debuginfo from .yml config
2020-08-12 17:48:03 +03:00
Roman Khimov
c3f7a419a0
Merge pull request #1296 from nspcc-dev/smartcontract/examples
...
examples: update examples
2020-08-11 19:09:13 +03:00
Anna Shaleva
b5494320f9
compiler, cli: support events from .yml config file
...
We currently can't process events in codegen, so we have to provide
them via .yml config file. Do not delete the rest of the code connected
with conversion of MethodDebugInfo.Event into manifest.Event as we have
issue #1038 .
2020-08-11 13:42:06 +03:00
Evgenii Stratonikov
a34ba92d46
compiler: allow to split main package across multiple files
2020-08-11 11:12:55 +03:00
Evgenii Stratonikov
553e57c2c4
compiler: make sequence points on global var/const declarations
2020-08-11 11:12:30 +03:00
Evgenii Stratonikov
128626de5c
compiler: save sequence points for init
function
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
Evgenii Stratonikov
057e1c6e3c
compiler: provide filename to Compile()
2020-08-11 11:10:45 +03:00
Roman Khimov
f5131491b7
Merge pull request #1271 from nspcc-dev/core/call_from_native
...
core: contractCall from native contracts
2020-08-07 21:24:50 +03:00
Anna Shaleva
995053f2eb
core: add VM into interop context
2020-08-07 16:15:24 +03:00
Roman Khimov
0e2784cd2c
always wrap errors when creating new ones with fmt.Errorf()
...
It doesn't really change anything in most of the cases, but it's a useful
habit anyway.
Fix #350 .
2020-08-07 12:21:52 +03:00
Roman Khimov
5ef08f60ae
remove github.com/pkg/errors from dependencies
...
It's not needed any more with Go 1.13 as we have wrapping/unwrapping in base
packages. All errors.Wrap calls are replaced with fmt.Errorf, some strings are
improved along the way.
2020-08-07 12:21:52 +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
439d9ff94d
compiler: initialize packages according to go spec
...
`init()` functions should be called during package initialization,
after global variables were processed.
2020-08-05 11:15:07 +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
Roman Khimov
ef53a45e7a
Merge pull request #1264 from nspcc-dev/smartcontract/manifest/supported_standards
...
smartcontract: add list of supported standards to manifest
2020-08-04 22:17:00 +03:00
Anna Shaleva
66ceaa6b75
smartcontract: add list of supported standards to manifest
...
Closes #1204
2020-08-04 17:29:44 +03:00
Roman Khimov
fa5ff8dd95
Merge pull request #1242 from nspcc-dev/fix/json
...
Implement lossless stackitem to json conversion
2020-08-04 12:59:47 +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
Roman Khimov
00671deb8f
Merge pull request #1241 from nspcc-dev/fix/string
...
Ensure strings are valid UTF-8 where appropriate
2020-08-03 18:10:27 +03:00
Evgenii Stratonikov
b53f0257f5
stackitem: change ByteArray type to ByteString
...
Adjust only string representation.
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-31 16:07:16 +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
ac040a6f22
compiler: remove unused resolveEntryPoint
...
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
f40aba4cd0
vm: convert items to UTF-8 strings
...
Add `stackitem.ToString` for seamless string conversion.
2020-07-30 12:37:31 +03:00
Evgenii Stratonikov
51ae12e4fd
*: move syscall handling out of VM
...
Remove interop-related structures from the `vm` package.
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-29 13:41:08 +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
Evgenii Stratonikov
d2ddf7b7cb
*: support invoking methods by offset
...
Allow to invoke methods by offset:
1. Every invoked contract must have manifest.
2. Check arguments count on invocation.
3. Change AppCall to a regular syscall.
4. Add test suite for `System.Contract.Call`.
2020-07-27 13:00:35 +03:00
Evgenii Stratonikov
e87eba51f9
compiler: emit bytecode for unused exported functions
...
Exported functions should always be present in byte-code.
This will be needed later when arbitrary method calls are allowed.
2020-07-27 13:00:35 +03:00
Evgenii Stratonikov
04bf357fa5
compiler: make DebugInfo.convertToManifest public
...
Allow to generate manifest when using compiler as a library.
2020-07-27 11:08:01 +03:00
Evgenii Stratonikov
a892e3ffa8
manifest: add Offset in method descriptor
2020-07-27 11:08:01 +03:00
Evgenii Stratonikov
e52c39ae7e
manifest: remove EntryPoint from manifest
2020-07-27 11:08:01 +03:00