Commit Graph

343 Commits

Author SHA1 Message Date
Alex Beregszaszi
af57879187 Report location on stack too deep if possible 2017-07-26 22:56:55 +01:00
Alex Beregszaszi
8098030986 Use solAssert instead of boost throw where possible 2017-07-26 22:23:21 +01:00
VoR0220
78769f3b39 Change fixed point types to have digit count
Signed-off-by: VoR0220 <rj@erisindustries.com>
2017-07-19 21:49:01 +01:00
chriseth
d58e439094 Fix internal "variable already present" error. 2017-07-04 19:33:55 +02:00
Alex Beregszaszi
677700d5ac Add assert to shift helper 2017-07-02 23:41:22 +01:00
Alex Beregszaszi
d261265595 Use shift helper in LValue 2017-07-02 23:40:51 +01:00
Alex Beregszaszi
68b0ac4fdd More uses of shift helper 2017-07-02 23:40:51 +01:00
Alex Beregszaszi
8fd1d4167d Change shiftNumberOnStack to bits 2017-07-02 23:40:47 +01:00
Alex Beregszaszi
c7ae042114 Use shift helper 2017-07-02 23:37:47 +01:00
Alex Beregszaszi
0494fa98c0 Add shift helper to CompilerUtils 2017-07-02 23:37:47 +01:00
chriseth
71d866cd7a Abort early if there is nothing to encode or decode. 2017-06-30 14:16:16 +02:00
Alex Beregszaszi
6a708b0cfe Document appendFunctionSelector 2017-06-28 18:00:40 +02:00
chriseth
ef9a7b2144 Stack adjustment and code generation for fallback function.
This assumes that the fallback function does not have return parameters.
2017-06-28 18:00:31 +02:00
chriseth
168f64f4cb Fix negative stack size checks. 2017-06-28 16:55:49 +01:00
Alex Beregszaszi
9d201a086c Merge pull request #2459 from ethereum/noComparisonForSomeTypes
No comparison for some types
2017-06-26 22:55:22 +01:00
Alex Beregszaszi
b0ab9aaee0 Merge pull request #2453 from ethereum/memcopyAsForLoop
Use for loop for assembly memcopy.
2017-06-26 22:39:30 +01:00
chriseth
ab15040caa Comment about zero length. 2017-06-26 21:48:17 +01:00
chriseth
f47e6e90fb Disallow comparisons between some types. 2017-06-26 16:30:36 +02:00
Alex Beregszaszi
a0b0df2d98 Merge pull request #2460 from ethereum/disallowMultiModifier
Disallow invoking the same modifier multiple times.
2017-06-26 11:51:12 +01:00
chriseth
d94a12a34c Reformat. 2017-06-26 09:19:11 +02:00
chriseth
0aaa6d876d Use for loop for assembly memcopy. 2017-06-26 09:18:14 +02:00
chriseth
5a75581f66 Disallow invoking the same modifier multiple times. 2017-06-23 20:12:22 +02:00
chriseth
64067975e4 Review suggestions. 2017-06-23 19:29:11 +02:00
chriseth
831ed08387 Change invalid opcode to revert for input validation. 2017-06-23 19:29:11 +02:00
Alex Beregszaszi
f9144ae5a4 Merge pull request #2444 from ethereum/parser-scanner
Avoid including Scanner.h in ParserBase.h
2017-06-23 00:14:18 +01:00
Alex Beregszaszi
007ffe9430 Avoid including Scanner.h in ParserBase.h 2017-06-22 22:22:19 +01:00
chriseth
83ea7793d9 Fix ABI encoding of empty string literal. 2017-06-22 17:55:06 +02:00
Alex Beregszaszi
d5f8ce90c7 Merge interface/Exceptions and interface/Utils 2017-06-22 11:25:07 +01:00
Alex Beregszaszi
c08c4b8b6f Move subroutine helpers from CompilerContext to Assembly 2017-06-14 21:21:26 +01:00
Alex Beregszaszi
398099f50e Remove obsolete errorTag() 2017-06-14 21:21:26 +01:00
Alex Beregszaszi
ae6251effd Use inline assembly directly and not via AsmStack 2017-06-09 11:43:40 +01:00
chriseth
ef3d5874fe Remove error reporter from code generation phase. 2017-06-08 15:52:45 +02:00
chriseth
97cc968a13 Initial EVM1.5 assembly implementation. 2017-06-08 15:52:44 +02:00
chriseth
d4a57d81ba Merge pull request #2317 from ethereum/keccak256
Use keccak256 in tests and replace the SHA3 instruction in assembly
2017-05-30 19:34:28 +02:00
Rhett Aultman
89b60ffbd4 Refactor error reporting
This commit introduces ErrorReporter, a utility class which consolidates
all of the error logging functionality into a common set of functions.
It also replaces all direct interactions with an ErrorList with calls to
an ErrorReporter.

This commit resolves issue #2209
2017-05-30 07:28:31 -07:00
Alex Beregszaszi
0c8beac357 Rename the SHA3 assembly instruction to KECCAK256 2017-05-30 10:54:29 +01:00
chriseth
261731f7ee Adapt EVM codegen to new namespace. 2017-05-26 15:08:27 +02:00
chriseth
8eead553af Merge pull request #1810 from ethereum/compactJson
Compact format for AST-Json.
2017-05-22 14:33:46 +02:00
chriseth
e2b21e1c96 Refactor to abstract assembly to JULIA. 2017-05-19 19:20:28 +02:00
djudjuu
1d22233a43 refactoring functionCallAnnotation 2017-05-19 15:48:07 +02:00
chriseth
28f10f4783 Remove error label / invalid jump label. 2017-04-28 13:14:52 +02:00
chriseth
f3ec2ba39e Refactor to combined scope and stack height info. 2017-04-26 17:12:04 +02:00
chriseth
e841b23bfd Special case for storage types with offset zero. 2017-04-25 16:49:04 +02:00
chriseth
978884d9ca Build fix. 2017-04-25 16:49:04 +02:00
chriseth
478f2997ea Storage access from inline assembly. 2017-04-25 16:49:04 +02:00
chriseth
dfb7d5ebd9 Move analysis out of code generator. 2017-04-25 16:49:04 +02:00
chriseth
dfaab73efe Only allow access to local variables and only if they have a stack size of one. 2017-04-25 16:49:04 +02:00
chriseth
34717838da Review comments. 2017-04-25 16:49:03 +02:00
chriseth
83bf34c571 Review comments and cleanup. 2017-04-25 16:49:03 +02:00
chriseth
e0849f2f3b Split external identifier access into resolving and code generation. 2017-04-25 16:49:03 +02:00
Alex Beregszaszi
3ae88377d6 Change references to FunctionType::Location 2017-03-16 12:49:52 +00:00
chriseth
47cd8964b8 Require and Assert. 2017-03-14 14:21:33 +01:00
Yoichi Hirai
cfbbd89daf Merge pull request #1702 from ethereum/assertError
Change effect of assert to invalid opcode.
2017-03-03 18:25:50 +01:00
chriseth
d2c79bf8e9 Merge pull request #1700 from ethereum/fixNoMobile
Some checks for the existence of mobile type.
2017-02-24 15:50:45 +01:00
Alex Beregszaszi
4d290e551c Disallow setting .gas() on .transfer() 2017-02-24 00:27:36 +00:00
Alex Beregszaszi
c674155e58 Do not keep the gas stipend if sending non-zero value 2017-02-24 00:18:18 +00:00
Alex Beregszaszi
81006dae98 Support gas modifier on addr.transfer() 2017-02-24 00:18:18 +00:00
Alex Beregszaszi
4264625c69 Implement address.transfer() 2017-02-24 00:17:45 +00:00
chriseth
811bb770c5 Change effect of assert to invalid opcode. 2017-02-16 15:54:17 +01:00
chriseth
dcc16c81e2 Some checks for the existence of mobile type. 2017-02-16 11:46:27 +01:00
Alex Beregszaszi
c8ec79548b Use the revert opcode in assert() 2017-02-10 22:53:32 +00:00
Alex Beregszaszi
586d156f33 Use the REVERT opcode for throw; 2017-02-10 22:41:09 +00:00
Alex Beregszaszi
f3158f92d6 Support revert() 2017-02-10 22:40:42 +00:00
Alex Beregszaszi
8a3d4a0500 Cleanup is not needed for assert() 2017-02-10 13:32:36 +00:00
Alex Beregszaszi
f8461e9e31 Implement assert as a global function 2017-02-10 13:29:17 +00:00
Alex Beregszaszi
693226b1ab Rename SUICIDE opcode to SELFDESTRUCT in libevmasm 2017-02-06 20:17:52 +00:00
Alex Beregszaszi
ba0015cf25 Warn early when exhausting stack 2017-02-02 11:39:29 +00:00
Alex Beregszaszi
4361797ddc Only capture function type to address conversion 2017-02-01 12:23:47 +00:00
Alex Beregszaszi
ce62c7c01c Be more verbose on the stack-mismatch errors 2017-02-01 12:23:47 +00:00
Alex Beregszaszi
767ec1d670 Support explicit conversion of external function type to address 2017-02-01 12:23:47 +00:00
chriseth
bff8fc23e6 Changelog and review suggestions. 2017-01-27 10:18:53 +01:00
chriseth
a98fa41897 Uninitialized internal function should call INVALID. 2017-01-26 16:39:07 +01:00
chriseth
d9fbb83861 Allow inserting low-level functions without calling them. 2017-01-26 16:39:07 +01:00
chriseth
390bebaaf9 Split line. 2017-01-26 16:39:07 +01:00
Valentin Wüstholz
5b7cc018f0 Address feedback from code review. 2017-01-26 16:39:07 +01:00
Valentin Wüstholz
9bcbd93ac5 Change translation of implicit throws (issue #1589).
This adds a new invalid instruction that is used for encoding
implicit throws that are emitted by the compiler. This makes it
possible to distinguish such runtime errors from user-provided,
explicit throws.
2017-01-26 16:39:07 +01:00
chriseth
1316bb7565 Warn about invalid checksums of addresses. 2017-01-24 23:37:48 +01:00
chriseth
ead1a3b33f Include creation code only once. 2017-01-24 17:41:31 +01:00
chriseth
7e6f1b3f00 Use int arithmetics for stack adjustment. 2017-01-24 12:07:09 +01:00
chriseth
23eca813f5 Change clearStorageLoop to TypePointer. 2017-01-24 12:07:09 +01:00
chriseth
82a00e7dc5 Use shared_ptrs to enable shared_from_this. 2017-01-24 12:06:41 +01:00
chriseth
cea020b89e Convert ArrayUtils routines into low-level functions. 2017-01-24 12:06:40 +01:00
chriseth
b60623521f Move some util functions to low-level functions. 2017-01-24 12:06:40 +01:00
chriseth
d0e8d340a5 Low level named functions for CompilerContext. 2017-01-24 12:06:40 +01:00
chriseth
2536bdd6d0 Report source location on "stack too deep" errors. 2017-01-20 19:01:19 +01:00
Rhett Aultman
1f30982ab5 Use fully-qualified names for linking, too
Using libraries leaves behind a library link reference in the binary
which the linker must later resolve.  These link references were still
being generated by name and not by fully-qualified name.  This would
lead to a link-time collision between two libraries having the same
name but in different source units.

This change changes linker symbols over to fully-qualified names,
which resolves that issue.  This does potentially introduce a new
problem, which is that linker symbols appear to be limited to 36
characters and are truncated.  Storing paths extends the average
symbol size, and it would be great if truncation was from the tail
rather than the head.
2017-01-16 12:32:57 -05:00
Yoichi Hirai
6a312233fc
ast, codegen: enable accessing events through contract names.
Fixes #1286
2017-01-02 17:59:20 +01:00
Yoichi Hirai
18f8f29c0a Merge pull request #1487 from ethereum/shift-ops
Shift operators
2016-12-14 16:31:27 +01:00
chriseth
e9d3327ad6 Use correct type for storing. 2016-12-13 16:50:50 +01:00
chriseth
0e0d5d47c0 Renamed padToWordBoundaries -> padToWords 2016-12-12 23:43:21 +01:00
chriseth
2738045030 Cleaner shift handling and type conversion for binary operations. 2016-12-12 11:12:12 +01:00
Alex Beregszaszi
b8b4f5e9f9 Support bitshifting in variables 2016-12-12 11:12:10 +01:00
chriseth
bfa4f45116 Split memcopy into three functions. 2016-12-11 17:57:15 +01:00
chriseth
4184525d4a Fix inline assembly. 2016-12-11 17:57:15 +01:00
Alex Beregszaszi
efd7b4bfbb Reset stack height after inline assembly block 2016-12-11 17:57:15 +01:00
Alex Beregszaszi
4a11200a27 Better assert message for appendInlineAssembnly 2016-12-11 17:57:15 +01:00
Alex Beregszaszi
b93589b3b6 Implement identity call in inline assembly 2016-12-11 17:57:15 +01:00
Alex Beregszaszi
bf5dac1fb2 Turn off the identity precompile for testing 2016-12-11 17:57:15 +01:00
Alex Beregszaszi
1bf412d9fd Implement CompilerUtils::memoryCopy using inline assembly 2016-12-11 17:57:15 +01:00
Alex Beregszaszi
4abc8ab5a9 Add usingIdentity option to CompilerUtils::memoryCopy 2016-12-11 17:57:15 +01:00
chriseth
84443eb560 Merge pull request #1351 from ethereum/truncate_bit
Truncate a boolean from calldata into one bit
2016-12-08 16:15:35 +01:00
Alex Beregszaszi
86d54c02cd Throw if calling the identity precompile (memoryCopy) failed 2016-12-02 13:18:39 +00:00
chriseth
6a7ff039df Use CBOR encoding. 2016-12-01 16:03:59 +01:00
chriseth
1e35526eb6 Fix tests. 2016-12-01 16:03:59 +01:00
chriseth
91ecc4533d Add swarm hash to the end of the bytecode. 2016-12-01 16:03:59 +01:00
chriseth
5789eaa78d Metadata stamp. 2016-12-01 16:03:59 +01:00
chriseth
55a719a79c Merge pull request #1462 from ethereum/fix-incorrect-assertion
codegen: assertion did not assert non-nullness
2016-12-01 15:14:31 +01:00
Yoichi Hirai
1e791f30aa
codegen: this commit removes one of duplicate assignments 2016-12-01 12:03:25 +01:00
Yoichi Hirai
e29047b24d
codegen: assertion did not assert non-nullness
This commit strengthens an assertion so that it makes sure that a pointer is not null.
Moreover, `isLocalVariable(variable)` is now positively asserted, following the error message.
2016-12-01 11:58:34 +01:00
Yoichi Hirai
d77c8f730c
codegen: clean not only booleans but all types before storing them into memory 2016-11-30 17:42:21 +01:00
Yoichi Hirai
547deec4be
codegen: clean any data from the input 2016-11-30 17:42:03 +01:00
Yoichi Hirai
fb9babce54
codegen: truncate booleans before they enter storage 2016-11-30 17:41:51 +01:00
Yoichi Hirai
0123e74a2e
codegen: cleanup booleans before storing them into memory 2016-11-30 17:41:46 +01:00
Yoichi Hirai
03ccc6df70
codegen: truncate a boolean calldata down to one bit 2016-11-30 17:41:38 +01:00
Alex Beregszaszi
f1bc979c0f Use solUnimplemented wherever possible 2016-11-28 09:51:02 +00:00
Yoichi Hirai
0be5859503
codegen: cleanup values to fit in storage bytes 2016-11-25 15:50:46 +01:00
Yoichi Hirai
548b7ce42d
codegen: storing of non-value types; add some assertions 2016-11-25 15:45:18 +01:00
Yoichi Hirai
fa486f5b44
codegen: shorten the bit truncation 2016-11-25 15:45:18 +01:00
Yoichi Hirai
9d25b5601e
codegen: merge type conversion and cleaning up 2016-11-25 15:45:18 +01:00
Yoichi Hirai
3fb9625127
codegen: document _chopSignBits parameter of convertType function 2016-11-25 15:45:17 +01:00
Yoichi Hirai
ea628001d5
codegen: add an option to CovertType so that it can truncate sign bits 2016-11-25 15:45:16 +01:00
Yoichi Hirai
56d6641086
codegen: cleanup stored values in a more consistent way 2016-11-25 15:44:36 +01:00
Yoichi Hirai
5b8a773986
codegen: cleanup value types before storing them 2016-11-24 11:31:45 +01:00
VoR0220
3f9f725737 Fix licensing headers
Signed-off-by: VoR0220 <rj@erisindustries.com>
2016-11-23 12:22:33 +01:00
Alex Beregszaszi
910269a29f Add appendCallValueCheck 2016-11-17 17:23:35 +00:00
Alex Beregszaszi
ceeb8f4a2b Add payable check for constructor in codegen 2016-11-17 17:23:35 +00:00
chriseth
2c14a96820 Some more assertions and style changes. 2016-11-16 15:09:01 +01:00
chriseth
ec31d08775 Change encoding to address-funid and add "function" as ABI type. 2016-11-16 14:37:19 +01:00
chriseth
0335ed4cb4 Simple peephole optimizer that is activated even if not requested. 2016-11-16 14:37:19 +01:00
chriseth
e51f852504 Converted sub assembly to smart pointer. 2016-11-16 14:37:18 +01:00
chriseth
e543bd34c0 Stored combined creation and runtime tags.
Includes a change to Assembly to allow tags from sub-assemblies to be
used.

Sorry, this get a bit bigger than I thought.
2016-11-16 14:37:18 +01:00
chriseth
e1df3bd77f Fix tests. 2016-11-16 14:37:18 +01:00
Yoichi Hirai
c9f9b2ab4d codegen: add a compilation mode and a runtime context to CompilerContext 2016-11-16 14:37:18 +01:00
chriseth
47794c1da4 Implement uninitialized storage functions. 2016-11-16 14:37:18 +01:00
chriseth
cc847df3c2 Bugfix in code generator. 2016-11-16 14:37:18 +01:00
chriseth
ff3553a348 Change alignment. 2016-11-16 14:37:18 +01:00
chriseth
95d7555e3c External functions in storage. 2016-11-16 14:37:17 +01:00
chriseth
dd173f83e3 Code generator for function types. 2016-11-16 14:37:17 +01:00
Rhett Aultman
58e75c7a48 Unimplemented features moved to their own exception (#1361)
Unimplemented features moved to their own exception

InternalCompilerError is an exception that really should be reserved for
actual internal errors of the compiler.  Unimplemented features can now
use either solUnimplemented( ) or, if it should be conditional, then
solUnimplementedAssert( ).

* Revert some unimplemented exceptions, add handlers

The jsonCompiler and CommandLineInterface needed handlers for the
new UnimplementedFeatureException, and some cases I had moved on to
the new exception were better treated as real internal compiler
errors.

* Standardize on "Unimplemented feature" message
2016-11-14 20:41:58 +00:00
chriseth
07e4cd6e32 Merge pull request #1372 from ethereum/invalid_enum_as_external_ret
Invalid enum as external ret
2016-11-14 19:46:25 +01:00
Yoichi Hirai
dbcbfafda8
codegen: overflow checking also during conversion from enums 2016-11-14 17:09:53 +01:00
Yoichi Hirai
1ff67b492a
codegen: add a missing break; 2016-11-14 16:14:59 +01:00
Yoichi Hirai
81f5734cbe
codegen: move the enum overflow checking closer to the conversion into enums 2016-11-14 11:11:39 +01:00
Yoichi Hirai
20c2ca3992
ast, codegen: disallow conversion between different enum types 2016-11-11 17:48:03 +01:00
Yoichi Hirai
0a6c937dcb
codegen: shorten the overflow checking when converting into enums 2016-11-11 17:48:03 +01:00
Yoichi Hirai
98dcd883e4
codegen: check the value range after converting something to an enum element 2016-11-11 17:48:03 +01:00
Rhett Aultman
4524ad0870 Add support for do/while loops
This commit adds support for a standard do <statement> while <expr>;
form of statement.  While loops were already being supported; supporting
a do/while loop mostly involves reusing code from while loops but putting
the conditional checking last.
2016-11-10 07:07:25 -08:00
chriseth
9920e88eea Clear all value types prior to storing. 2016-10-31 16:40:30 +01:00
chriseth
e00a4b47c0 Merge pull request #1264 from ethereum/988
State variable under contract's name
2016-10-25 12:50:24 +02:00
chriseth
f25aa0c68b More checks for missing mobile type. 2016-10-24 16:45:25 +02:00