ethereum / solidity

Solidity, the Smart Contract Programming Language
https://soliditylang.org
GNU General Public License v3.0
23.3k stars 5.77k forks source link

[Yul] add types to dialects, but keep a default type #7070

Closed chriseth closed 4 years ago

chriseth commented 5 years ago

Since eWasm has different types, we have to enable the type system in Yul before eWasm can be completed. To make the code better readable, each Yul dialect will have a default type which does not have to be explicitly mentioned. For eWasm this is u64, for EVM it is u256.

The Yul parser, analyzer and printer should all honour types and the analyzer should also check them (#2324).

It is to be discussed whether bool should be introduced as a type in the EVM dialect.

It should also be discussed how dialects deal with types for literals.

bshastry commented 5 years ago

For eWasm this is u64, for EVM it is u265.

@chriseth I think you meant u256

chriseth commented 4 years ago

I think a good step here is to modify the AST right after parsing (or during?) by replacing all empty types by the default type. Likewise, during printing, all default types are replaced by the empty type.

chriseth commented 4 years ago

@mijovic something similar to the VarDeclInitializer should be done to InlineModifier::performInline, line 201. Maybe it could make sense to make "zeroLiteralForType" a virtual function of Dialect.

Please create a new test similar to test/libyul/yulOptimizerTests/fullInliner/multi_return.yul, but with evmTyped as dialect and change one of the return variables of the function to bool.