473 Commits

Author SHA1 Message Date
Hans Svensson
be7c0e1bd4 Remove escript aesophia 2019-05-21 09:54:42 +02:00
Ulf Norell
8eaafa736c
Merge pull request #69 from aeternity/PT-162578475-stateful
Check stateful annotations
2019-05-15 15:44:37 +02:00
Ulf Norell
9e555a3121 Fix type definition 2019-05-14 09:42:27 +02:00
Ulf Norell
d051fa6c89 Remove bad code 2019-05-14 09:42:17 +02:00
Ulf Norell
389072fb12 Add stateful to __call 2019-05-14 09:32:52 +02:00
Tobias Lindahl
1760593170 Keep the contract type in fate code 2019-05-14 09:29:52 +02:00
Ulf Norell
74d4048d9f Check that init doesn't read or write the state 2019-05-13 17:51:47 +02:00
Ulf Norell
6bd2b7c483 Remember source location when computing used names 2019-05-13 17:50:34 +02:00
Ulf Norell
5aed8b3ef5 Check stateful annotations
Functions must be annotated as `stateful` in order to
- Update the contract state (using `put`)
- Call `Chain.spend` or other primitive functions that cost tokens
- Call an Oracle or AENS function that requires a signature
- Make a remote call with a non-zero value
- Construct a lambda calling a stateful function

It does not need to be stateful to
- Read the contract state
- Call another contract with value=0, even when the remote function is stateful
2019-05-13 13:39:17 +02:00
Ulf Norell
e1a798aef4 Check for repeated argument names to functions
(PT-159592825)
2019-05-10 15:51:42 +02:00
Ulf Norell
23cc8e1132
Letrec and letfun (#65)
* Type check and compile letfuns

* Minor code simplification

* Remove let rec from Sophia
2019-05-10 13:27:57 +02:00
Tobias Lindahl
8830095c7e Add call value instruction in fate 2019-05-10 12:38:58 +02:00
Tobias Lindahl
251b876495
Add value and gas to remote calls (#64)
* Add value and gas to remote calls
2019-05-10 09:00:36 +02:00
Hans Svensson
192ec207a7 Add Contract.creator and address checking primitives 2019-05-09 09:54:04 +02:00
Ulf Norell
0aa1c89556
Fate compiler (#62)
* Update to changes in icode format

* Start on new intermediate code for FATE

* Compile `let` to FATE

* Fix and improve broken bytecode optimisations

* Basic tuple patterns

* Compile shallow matching on tuples

* Liveness analysis for local variables

* Fix minor bug

* Use RETURNR when possible

* Nicer debug printing

* Refactor optimization rules

* Compile tuple construction

* Improve instruction analysis and generalize some optimizations

* Compile nested pattern matching to case trees

(Only tuple and variable patterns so far)

* Reannotate and repeat optimization pass once it done

Could try hard to keep annotations more precise, but would be more error prone

* Get rid of unnecessary STORE instructions

* Keep better track of liveness annotations when swapping instructions

* Limit the number of iterations for the optimization loop

Should finish in one iteration, but we shouldn't loop if there are bugs
or corner cases where it doesn't.

* Pattern matching on booleans

* wip: rewrite case tree compiler to handle catch-alls

still with debug printing, and can't compile it yet

* Add missing case in renaming

* Compile case trees all the way to Fate assembly

* Simplify variables bindings in environment

* Shortcut let x = y in ...

* compile list literals

* Fix various bugs in pattern match compilation

* Pretty printer for fcode

* Fix renaming bug

* Another renaming bug

* Handle switch_body in optimizations

* Remove optimization for if-then-else

* Tag instructions in annotated scode

* Remove 'if' from fcode

* Fix dialyzer things

* Remove unused argument

* Compile pattern matching on integer literals

* Compile list patterns

* Use op_view in more places

* allow leaving out fields from record patterns

* compile records (patterns and construction)

* Compile record update

* Use SETELEMENT instruction

* Compile variants

* Remove incorrect push for tuple switches

* Optimize matching on single constructors datatypes

* Use the fact that SWITCH and JUMPIF can use args and vars

* string literals and pattern matching on the same

* Compile character literals

* Minor refactoring of op instruction handling

* compile address literals

* Get rid of unit in AST

* Unary operators

* Compile function calls

(to fully saturated top-level functions only)

* fix breakage after unary operators

* variables are now lists of names in fcode

* pretty printing for function calls

* use STORE ?a instead of PUSH during optimizations

* no-op fcode optimization pass

* some constant propagation optimizations

* Case on constructor optimization

* fix minor bugs

* Compile all the operators

* Compile maps

* Simplify JUMPIF on true/false

* Fixed left-over reference to STR_EQ

* Add compile-time evaluation for more operators

* Distinguish local vars and top-level names already in fcode

* Compile builtins

* Compile bytes(N)

Compile to FATE strings for now

* Improve inlining of PUSH

* Fix name resolution bug

* Change map_get/set to operators in fcode

* Compile lambdas and higher-order functions

* Optimize single variable closure envs

* Handle unapplied builtins and top-level functions

* Missing case in fcode pretty printer

* Fix variable binding bug in fcode compiler

* Compiler side of state updates

No support in FATE yet though

* Compile statements

* Compile events

But no FATE support for events yet

* Compile remote calls

* Clearer distinction between applied and unapplied top-level things (def/builtin) in fcode

* Tag for literals in fcode to make code cleaner

* We now have block hash at height in FATE

* Update aebytecode commit

* Get rid of catchall todos

* Jump some hoops to please Dialyzer
2019-05-07 15:48:47 +02:00
Ulf Norell
8a381e5ef1 Support equality on bytes(N) 2019-04-25 16:06:50 +02:00
Hans Svensson
45a62f0807 Simplify ast_typerep 2019-04-24 08:44:05 +02:00
Hans Svensson
3255c62e0e Revert bytes(N) from icode/vm-types 2019-04-23 17:47:50 +02:00
Hans Svensson
5e6af18c7b Address review comment 2019-04-23 11:10:56 +02:00
Hans Svensson
4324bfd49e Add bytes(int), add address_literalsm add ecverify_secp25k1
hash -> bytes(32)
signature -> bytes(64)
address literals
2019-04-23 10:40:02 +02:00
Hans Svensson
330d8929fd Preparing v2.1.0 2019-04-11 13:42:41 +02:00
Hans Svensson
db64978d2e Add Auth.tx_hash 2019-04-08 11:57:07 +02:00
Robert Virding
4a01c852c9 Add more test cases
And some trivial code cleanup.
2019-04-03 22:58:54 +02:00
Robert Virding
df00c3958b First version of final aci
Should have more test cases and code cleanup
2019-04-03 17:53:16 +02:00
Robert Virding
12cb37245b First version of new aci generator
We also include some updated simple tests which are only run by eunit.
2019-04-03 17:53:16 +02:00
Robert Virding
549a0c2201 Move TYPEREP definitions to aebytecode 2019-04-02 16:03:50 +02:00
Robert Virding
9f5f8d4444 Change function references from aeso_sophia to aeb_aevm_data 2019-04-02 16:00:10 +02:00
Robert Virding
fd0dbdf207 Change references from aeso_memory to aeb_memory 2019-04-02 15:59:12 +02:00
Robert Virding
0d8b7c7c79 First commit fixinng references from aeso_ to aeb_
Also remove local copies of modules moved to aebytecode.
2019-04-02 15:59:12 +02:00
Hans Svensson
15ca37342c Remove aeso_blake2, use eblake2 2019-04-02 09:00:20 +02:00
Luca Favatella
d89fd134b5 Fix build warning
Symptom:
```
src/aeso_aci.erl:18: Warning: record namespace is unused
```
2019-03-29 15:25:21 +00:00
Luca Favatella
37dfbf78ac
Remove fragile file-based versioning (#46) 2019-03-15 10:12:41 +00:00
Hans Svensson
4d61ee65df
Merge pull request #43 from aeternity/add_decode_calldata
add aeso_compiler:decode_calldata/3
2019-03-14 09:42:27 +01:00
Hans Svensson
a089af555f More better type specs 2019-03-13 19:57:27 +01:00
Hans Svensson
cd116b23d7 add aeso_compiler:decode_calldata/3 2019-03-13 16:15:48 +01:00
Erik Stenman
ad34363673
Merge branch 'fortuna' into merge_master_to_fortuna 2019-03-05 14:35:10 +01:00
Erik Stenman
7ae4a98360 Use latest aebytecode. (#36)
* Use latest aebytecode.

* Fix argument to dup instruction.
2019-03-05 14:27:01 +01:00
Erik Stenman
8cfa611b20 Use right name for inc/1. Remove dead code. 2019-03-05 14:24:46 +01:00
Ulf Norell
f07a49c91d Skeleton for Fate backend 2019-03-05 14:23:19 +01:00
Erik Stenman
85a014958d
Use latest aebytecode. (#36)
* Use latest aebytecode.

* Fix argument to dup instruction.
2019-03-04 14:22:36 +01:00
Hans Svensson
f266c5eed8 Add a VERSION file at the top level and go from there 2019-03-04 12:17:54 +01:00
Ulf Norell
3efde2a2a1 handle hash literals when permissive_address_literals 2019-03-01 11:36:28 +01:00
Ulf Norell
edc37bcf1b add case for signature literals to pretty printer 2019-03-01 11:08:28 +01:00
Ulf Norell
20f2a05638 fix problem with indent detection when inserting the __call function 2019-03-01 11:08:14 +01:00
Ulf Norell
c2a5ed28cf please dialyzer 2019-03-01 11:07:46 +01:00
Ulf Norell
56f70fea6c test oracle calldata fixes 2019-03-01 09:36:43 +01:00
Ulf Norell
9e908369ec check create_calldata contract without the __call function first 2019-03-01 09:21:56 +01:00
Ulf Norell
9984679a24 better handling of permissive_literals
...that doesn't make the compiler crash
2019-03-01 09:02:55 +01:00
Robert Virding
0d56130baa Use correct parse error formats 2019-02-28 16:13:57 +01:00
Robert Virding
7448da16bb Make dialyzer happy and keep it quiet 2019-02-28 16:13:57 +01:00