diff --git a/libsolidity/codegen/ir/Common.cpp b/libsolidity/codegen/ir/Common.cpp index 0a445c119..49a6be5e5 100644 --- a/libsolidity/codegen/ir/Common.cpp +++ b/libsolidity/codegen/ir/Common.cpp @@ -135,10 +135,9 @@ string dispenseLocationComment(langutil::SourceLocation const& _location, IRGene { solAssert(_location.sourceName, ""); _context.markSourceUsed(*_location.sourceName); - return AsmPrinter::formatSourceLocationComment( + return "/// " + AsmPrinter::formatSourceLocation( _location, _context.sourceIndices(), - true /* _statement */, _context.soliditySourceProvider() ); } diff --git a/libsolidity/codegen/ir/IRGenerator.cpp b/libsolidity/codegen/ir/IRGenerator.cpp index 30fc149ad..0b314bc9b 100644 --- a/libsolidity/codegen/ir/IRGenerator.cpp +++ b/libsolidity/codegen/ir/IRGenerator.cpp @@ -340,6 +340,7 @@ string IRGenerator::generateFunction(FunctionDefinition const& _function) return m_context.functionCollector().createFunction(functionName, [&]() { m_context.resetLocalVariables(); Whiskers t(R"( + /// @ast-id function () -> { @@ -348,6 +349,7 @@ string IRGenerator::generateFunction(FunctionDefinition const& _function) )"); + t("astID", to_string(_function.id())); t("sourceLocationComment", dispenseLocationComment(_function)); t( "contractSourceLocationComment", @@ -407,6 +409,7 @@ string IRGenerator::generateModifier( return m_context.functionCollector().createFunction(functionName, [&]() { m_context.resetLocalVariables(); Whiskers t(R"( + /// @ast-id function () -> { @@ -437,6 +440,7 @@ string IRGenerator::generateModifier( _modifierInvocation.name().annotation().referencedDeclaration ); solAssert(modifier, ""); + t("astID", to_string(modifier->id())); t("sourceLocationComment", dispenseLocationComment(*modifier)); t( "contractSourceLocationComment", @@ -542,12 +546,14 @@ string IRGenerator::generateGetter(VariableDeclaration const& _varDecl) solAssert(paramTypes.empty(), ""); solUnimplementedAssert(type->sizeOnStack() == 1, ""); return Whiskers(R"( + /// @ast-id function () -> rval { rval := loadimmutable("") } )") + ("astID", to_string(_varDecl.id())) ("sourceLocationComment", dispenseLocationComment(_varDecl)) ( "contractSourceLocationComment", @@ -561,12 +567,14 @@ string IRGenerator::generateGetter(VariableDeclaration const& _varDecl) { solAssert(paramTypes.empty(), ""); return Whiskers(R"( + /// @ast-id function () -> { := () } )") + ("astID", to_string(_varDecl.id())) ("sourceLocationComment", dispenseLocationComment(_varDecl)) ( "contractSourceLocationComment", @@ -683,6 +691,7 @@ string IRGenerator::generateGetter(VariableDeclaration const& _varDecl) } return Whiskers(R"( + /// @ast-id function () -> { @@ -693,6 +702,7 @@ string IRGenerator::generateGetter(VariableDeclaration const& _varDecl) ("params", joinHumanReadable(parameters)) ("retVariables", joinHumanReadable(returnVariables)) ("code", std::move(code)) + ("astID", to_string(_varDecl.id())) ("sourceLocationComment", dispenseLocationComment(_varDecl)) ( "contractSourceLocationComment", @@ -804,7 +814,7 @@ void IRGenerator::generateConstructors(ContractDefinition const& _contract) m_context.resetLocalVariables(); m_context.functionCollector().createFunction(IRNames::constructor(*contract), [&]() { Whiskers t(R"( - + function () { @@ -819,6 +829,10 @@ void IRGenerator::generateConstructors(ContractDefinition const& _contract) for (ASTPointer const& varDecl: contract->constructor()->parameters()) params += m_context.addLocalVariable(*varDecl).stackSlots(); + if (contract->constructor()) + t("astIDComment", "/// @ast-id " + to_string(contract->constructor()->id()) + "\n"); + else + t("astIDComment", ""); t("sourceLocationComment", dispenseLocationComment( contract->constructor() ? dynamic_cast(*contract->constructor()) : diff --git a/libyul/AsmPrinter.cpp b/libyul/AsmPrinter.cpp index 9462bbd5a..6a764ee16 100644 --- a/libyul/AsmPrinter.cpp +++ b/libyul/AsmPrinter.cpp @@ -45,7 +45,7 @@ using namespace solidity::yul; string AsmPrinter::operator()(Literal const& _literal) { - string const locationComment = formatSourceLocationComment(_literal); + string const locationComment = formatDebugData(_literal); switch (_literal.kind) { @@ -65,19 +65,19 @@ string AsmPrinter::operator()(Literal const& _literal) string AsmPrinter::operator()(Identifier const& _identifier) { yulAssert(!_identifier.name.empty(), "Invalid identifier."); - return formatSourceLocationComment(_identifier) + _identifier.name.str(); + return formatDebugData(_identifier) + _identifier.name.str(); } string AsmPrinter::operator()(ExpressionStatement const& _statement) { - string const locationComment = formatSourceLocationComment(_statement); + string const locationComment = formatDebugData(_statement); return locationComment + std::visit(*this, _statement.expression); } string AsmPrinter::operator()(Assignment const& _assignment) { - string const locationComment = formatSourceLocationComment(_assignment); + string const locationComment = formatDebugData(_assignment); yulAssert(_assignment.variableNames.size() >= 1, ""); string variables = (*this)(_assignment.variableNames.front()); @@ -89,7 +89,7 @@ string AsmPrinter::operator()(Assignment const& _assignment) string AsmPrinter::operator()(VariableDeclaration const& _variableDeclaration) { - string out = formatSourceLocationComment(_variableDeclaration); + string out = formatDebugData(_variableDeclaration); out += "let "; out += boost::algorithm::join( @@ -110,7 +110,7 @@ string AsmPrinter::operator()(FunctionDefinition const& _functionDefinition) { yulAssert(!_functionDefinition.name.empty(), "Invalid function name."); - string out = formatSourceLocationComment(_functionDefinition); + string out = formatDebugData(_functionDefinition); out += "function " + _functionDefinition.name.str() + "("; out += boost::algorithm::join( _functionDefinition.parameters | ranges::views::transform( @@ -135,7 +135,7 @@ string AsmPrinter::operator()(FunctionDefinition const& _functionDefinition) string AsmPrinter::operator()(FunctionCall const& _functionCall) { - string const locationComment = formatSourceLocationComment(_functionCall); + string const locationComment = formatDebugData(_functionCall); string const functionName = (*this)(_functionCall.functionName); return locationComment + @@ -150,7 +150,7 @@ string AsmPrinter::operator()(If const& _if) { yulAssert(_if.condition, "Invalid if condition."); - string out = formatSourceLocationComment(_if); + string out = formatDebugData(_if); out += "if " + std::visit(*this, *_if.condition); string body = (*this)(_if.body); @@ -165,7 +165,7 @@ string AsmPrinter::operator()(Switch const& _switch) { yulAssert(_switch.expression, "Invalid expression pointer."); - string out = formatSourceLocationComment(_switch); + string out = formatDebugData(_switch); out += "switch " + std::visit(*this, *_switch.expression); for (auto const& _case: _switch.cases) @@ -182,7 +182,7 @@ string AsmPrinter::operator()(Switch const& _switch) string AsmPrinter::operator()(ForLoop const& _forLoop) { yulAssert(_forLoop.condition, "Invalid for loop condition."); - string const locationComment = formatSourceLocationComment(_forLoop); + string const locationComment = formatDebugData(_forLoop); string pre = (*this)(_forLoop.pre); string condition = std::visit(*this, *_forLoop.condition); @@ -203,23 +203,23 @@ string AsmPrinter::operator()(ForLoop const& _forLoop) string AsmPrinter::operator()(Break const& _break) { - return formatSourceLocationComment(_break) + "break"; + return formatDebugData(_break) + "break"; } string AsmPrinter::operator()(Continue const& _continue) { - return formatSourceLocationComment(_continue) + "continue"; + return formatDebugData(_continue) + "continue"; } // '_leave' and '__leave' is reserved in VisualStudio string AsmPrinter::operator()(Leave const& leave_) { - return formatSourceLocationComment(leave_) + "leave"; + return formatDebugData(leave_) + "leave"; } string AsmPrinter::operator()(Block const& _block) { - string const locationComment = formatSourceLocationComment(_block); + string const locationComment = formatDebugData(_block); if (_block.statements.empty()) return locationComment + "{ }"; @@ -239,7 +239,7 @@ string AsmPrinter::operator()(Block const& _block) string AsmPrinter::formatTypedName(TypedName _variable) { yulAssert(!_variable.name.empty(), "Invalid variable name."); - return formatSourceLocationComment(_variable) + _variable.name.str() + appendTypeName(_variable.type); + return formatDebugData(_variable) + _variable.name.str() + appendTypeName(_variable.type); } string AsmPrinter::appendTypeName(YulString _type, bool _isBoolLiteral) const @@ -258,10 +258,9 @@ string AsmPrinter::appendTypeName(YulString _type, bool _isBoolLiteral) const return ":" + _type.str(); } -string AsmPrinter::formatSourceLocationComment( +string AsmPrinter::formatSourceLocation( SourceLocation const& _location, map const& _nameToSourceIndex, - bool _statement, CharStreamProvider const* _soliditySourceProvider ) { @@ -294,27 +293,38 @@ string AsmPrinter::formatSourceLocationComment( ":" + to_string(_location.end); - return - _statement ? - "/// " + joinHumanReadable(vector{sourceLocation, solidityCodeSnippet}, " ") : - "/** " + joinHumanReadable(vector{sourceLocation, solidityCodeSnippet}, " ") + " */ "; + return joinHumanReadable(vector{sourceLocation, solidityCodeSnippet}, " "); } -string AsmPrinter::formatSourceLocationComment(shared_ptr const& _debugData, bool _statement) +string AsmPrinter::formatDebugData(shared_ptr const& _debugData, bool _statement) { - if ( - !_debugData || - m_lastLocation == _debugData->location || - m_nameToSourceIndex.empty() - ) + if (!_debugData) return ""; - m_lastLocation = _debugData->location; + vector items; + if (auto id = _debugData->astID) + items.emplace_back("@ast-id " + to_string(*id)); - return formatSourceLocationComment( - _debugData->location, - m_nameToSourceIndex, - _statement, - m_soliditySourceProvider - ) + (_statement ? "\n" : ""); + if ( + m_lastLocation != _debugData->location && + !m_nameToSourceIndex.empty() + ) + { + m_lastLocation = _debugData->location; + + items.emplace_back(formatSourceLocation( + _debugData->location, + m_nameToSourceIndex, + m_soliditySourceProvider + )); + } + + string commentBody = joinHumanReadable(items, " "); + if (commentBody.empty()) + return ""; + else + return + _statement ? + "/// " + commentBody + "\n" : + "/** " + commentBody + " */ "; } diff --git a/libyul/AsmPrinter.h b/libyul/AsmPrinter.h index de9e8fe90..3bb683191 100644 --- a/libyul/AsmPrinter.h +++ b/libyul/AsmPrinter.h @@ -80,22 +80,21 @@ public: std::string operator()(Leave const& _continue); std::string operator()(Block const& _block); - static std::string formatSourceLocationComment( + static std::string formatSourceLocation( langutil::SourceLocation const& _location, std::map const& _nameToSourceIndex, - bool _statement, langutil::CharStreamProvider const* m_soliditySourceProvider = nullptr ); private: std::string formatTypedName(TypedName _variable); std::string appendTypeName(YulString _type, bool _isBoolLiteral = false) const; - std::string formatSourceLocationComment(std::shared_ptr const& _debugData, bool _statement); + std::string formatDebugData(std::shared_ptr const& _debugData, bool _statement); template - std::string formatSourceLocationComment(T const& _node) + std::string formatDebugData(T const& _node) { bool isExpression = std::is_constructible::value; - return formatSourceLocationComment(_node.debugData, !isExpression); + return formatDebugData(_node.debugData, !isExpression); } Dialect const* const m_dialect = nullptr; diff --git a/test/cmdlineTests/exp_base_literal/output b/test/cmdlineTests/exp_base_literal/output index 7a7f0647a..c4b71dcac 100644 --- a/test/cmdlineTests/exp_base_literal/output +++ b/test/cmdlineTests/exp_base_literal/output @@ -288,6 +288,7 @@ object "C_81" { power := exp(1, exponent) } + /// @ast-id 80 /// @src 0:96:368 "function f(uint a, uint b, uint c, uint d) public pure returns (uint, int, uint, uint) {..." function fun_f_80(var_a_4, var_b_6, var_c_8, var_d_10) -> var__13, var__15, var__17, var__19 { /// @src 0:160:164 "uint" diff --git a/test/cmdlineTests/name_simplifier/output b/test/cmdlineTests/name_simplifier/output index 703ddc2dc..73c9cc1aa 100644 --- a/test/cmdlineTests/name_simplifier/output +++ b/test/cmdlineTests/name_simplifier/output @@ -105,7 +105,7 @@ object "C_59" { mstore(4, 0x32) revert(0, 0x24) } - /// @src 0:381:623 "function sumArray(S[] memory _s) public returns (uint, string memory) {..." + /// @ast-id 58 @src 0:381:623 "function sumArray(S[] memory _s) public returns (uint, string memory) {..." function fun_sumArray(var_s_mpos) -> var, var_mpos { /// @src 0:346:625 "contract C {..." diff --git a/test/cmdlineTests/revert_strings/output b/test/cmdlineTests/revert_strings/output index df0029e63..718cf0ba9 100644 --- a/test/cmdlineTests/revert_strings/output +++ b/test/cmdlineTests/revert_strings/output @@ -357,6 +357,7 @@ object "C_15" { } + /// @ast-id 14 /// @src 0:93:145 "function f(uint[][] memory, E e) public pure {..." function fun_f_14(var__7_mpos, var_e_10) { diff --git a/test/cmdlineTests/standard_irOptimized_requested/output.json b/test/cmdlineTests/standard_irOptimized_requested/output.json index 696a03573..c636adcc4 100644 --- a/test/cmdlineTests/standard_irOptimized_requested/output.json +++ b/test/cmdlineTests/standard_irOptimized_requested/output.json @@ -68,7 +68,7 @@ object \"C_7\" { { tail := add(headStart, 0) } function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { revert(0, 0) } - /// @src 0:92:119 \"function f() public pure {}\" + /// @ast-id 6 @src 0:92:119 \"function f() public pure {}\" function fun_f_6() { } } diff --git a/test/cmdlineTests/standard_ir_requested/output.json b/test/cmdlineTests/standard_ir_requested/output.json index a056672b9..2c01878f3 100644 --- a/test/cmdlineTests/standard_ir_requested/output.json +++ b/test/cmdlineTests/standard_ir_requested/output.json @@ -98,6 +98,7 @@ object \"C_7\" { revert(0, 0) } + /// @ast-id 6 /// @src 0:92:119 \"function f() public pure {}\" function fun_f_6() { diff --git a/test/cmdlineTests/standard_viair_requested/output.json b/test/cmdlineTests/standard_viair_requested/output.json index 31ab3de5e..9ae88b90c 100644 --- a/test/cmdlineTests/standard_viair_requested/output.json +++ b/test/cmdlineTests/standard_viair_requested/output.json @@ -187,6 +187,7 @@ object \"D_16\" { revert(pos, returndatasize()) } + /// @ast-id 15 /// @src 0:106:144 \"function f() public { C c = new C(); }\" function fun_f_15() { diff --git a/test/cmdlineTests/standard_yul_source_locations/input.json b/test/cmdlineTests/standard_yul_source_locations/input.json new file mode 100644 index 000000000..8ba84239a --- /dev/null +++ b/test/cmdlineTests/standard_yul_source_locations/input.json @@ -0,0 +1,22 @@ +{ + "language": "Solidity", + "sources": + { + "C": + { + "content": "//SPDX-License-Identifier: GPL-2.0\npragma solidity >=0.0;\npragma abicoder v2;\n\ncontract C\n{\n int public constant constVar = 41;\n int immutable immutVar = 42;\n int public stateVar;\n\n constructor(int _init)\n {\n stateVar = _init;\n }\n\n function f() external pure returns (int)\n {\n return constVar + immutVar;\n }\n modifier m()\n {\n stateVar++;\n _;\n }\n function f2() m public returns (int)\n {\n return stateVar + this.f() + immutVar;\n }\n}\n" + }, + "D": + { + "content": "//SPDX-License-Identifier: GPL-2.0\npragma solidity >=0.0;\npragma abicoder v2;\nimport \"C\";\n\ncontract D is C(3)\n{\n constructor(int _init2)\n {\n stateVar += _init2;\n }\n}\n" + } + }, + "settings": + { + "outputSelection": + { + "*": { "*": ["ir", "irOptimized"] } + }, + "optimizer": { "enabled": true } + } +} diff --git a/test/cmdlineTests/yul_source_locations/output.json b/test/cmdlineTests/standard_yul_source_locations/output.json similarity index 62% rename from test/cmdlineTests/yul_source_locations/output.json rename to test/cmdlineTests/standard_yul_source_locations/output.json index 0839fb1f3..485380625 100644 --- a/test/cmdlineTests/yul_source_locations/output.json +++ b/test/cmdlineTests/standard_yul_source_locations/output.json @@ -9,7 +9,7 @@ /// @use-src 0:\"C\" object \"C_54\" { code { - /// @src 0:79:428 \"contract C...\" + /// @src 0:79:435 \"contract C...\" mstore(64, 160) if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } @@ -135,31 +135,32 @@ object \"C_54\" { sstore(slot, update_byte_slice_32_shift_0(sload(slot), prepare_store_t_int256(convertedValue_0))) } - /// @src 0:175:223 \"constructor(int _init)...\" + /// @ast-id 20 + /// @src 0:182:230 \"constructor(int _init)...\" function constructor_C_54(var__init_12) { - /// @src 0:175:223 \"constructor(int _init)...\" + /// @src 0:182:230 \"constructor(int _init)...\" - /// @src 0:147:149 \"42\" + /// @src 0:154:156 \"42\" let expr_7 := 0x2a let _3 := convert_t_rational_42_by_1_to_t_int256(expr_7) mstore(128, _3) - /// @src 0:214:219 \"_init\" + /// @src 0:221:226 \"_init\" let _4 := var__init_12 let expr_16 := _4 - /// @src 0:203:219 \"stateVar = _init\" + /// @src 0:210:226 \"stateVar = _init\" update_storage_value_offset_0t_int256_to_t_int256(0x00, expr_16) let expr_17 := expr_16 } - /// @src 0:79:428 \"contract C...\" + /// @src 0:79:435 \"contract C...\" } /// @use-src 0:\"C\" object \"C_54_deployed\" { code { - /// @src 0:79:428 \"contract C...\" + /// @src 0:79:435 \"contract C...\" mstore(64, 128) if iszero(lt(calldatasize(), 4)) @@ -203,6 +204,18 @@ object \"C_54\" { return(memPos, sub(memEnd, memPos)) } + case 0xa00b982b + { + // constVar() + + if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } + abi_decode_tuple_(4, calldatasize()) + let ret_0 := getter_fun_constVar_5() + let memPos := allocate_unbounded() + let memEnd := abi_encode_tuple_t_int256__to_t_int256__fromStack(memPos , ret_0) + return(memPos, sub(memEnd, memPos)) + } + default {} } if iszero(calldatasize()) { } @@ -267,7 +280,8 @@ object \"C_54\" { } - /// @src 0:152:171 \"int public stateVar\" + /// @ast-id 10 + /// @src 0:159:178 \"int public stateVar\" function getter_fun_stateVar_10() -> ret { let slot := 0 @@ -276,15 +290,7 @@ object \"C_54\" { ret := read_from_storage_split_dynamic_t_int256(slot, offset) } - /// @src 0:79:428 \"contract C...\" - - function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { - revert(0, 0) - } - - function zero_value_for_split_t_int256() -> ret { - ret := 0 - } + /// @src 0:79:435 \"contract C...\" function cleanup_t_rational_41_by_1(value) -> cleaned { cleaned := value @@ -298,13 +304,28 @@ object \"C_54\" { converted := cleanup_t_int256(identity(cleanup_t_rational_41_by_1(value))) } - /// @src 0:93:119 \"int constant constVar = 41\" + /// @src 0:93:126 \"int public constant constVar = 41\" function constant_constVar_5() -> ret { - /// @src 0:117:119 \"41\" + /// @src 0:124:126 \"41\" let expr_4 := 0x29 - let _2 := convert_t_rational_41_by_1_to_t_int256(expr_4) + let _1 := convert_t_rational_41_by_1_to_t_int256(expr_4) - ret := _2 + ret := _1 + } + + /// @ast-id 5 + /// @src 0:93:126 \"int public constant constVar = 41\" + function getter_fun_constVar_5() -> ret_0 { + ret_0 := constant_constVar_5() + } + /// @src 0:79:435 \"contract C...\" + + function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { + revert(0, 0) + } + + function zero_value_for_split_t_int256() -> ret { + ret := 0 } function panic_error_0x11() { @@ -325,26 +346,27 @@ object \"C_54\" { sum := add(x, y) } - /// @src 0:226:302 \"function f() external pure returns (int)...\" + /// @ast-id 30 + /// @src 0:233:309 \"function f() external pure returns (int)...\" function fun_f_30() -> var__23 { - /// @src 0:262:265 \"int\" - let zero_t_int256_1 := zero_value_for_split_t_int256() - var__23 := zero_t_int256_1 + /// @src 0:269:272 \"int\" + let zero_t_int256_2 := zero_value_for_split_t_int256() + var__23 := zero_t_int256_2 - /// @src 0:279:287 \"constVar\" + /// @src 0:286:294 \"constVar\" let expr_25 := constant_constVar_5() - /// @src 0:290:298 \"immutVar\" + /// @src 0:297:305 \"immutVar\" let _3 := loadimmutable(\"8\") let expr_26 := _3 - /// @src 0:279:298 \"constVar + immutVar\" + /// @src 0:286:305 \"constVar + immutVar\" let expr_27 := checked_add_t_int256(expr_25, expr_26) - /// @src 0:272:298 \"return constVar + immutVar\" + /// @src 0:279:305 \"return constVar + immutVar\" var__23 := expr_27 leave } - /// @src 0:79:428 \"contract C...\" + /// @src 0:79:435 \"contract C...\" function shift_right_0_unsigned(value) -> newValue { newValue := @@ -395,20 +417,21 @@ object \"C_54\" { sstore(slot, update_byte_slice_32_shift_0(sload(slot), prepare_store_t_int256(convertedValue_0))) } - /// @src 0:304:341 \"modifier m()...\" + /// @ast-id 37 + /// @src 0:311:348 \"modifier m()...\" function modifier_m_40(var__42) -> _5 { _5 := var__42 - /// @src 0:322:332 \"stateVar++\" + /// @src 0:329:339 \"stateVar++\" let _7 := read_from_storage_split_offset_0_t_int256(0x00) let _6 := increment_t_int256(_7) update_storage_value_offset_0t_int256_to_t_int256(0x00, _6) let expr_33 := _7 - /// @src 0:336:337 \"_\" + /// @src 0:343:344 \"_\" _5 := fun_f2_53_inner(var__42) } - /// @src 0:79:428 \"contract C...\" + /// @src 0:79:435 \"contract C...\" function cleanup_t_uint160(value) -> cleaned { cleaned := and(value, 0xffffffffffffffffffffffffffffffffffffffff) @@ -490,19 +513,19 @@ object \"C_54\" { revert(pos, returndatasize()) } - /// @src 0:343:426 \"function f2() m public returns (int)...\" + /// @src 0:350:433 \"function f2() m public returns (int)...\" function fun_f2_53_inner(_8) -> var__42 { var__42 := _8 - /// @src 0:392:400 \"stateVar\" + /// @src 0:399:407 \"stateVar\" let _9 := read_from_storage_split_offset_0_t_int256(0x00) let expr_44 := _9 - /// @src 0:403:407 \"this\" + /// @src 0:410:414 \"this\" let expr_45_address := address() - /// @src 0:403:409 \"this.f\" + /// @src 0:410:416 \"this.f\" let expr_46_address := convert_t_contract$_C_$54_to_t_address(expr_45_address) let expr_46_functionSelector := 0x26121ff0 - /// @src 0:403:411 \"this.f()\" + /// @src 0:410:418 \"this.f()\" if iszero(extcodesize(expr_46_address)) { revert_error_0cc013b6b3b6beabea4e3a74a6d380f0df81852ca99887912475e1f66b2a2c20() } // storage for arguments and returned data @@ -523,31 +546,32 @@ object \"C_54\" { // decode return parameters from external try-call into retVars expr_47 := abi_decode_tuple_t_int256_fromMemory(_10, add(_10, returndatasize())) } - /// @src 0:392:411 \"stateVar + this.f()\" + /// @src 0:399:418 \"stateVar + this.f()\" let expr_48 := checked_add_t_int256(expr_44, expr_47) - /// @src 0:414:422 \"immutVar\" + /// @src 0:421:429 \"immutVar\" let _13 := loadimmutable(\"8\") let expr_49 := _13 - /// @src 0:392:422 \"stateVar + this.f() + immutVar\" + /// @src 0:399:429 \"stateVar + this.f() + immutVar\" let expr_50 := checked_add_t_int256(expr_48, expr_49) - /// @src 0:385:422 \"return stateVar + this.f() + immutVar\" + /// @src 0:392:429 \"return stateVar + this.f() + immutVar\" var__42 := expr_50 leave } - /// @src 0:79:428 \"contract C...\" + /// @src 0:79:435 \"contract C...\" - /// @src 0:343:426 \"function f2() m public returns (int)...\" + /// @ast-id 53 + /// @src 0:350:433 \"function f2() m public returns (int)...\" function fun_f2_53() -> var__42 { - /// @src 0:375:378 \"int\" + /// @src 0:382:385 \"int\" let zero_t_int256_4 := zero_value_for_split_t_int256() var__42 := zero_t_int256_4 var__42 := modifier_m_40(var__42) } - /// @src 0:79:428 \"contract C...\" + /// @src 0:79:435 \"contract C...\" } @@ -556,6 +580,188 @@ object \"C_54\" { } +","irOptimized":"/*=====================================================* + * WARNING * + * Solidity to Yul compilation is still EXPERIMENTAL * + * It can result in LOSS OF FUNDS or worse * + * !USE AT YOUR OWN RISK! * + *=====================================================*/ + +/// @use-src 0:\"C\" +object \"C_54\" { + code { + { + /// @src 0:79:435 \"contract C...\" + mstore(64, 160) + if callvalue() { revert(0, 0) } + let programSize := datasize(\"C_54\") + let argSize := sub(codesize(), programSize) + let newFreePtr := add(160, and(add(argSize, 31), not(31))) + if or(gt(newFreePtr, sub(shl(64, 1), 1)), lt(newFreePtr, 160)) + { + mstore(/** @src -1:-1:-1 */ 0, /** @src 0:79:435 \"contract C...\" */ shl(224, 0x4e487b71)) + mstore(4, 0x41) + revert(/** @src -1:-1:-1 */ 0, /** @src 0:79:435 \"contract C...\" */ 0x24) + } + mstore(64, newFreePtr) + codecopy(160, programSize, argSize) + if slt(argSize, 32) + { + revert(/** @src -1:-1:-1 */ 0, 0) + } + /// @src 0:79:435 \"contract C...\" + constructor_C(mload(160)) + let _1 := mload(64) + let _2 := datasize(\"C_54_deployed\") + codecopy(_1, dataoffset(\"C_54_deployed\"), _2) + setimmutable(_1, \"8\", mload(128)) + return(_1, _2) + } + /// @ast-id 20 @src 0:182:230 \"constructor(int _init)...\" + function constructor_C(var_init) + { + /// @src 0:154:156 \"42\" + mstore(128, 0x2a) + /// @src 0:79:435 \"contract C...\" + sstore(/** @src 0:210:226 \"stateVar = _init\" */ 0x00, /** @src 0:79:435 \"contract C...\" */ var_init) + } + } + /// @use-src 0:\"C\" + object \"C_54_deployed\" { + code { + { + /// @src 0:79:435 \"contract C...\" + mstore(64, 128) + if iszero(lt(calldatasize(), 4)) + { + let _1 := 0 + switch shr(224, calldataload(_1)) + case 0x26121ff0 { + if callvalue() { revert(_1, _1) } + abi_decode(calldatasize()) + let ret := /** @src 0:286:305 \"constVar + immutVar\" */ checked_add_int256_568(/** @src 0:297:305 \"immutVar\" */ loadimmutable(\"8\")) + /// @src 0:79:435 \"contract C...\" + let memPos := mload(64) + return(memPos, sub(abi_encode_int256(memPos, ret), memPos)) + } + case 0x793816ec { + if callvalue() { revert(_1, _1) } + abi_decode(calldatasize()) + let ret_1 := sload(_1) + let memPos_1 := mload(64) + return(memPos_1, sub(abi_encode_int256(memPos_1, ret_1), memPos_1)) + } + case 0x9942ec6f { + if callvalue() { revert(_1, _1) } + abi_decode(calldatasize()) + let ret_2 := /** @src 0:382:385 \"int\" */ modifier_m() + /// @src 0:79:435 \"contract C...\" + let memPos_2 := mload(64) + return(memPos_2, sub(abi_encode_int256(memPos_2, ret_2), memPos_2)) + } + case 0xa00b982b { + if callvalue() { revert(_1, _1) } + abi_decode(calldatasize()) + let memPos_3 := mload(64) + return(memPos_3, sub(abi_encode_int256_567(memPos_3), memPos_3)) + } + } + revert(0, 0) + } + function abi_decode(dataEnd) + { + if slt(add(dataEnd, not(3)), 0) { revert(0, 0) } + } + function abi_encode_int256_567(headStart) -> tail + { + tail := add(headStart, 32) + mstore(headStart, /** @src 0:124:126 \"41\" */ 0x29) + } + /// @src 0:79:435 \"contract C...\" + function abi_encode_int256(headStart, value0) -> tail + { + tail := add(headStart, 32) + mstore(headStart, value0) + } + function panic_error_0x11() + { + mstore(0, shl(224, 0x4e487b71)) + mstore(4, 0x11) + revert(0, 0x24) + } + function checked_add_int256_568(y) -> sum + { + if and(1, sgt(y, sub(shl(255, 1), 42))) { panic_error_0x11() } + sum := add(/** @src 0:124:126 \"41\" */ 0x29, /** @src 0:79:435 \"contract C...\" */ y) + } + function checked_add_int256(x, y) -> sum + { + let _1 := slt(x, 0) + if and(iszero(_1), sgt(y, sub(sub(shl(255, 1), 1), x))) { panic_error_0x11() } + if and(_1, slt(y, sub(shl(255, 1), x))) { panic_error_0x11() } + sum := add(x, y) + } + /// @ast-id 37 @src 0:311:348 \"modifier m()...\" + function modifier_m() -> _1 + { + /// @src 0:79:435 \"contract C...\" + let _2 := 0 + let _3 := sload(_2) + if eq(_3, sub(shl(255, 1), 1)) { panic_error_0x11() } + let ret := add(_3, 1) + sstore(_2, ret) + /// @src 0:410:418 \"this.f()\" + if iszero(extcodesize(/** @src 0:410:414 \"this\" */ address())) + /// @src 0:410:418 \"this.f()\" + { + /// @src 0:79:435 \"contract C...\" + revert(_2, _2) + } + /// @src 0:410:418 \"this.f()\" + let _4 := /** @src 0:79:435 \"contract C...\" */ mload(64) + /// @src 0:410:418 \"this.f()\" + mstore(_4, /** @src 0:79:435 \"contract C...\" */ shl(228, 0x026121ff)) + /// @src 0:410:418 \"this.f()\" + let _5 := staticcall(gas(), /** @src 0:410:414 \"this\" */ address(), /** @src 0:410:418 \"this.f()\" */ _4, 4, _4, 32) + if iszero(_5) + { + /// @src 0:79:435 \"contract C...\" + let pos := mload(64) + returndatacopy(pos, _2, returndatasize()) + revert(pos, returndatasize()) + } + /// @src 0:410:418 \"this.f()\" + let expr := /** @src 0:79:435 \"contract C...\" */ _2 + /// @src 0:410:418 \"this.f()\" + if _5 + { + /// @src 0:79:435 \"contract C...\" + let newFreePtr := add(_4, and(add(/** @src 0:410:418 \"this.f()\" */ returndatasize(), /** @src 0:79:435 \"contract C...\" */ 31), not(31))) + if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, _4)) + { + mstore(_2, shl(224, 0x4e487b71)) + mstore(/** @src 0:410:418 \"this.f()\" */ 4, /** @src 0:79:435 \"contract C...\" */ 0x41) + revert(_2, 0x24) + } + mstore(64, newFreePtr) + /// @src 0:410:418 \"this.f()\" + expr := abi_decode_int256_fromMemory(_4, add(_4, returndatasize())) + } + /// @src 0:399:418 \"stateVar + this.f()\" + let expr_1 := checked_add_int256(ret, expr) + /// @src 0:343:344 \"_\" + _1 := /** @src 0:399:429 \"stateVar + this.f() + immutVar\" */ checked_add_int256(expr_1, /** @src 0:421:429 \"immutVar\" */ loadimmutable(\"8\")) + } + /// @src 0:79:435 \"contract C...\" + function abi_decode_int256_fromMemory(headStart, dataEnd) -> value0 + { + if slt(sub(dataEnd, headStart), 32) { revert(0, 0) } + value0 := mload(headStart) + } + } + data \".metadata\" hex\"\" + } +} "}},"D":{"D":{"ir":"/*=====================================================* * WARNING * * Solidity to Yul compilation is still EXPERIMENTAL * @@ -731,6 +937,7 @@ object \"D_72\" { sstore(slot, update_byte_slice_32_shift_0(sload(slot), prepare_store_t_int256(convertedValue_0))) } + /// @ast-id 71 /// @src 1:113:164 \"constructor(int _init2)...\" function constructor_D_72(var__init2_63) { /// @src 1:107:108 \"3\" @@ -760,20 +967,21 @@ object \"D_72\" { converted := cleanup_t_int256(identity(cleanup_t_rational_42_by_1(value))) } - /// @src 0:175:223 \"constructor(int _init)...\" + /// @ast-id 20 + /// @src 0:182:230 \"constructor(int _init)...\" function constructor_C_54(var__init_12) { - /// @src 0:175:223 \"constructor(int _init)...\" + /// @src 0:182:230 \"constructor(int _init)...\" - /// @src 0:147:149 \"42\" + /// @src 0:154:156 \"42\" let expr_7 := 0x2a let _6 := convert_t_rational_42_by_1_to_t_int256(expr_7) mstore(128, _6) - /// @src 0:214:219 \"_init\" + /// @src 0:221:226 \"_init\" let _7 := var__init_12 let expr_16 := _7 - /// @src 0:203:219 \"stateVar = _init\" + /// @src 0:210:226 \"stateVar = _init\" update_storage_value_offset_0t_int256_to_t_int256(0x00, expr_16) let expr_17 := expr_16 @@ -828,6 +1036,18 @@ object \"D_72\" { return(memPos, sub(memEnd, memPos)) } + case 0xa00b982b + { + // constVar() + + if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } + abi_decode_tuple_(4, calldatasize()) + let ret_0 := getter_fun_constVar_5() + let memPos := allocate_unbounded() + let memEnd := abi_encode_tuple_t_int256__to_t_int256__fromStack(memPos , ret_0) + return(memPos, sub(memEnd, memPos)) + } + default {} } if iszero(calldatasize()) { } @@ -892,7 +1112,8 @@ object \"D_72\" { } - /// @src 0:152:171 \"int public stateVar\" + /// @ast-id 10 + /// @src 0:159:178 \"int public stateVar\" function getter_fun_stateVar_10() -> ret { let slot := 0 @@ -903,14 +1124,6 @@ object \"D_72\" { } /// @src 1:91:166 \"contract D is C(3)...\" - function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { - revert(0, 0) - } - - function zero_value_for_split_t_int256() -> ret { - ret := 0 - } - function cleanup_t_rational_41_by_1(value) -> cleaned { cleaned := value } @@ -923,13 +1136,28 @@ object \"D_72\" { converted := cleanup_t_int256(identity(cleanup_t_rational_41_by_1(value))) } - /// @src 0:93:119 \"int constant constVar = 41\" + /// @src 0:93:126 \"int public constant constVar = 41\" function constant_constVar_5() -> ret { - /// @src 0:117:119 \"41\" + /// @src 0:124:126 \"41\" let expr_4 := 0x29 - let _2 := convert_t_rational_41_by_1_to_t_int256(expr_4) + let _1 := convert_t_rational_41_by_1_to_t_int256(expr_4) - ret := _2 + ret := _1 + } + + /// @ast-id 5 + /// @src 0:93:126 \"int public constant constVar = 41\" + function getter_fun_constVar_5() -> ret_0 { + ret_0 := constant_constVar_5() + } + /// @src 1:91:166 \"contract D is C(3)...\" + + function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { + revert(0, 0) + } + + function zero_value_for_split_t_int256() -> ret { + ret := 0 } function panic_error_0x11() { @@ -950,21 +1178,22 @@ object \"D_72\" { sum := add(x, y) } - /// @src 0:226:302 \"function f() external pure returns (int)...\" + /// @ast-id 30 + /// @src 0:233:309 \"function f() external pure returns (int)...\" function fun_f_30() -> var__23 { - /// @src 0:262:265 \"int\" - let zero_t_int256_1 := zero_value_for_split_t_int256() - var__23 := zero_t_int256_1 + /// @src 0:269:272 \"int\" + let zero_t_int256_2 := zero_value_for_split_t_int256() + var__23 := zero_t_int256_2 - /// @src 0:279:287 \"constVar\" + /// @src 0:286:294 \"constVar\" let expr_25 := constant_constVar_5() - /// @src 0:290:298 \"immutVar\" + /// @src 0:297:305 \"immutVar\" let _3 := loadimmutable(\"8\") let expr_26 := _3 - /// @src 0:279:298 \"constVar + immutVar\" + /// @src 0:286:305 \"constVar + immutVar\" let expr_27 := checked_add_t_int256(expr_25, expr_26) - /// @src 0:272:298 \"return constVar + immutVar\" + /// @src 0:279:305 \"return constVar + immutVar\" var__23 := expr_27 leave @@ -1020,16 +1249,17 @@ object \"D_72\" { sstore(slot, update_byte_slice_32_shift_0(sload(slot), prepare_store_t_int256(convertedValue_0))) } - /// @src 0:304:341 \"modifier m()...\" + /// @ast-id 37 + /// @src 0:311:348 \"modifier m()...\" function modifier_m_40(var__42) -> _5 { _5 := var__42 - /// @src 0:322:332 \"stateVar++\" + /// @src 0:329:339 \"stateVar++\" let _7 := read_from_storage_split_offset_0_t_int256(0x00) let _6 := increment_t_int256(_7) update_storage_value_offset_0t_int256_to_t_int256(0x00, _6) let expr_33 := _7 - /// @src 0:336:337 \"_\" + /// @src 0:343:344 \"_\" _5 := fun_f2_53_inner(var__42) } @@ -1115,19 +1345,19 @@ object \"D_72\" { revert(pos, returndatasize()) } - /// @src 0:343:426 \"function f2() m public returns (int)...\" + /// @src 0:350:433 \"function f2() m public returns (int)...\" function fun_f2_53_inner(_8) -> var__42 { var__42 := _8 - /// @src 0:392:400 \"stateVar\" + /// @src 0:399:407 \"stateVar\" let _9 := read_from_storage_split_offset_0_t_int256(0x00) let expr_44 := _9 - /// @src 0:403:407 \"this\" + /// @src 0:410:414 \"this\" let expr_45_address := address() - /// @src 0:403:409 \"this.f\" + /// @src 0:410:416 \"this.f\" let expr_46_address := convert_t_contract$_C_$54_to_t_address(expr_45_address) let expr_46_functionSelector := 0x26121ff0 - /// @src 0:403:411 \"this.f()\" + /// @src 0:410:418 \"this.f()\" if iszero(extcodesize(expr_46_address)) { revert_error_0cc013b6b3b6beabea4e3a74a6d380f0df81852ca99887912475e1f66b2a2c20() } // storage for arguments and returned data @@ -1148,25 +1378,26 @@ object \"D_72\" { // decode return parameters from external try-call into retVars expr_47 := abi_decode_tuple_t_int256_fromMemory(_10, add(_10, returndatasize())) } - /// @src 0:392:411 \"stateVar + this.f()\" + /// @src 0:399:418 \"stateVar + this.f()\" let expr_48 := checked_add_t_int256(expr_44, expr_47) - /// @src 0:414:422 \"immutVar\" + /// @src 0:421:429 \"immutVar\" let _13 := loadimmutable(\"8\") let expr_49 := _13 - /// @src 0:392:422 \"stateVar + this.f() + immutVar\" + /// @src 0:399:429 \"stateVar + this.f() + immutVar\" let expr_50 := checked_add_t_int256(expr_48, expr_49) - /// @src 0:385:422 \"return stateVar + this.f() + immutVar\" + /// @src 0:392:429 \"return stateVar + this.f() + immutVar\" var__42 := expr_50 leave } /// @src 1:91:166 \"contract D is C(3)...\" - /// @src 0:343:426 \"function f2() m public returns (int)...\" + /// @ast-id 53 + /// @src 0:350:433 \"function f2() m public returns (int)...\" function fun_f2_53() -> var__42 { - /// @src 0:375:378 \"int\" + /// @src 0:382:385 \"int\" let zero_t_int256_4 := zero_value_for_split_t_int256() var__42 := zero_t_int256_4 @@ -1181,4 +1412,194 @@ object \"D_72\" { } +","irOptimized":"/*=====================================================* + * WARNING * + * Solidity to Yul compilation is still EXPERIMENTAL * + * It can result in LOSS OF FUNDS or worse * + * !USE AT YOUR OWN RISK! * + *=====================================================*/ + +/// @use-src 0:\"C\", 1:\"D\" +object \"D_72\" { + code { + { + /// @src 1:91:166 \"contract D is C(3)...\" + mstore(64, 160) + if callvalue() { revert(0, 0) } + let programSize := datasize(\"D_72\") + let argSize := sub(codesize(), programSize) + let newFreePtr := add(160, and(add(argSize, 31), not(31))) + if or(gt(newFreePtr, sub(shl(64, 1), 1)), lt(newFreePtr, 160)) + { + mstore(/** @src -1:-1:-1 */ 0, /** @src 1:91:166 \"contract D is C(3)...\" */ shl(224, 0x4e487b71)) + mstore(4, 0x41) + revert(/** @src -1:-1:-1 */ 0, /** @src 1:91:166 \"contract D is C(3)...\" */ 0x24) + } + mstore(64, newFreePtr) + codecopy(160, programSize, argSize) + if slt(argSize, 32) + { + revert(/** @src -1:-1:-1 */ 0, 0) + } + /// @src 1:91:166 \"contract D is C(3)...\" + constructor_D(mload(160)) + let _1 := mload(64) + let _2 := datasize(\"D_72_deployed\") + codecopy(_1, dataoffset(\"D_72_deployed\"), _2) + setimmutable(_1, \"8\", mload(128)) + return(_1, _2) + } + /// @ast-id 71 @src 1:113:164 \"constructor(int _init2)...\" + function constructor_D(var_init2) + { + /// @src 0:154:156 \"42\" + mstore(128, 0x2a) + /// @src 1:91:166 \"contract D is C(3)...\" + sstore(/** @src 0:210:226 \"stateVar = _init\" */ 0x00, /** @src 1:107:108 \"3\" */ 0x03) + /// @src 1:91:166 \"contract D is C(3)...\" + if and(1, sgt(var_init2, sub(shl(255, 1), 4))) + { + mstore(/** @src 0:210:226 \"stateVar = _init\" */ 0x00, /** @src 1:91:166 \"contract D is C(3)...\" */ shl(224, 0x4e487b71)) + mstore(4, 0x11) + revert(/** @src 0:210:226 \"stateVar = _init\" */ 0x00, /** @src 1:91:166 \"contract D is C(3)...\" */ 0x24) + } + sstore(/** @src 0:210:226 \"stateVar = _init\" */ 0x00, /** @src 1:91:166 \"contract D is C(3)...\" */ add(/** @src 1:107:108 \"3\" */ 0x03, /** @src 1:91:166 \"contract D is C(3)...\" */ var_init2)) + } + } + /// @use-src 0:\"C\", 1:\"D\" + object \"D_72_deployed\" { + code { + { + /// @src 1:91:166 \"contract D is C(3)...\" + mstore(64, 128) + if iszero(lt(calldatasize(), 4)) + { + let _1 := 0 + switch shr(224, calldataload(_1)) + case 0x26121ff0 { + if callvalue() { revert(_1, _1) } + abi_decode(calldatasize()) + let ret := /** @src 0:286:305 \"constVar + immutVar\" */ checked_add_int256_568(/** @src 0:297:305 \"immutVar\" */ loadimmutable(\"8\")) + /// @src 1:91:166 \"contract D is C(3)...\" + let memPos := mload(64) + return(memPos, sub(abi_encode_int256(memPos, ret), memPos)) + } + case 0x793816ec { + if callvalue() { revert(_1, _1) } + abi_decode(calldatasize()) + let ret_1 := sload(_1) + let memPos_1 := mload(64) + return(memPos_1, sub(abi_encode_int256(memPos_1, ret_1), memPos_1)) + } + case 0x9942ec6f { + if callvalue() { revert(_1, _1) } + abi_decode(calldatasize()) + let ret_2 := /** @src 0:382:385 \"int\" */ modifier_m() + /// @src 1:91:166 \"contract D is C(3)...\" + let memPos_2 := mload(64) + return(memPos_2, sub(abi_encode_int256(memPos_2, ret_2), memPos_2)) + } + case 0xa00b982b { + if callvalue() { revert(_1, _1) } + abi_decode(calldatasize()) + let memPos_3 := mload(64) + return(memPos_3, sub(abi_encode_int256_567(memPos_3), memPos_3)) + } + } + revert(0, 0) + } + function abi_decode(dataEnd) + { + if slt(add(dataEnd, not(3)), 0) { revert(0, 0) } + } + function abi_encode_int256_567(headStart) -> tail + { + tail := add(headStart, 32) + mstore(headStart, /** @src 0:124:126 \"41\" */ 0x29) + } + /// @src 1:91:166 \"contract D is C(3)...\" + function abi_encode_int256(headStart, value0) -> tail + { + tail := add(headStart, 32) + mstore(headStart, value0) + } + function panic_error_0x11() + { + mstore(0, shl(224, 0x4e487b71)) + mstore(4, 0x11) + revert(0, 0x24) + } + function checked_add_int256_568(y) -> sum + { + if and(1, sgt(y, sub(shl(255, 1), 42))) { panic_error_0x11() } + sum := add(/** @src 0:124:126 \"41\" */ 0x29, /** @src 1:91:166 \"contract D is C(3)...\" */ y) + } + function checked_add_int256(x, y) -> sum + { + let _1 := slt(x, 0) + if and(iszero(_1), sgt(y, sub(sub(shl(255, 1), 1), x))) { panic_error_0x11() } + if and(_1, slt(y, sub(shl(255, 1), x))) { panic_error_0x11() } + sum := add(x, y) + } + /// @ast-id 37 @src 0:311:348 \"modifier m()...\" + function modifier_m() -> _1 + { + /// @src 1:91:166 \"contract D is C(3)...\" + let _2 := 0 + let _3 := sload(_2) + if eq(_3, sub(shl(255, 1), 1)) { panic_error_0x11() } + let ret := add(_3, 1) + sstore(_2, ret) + /// @src 0:410:418 \"this.f()\" + if iszero(extcodesize(/** @src 0:410:414 \"this\" */ address())) + /// @src 0:410:418 \"this.f()\" + { + /// @src 1:91:166 \"contract D is C(3)...\" + revert(_2, _2) + } + /// @src 0:410:418 \"this.f()\" + let _4 := /** @src 1:91:166 \"contract D is C(3)...\" */ mload(64) + /// @src 0:410:418 \"this.f()\" + mstore(_4, /** @src 1:91:166 \"contract D is C(3)...\" */ shl(228, 0x026121ff)) + /// @src 0:410:418 \"this.f()\" + let _5 := staticcall(gas(), /** @src 0:410:414 \"this\" */ address(), /** @src 0:410:418 \"this.f()\" */ _4, 4, _4, 32) + if iszero(_5) + { + /// @src 1:91:166 \"contract D is C(3)...\" + let pos := mload(64) + returndatacopy(pos, _2, returndatasize()) + revert(pos, returndatasize()) + } + /// @src 0:410:418 \"this.f()\" + let expr := /** @src 1:91:166 \"contract D is C(3)...\" */ _2 + /// @src 0:410:418 \"this.f()\" + if _5 + { + /// @src 1:91:166 \"contract D is C(3)...\" + let newFreePtr := add(_4, and(add(/** @src 0:410:418 \"this.f()\" */ returndatasize(), /** @src 1:91:166 \"contract D is C(3)...\" */ 31), not(31))) + if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, _4)) + { + mstore(_2, shl(224, 0x4e487b71)) + mstore(/** @src 0:410:418 \"this.f()\" */ 4, /** @src 1:91:166 \"contract D is C(3)...\" */ 0x41) + revert(_2, 0x24) + } + mstore(64, newFreePtr) + /// @src 0:410:418 \"this.f()\" + expr := abi_decode_int256_fromMemory(_4, add(_4, returndatasize())) + } + /// @src 0:399:418 \"stateVar + this.f()\" + let expr_1 := checked_add_int256(ret, expr) + /// @src 0:343:344 \"_\" + _1 := /** @src 0:399:429 \"stateVar + this.f() + immutVar\" */ checked_add_int256(expr_1, /** @src 0:421:429 \"immutVar\" */ loadimmutable(\"8\")) + } + /// @src 1:91:166 \"contract D is C(3)...\" + function abi_decode_int256_fromMemory(headStart, dataEnd) -> value0 + { + if slt(sub(dataEnd, headStart), 32) { revert(0, 0) } + value0 := mload(headStart) + } + } + data \".metadata\" hex\"\" + } +} "}}},"sources":{"C":{"id":0},"D":{"id":1}}} diff --git a/test/cmdlineTests/viair_abicoder_v1/output b/test/cmdlineTests/viair_abicoder_v1/output index 3a0d4744b..18d02a0e9 100644 --- a/test/cmdlineTests/viair_abicoder_v1/output +++ b/test/cmdlineTests/viair_abicoder_v1/output @@ -113,6 +113,7 @@ object "test_11" { ret := 0 } + /// @ast-id 10 /// @src 0:99:167 "function f() public pure returns (bool) {..." function fun_f_10() -> var__5 { /// @src 0:133:137 "bool" diff --git a/test/cmdlineTests/yul_source_locations/input.json b/test/cmdlineTests/yul_source_locations/input.json deleted file mode 100644 index ce5c4b626..000000000 --- a/test/cmdlineTests/yul_source_locations/input.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "language": "Solidity", - "sources": - { - "C": - { - "content": "//SPDX-License-Identifier: GPL-2.0\npragma solidity >=0.0;\npragma abicoder v2;\n\ncontract C\n{\n int constant constVar = 41;\n int immutable immutVar = 42;\n int public stateVar;\n\n constructor(int _init)\n {\n stateVar = _init;\n }\n\n function f() external pure returns (int)\n {\n return constVar + immutVar;\n }\n modifier m()\n {\n stateVar++;\n _;\n }\n function f2() m public returns (int)\n {\n return stateVar + this.f() + immutVar;\n }\n}\n" - }, - "D": - { - "content": "//SPDX-License-Identifier: GPL-2.0\npragma solidity >=0.0;\npragma abicoder v2;\nimport \"C\";\n\ncontract D is C(3)\n{\n constructor(int _init2)\n {\n stateVar += _init2;\n }\n}\n" - } - }, - "settings": - { - "outputSelection": - { - "*": { "*": ["ir"] } - } - } -} diff --git a/test/cmdlineTests/yul_source_locations_code_snippet_escaping/output b/test/cmdlineTests/yul_source_locations_code_snippet_escaping/output index 6563ceb3e..9fea7f8cc 100644 --- a/test/cmdlineTests/yul_source_locations_code_snippet_escaping/output +++ b/test/cmdlineTests/yul_source_locations_code_snippet_escaping/output @@ -333,6 +333,7 @@ object "D_27" { converted := copy_literal_to_memory_5bde9a896e3f09acac1496d16642fcdd887d2a000bf1ab18bdff3f17b91e320b() } + /// @ast-id 26 /// @src 0:336:597 "function f() /* @use-src 0:\"input.sol\", 1:\"#utility.yul\" @ast-id 15 *\/ public returns (string memory) { C c = new /// @src 0:149:156 \"new C()\"..." function fun_f_26() -> var__5_mpos { /// @src 0:423:436 "string memory" diff --git a/test/cmdlineTests/yul_string_format_ascii/output.json b/test/cmdlineTests/yul_string_format_ascii/output.json index 221c9d306..f68f984c7 100644 --- a/test/cmdlineTests/yul_string_format_ascii/output.json +++ b/test/cmdlineTests/yul_string_format_ascii/output.json @@ -192,6 +192,7 @@ object \"C_11\" { converted := copy_literal_to_memory_9f0adad0a59b05d2e04a1373342b10b9eb16c57c164c8a3bfcbf46dccee39a21() } + /// @ast-id 10 /// @src 0:91:162 \"function f() external pure returns (string memory) { return \\\"abcabc\\\"; }\" function fun_f_10() -> var__5_mpos { /// @src 0:127:140 \"string memory\" diff --git a/test/cmdlineTests/yul_string_format_ascii_bytes32/output.json b/test/cmdlineTests/yul_string_format_ascii_bytes32/output.json index 0c8fbe701..e2757135e 100644 --- a/test/cmdlineTests/yul_string_format_ascii_bytes32/output.json +++ b/test/cmdlineTests/yul_string_format_ascii_bytes32/output.json @@ -116,6 +116,7 @@ object \"C_11\" { converted := 0x6162636162630000000000000000000000000000000000000000000000000000 } + /// @ast-id 10 /// @src 0:91:156 \"function f() external pure returns (bytes32) { return \\\"abcabc\\\"; }\" function fun_f_10() -> var__5 { /// @src 0:127:134 \"bytes32\" diff --git a/test/cmdlineTests/yul_string_format_ascii_bytes32_from_number/output.json b/test/cmdlineTests/yul_string_format_ascii_bytes32_from_number/output.json index f495dc98a..c977d791d 100644 --- a/test/cmdlineTests/yul_string_format_ascii_bytes32_from_number/output.json +++ b/test/cmdlineTests/yul_string_format_ascii_bytes32_from_number/output.json @@ -127,6 +127,7 @@ object \"C_11\" { converted := cleanup_t_bytes4(shift_left_224(cleanup_t_rational_1633837924_by_1(value))) } + /// @ast-id 10 /// @src 0:91:157 \"function f() external pure returns (bytes4) { return 0x61626364; }\" function fun_f_10() -> var__5 { /// @src 0:127:133 \"bytes4\" diff --git a/test/cmdlineTests/yul_string_format_ascii_long/output.json b/test/cmdlineTests/yul_string_format_ascii_long/output.json index c32952157..19428f29d 100644 --- a/test/cmdlineTests/yul_string_format_ascii_long/output.json +++ b/test/cmdlineTests/yul_string_format_ascii_long/output.json @@ -196,6 +196,7 @@ object \"C_11\" { converted := copy_literal_to_memory_d6604f85ac07e2b33103a620b3d3d75b0473c7214912beded67b9b624d41c571() } + /// @ast-id 10 /// @src 0:91:241 \"function f() external pure returns (string memory) { return \\\"abcdabcdcafecafeabcdabcdcafecafeffffzzzzoooo0123456789,.<,>.?:;'[{]}|`~!@#$%^&*()-_=+\\\"; }\" function fun_f_10() -> var__5_mpos { /// @src 0:127:140 \"string memory\" diff --git a/test/cmdlineTests/yul_string_format_hex/output.json b/test/cmdlineTests/yul_string_format_hex/output.json index 98e3c8e46..b17922a55 100644 --- a/test/cmdlineTests/yul_string_format_hex/output.json +++ b/test/cmdlineTests/yul_string_format_hex/output.json @@ -127,6 +127,7 @@ object \"C_11\" { converted := cleanup_t_bytes4(shift_left_224(cleanup_t_rational_2864434397_by_1(value))) } + /// @ast-id 10 /// @src 0:91:157 \"function f() external pure returns (bytes4) { return 0xaabbccdd; }\" function fun_f_10() -> var__5 { /// @src 0:127:133 \"bytes4\"