Commit Graph

217 Commits

Author SHA1 Message Date
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
Yoichi Hirai
5245a3cf74
codegen: refactor common code 2016-10-24 16:34:23 +02:00
Yoichi Hirai
acba7b92e5
codegen: if a member access has been resolved as a variable, follow that
This fixes at least the first example in #988
2016-10-24 16:34:23 +02:00
Yoichi Hirai
7cee39fc17
codegen: skip contract L for L.Foo where Foo is a type
Fixes #1116
2016-10-24 15:30:26 +02:00
Alex Beregszaszi
0e33b63468 Allow warnings for inline assembly block 2016-10-20 13:25:28 +01:00
Alex Beregszaszi
aefb6e5fcf Rename dev::sha3 to dev::keccak256 2016-10-06 14:53:40 +01:00
chriseth
212e016091 Merge pull request #1104 from ethereum/fixmemcosts
Fix memory resize costs during call
2016-09-17 12:30:41 +02:00
chriseth
5a45990458 Access output memory area so that we do not pay for resize during call. 2016-09-17 11:29:54 +02:00
chriseth
727c6fac85 Allow value transfer to library functions. 2016-09-17 11:29:27 +02:00
chriseth
9ca7472089 Provide gas stipend manually for send(0). 2016-09-06 12:37:01 +02:00
chriseth
f687635e47 Merge pull request #665 from axic/feature/accept-ether
BREAKING: Add payable modifier
2016-09-06 12:25:19 +02:00
chriseth
114502f8ad Merge pull request #1006 from ethereum/nenewaccountgas
Do not pay new account gas.
2016-09-06 11:13:31 +02:00
chriseth
9c64edf110 Change function type to include and propagate payable and constant modifier. 2016-09-05 21:28:28 +02:00
Alex Beregszaszi
962531af96 Merged in changes from chriseth/payable 2016-09-05 21:28:28 +02:00
Alex Beregszaszi
a34f2f1a31 Support payable keyword for functions 2016-09-05 21:28:18 +02:00
chriseth
bf3f45c948 Improve error message. 2016-09-05 17:11:23 +02:00
chriseth
69c175fe22 Do not pay new account gas.
If we checked that the target contract exists, we do not have
to pay the "new account gas".
2016-09-05 15:52:44 +02:00
chriseth
4134834ff3 Guard encoding crashes with assertions. 2016-09-01 20:07:14 +02:00
chriseth
4bfe09897e Make fallback function throw by default. 2016-08-30 15:31:50 +02:00
chriseth
b2507e9f10 Merge pull request #839 from chriseth/checkcode
BREAKING: Make function calls throw if target does not have code.
2016-08-17 16:44:15 +02:00
chriseth
d6579a0a5f Merge pull request #888 from chriseth/throwOnDivZero
Throw on division by zero.
2016-08-17 16:43:13 +02:00
chriseth
774bb8ab3b Make function calls throw if target does not have code.
Low-level calls still just execute and will actually report "success".
This allows `x.call.value(y)()` for x being a non-contract account.
2016-08-17 11:30:40 +02:00
chriseth
9c83109549 BREAKING: return only exits current function/modifier 2016-08-17 11:29:31 +02:00
chriseth
e7084d9e16 Throw on division by zero. 2016-08-17 11:27:15 +02:00
chriseth
d5505e21eb Merge pull request #838 from chriseth/ecrecover
Make ecrecover return zero for malformed input.
2016-08-17 11:05:20 +02:00
chriseth
77f4424589 Provide inline assembly to the code generator. (#840)
* Directly usable inline assembly.

* Add missing header.
2016-08-16 16:27:20 +02:00
chriseth
d731225d02 Actually better to return zero on error. 2016-08-16 14:53:01 +02:00