diff --git a/Changelog.md b/Changelog.md index e34e6021a..779aadbeb 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,6 +4,7 @@ Language Features: Compiler Features: + * Export compiler-generated utility sources via standard-json or combined-json. * SMTChecker: Support shifts. * SMTChecker: Support structs. * SMTChecker: Support ``type(T).min``, ``type(T).max``, and ``type(I).interfaceId``. diff --git a/libsolidity/codegen/Compiler.cpp b/libsolidity/codegen/Compiler.cpp index a64a34009..0b6385943 100644 --- a/libsolidity/codegen/Compiler.cpp +++ b/libsolidity/codegen/Compiler.cpp @@ -51,8 +51,8 @@ void Compiler::compileContract( m_context.optimise(m_optimiserSettings); - solAssert(m_context.requestedYulFunctionsRan(), "requestedYulFunctions() was not called."); - solAssert(m_runtimeContext.requestedYulFunctionsRan(), "requestedYulFunctions() was not called."); + solAssert(m_context.appendYulUtilityFunctionsRan(), "appendYulUtilityFunctions() was not called."); + solAssert(m_runtimeContext.appendYulUtilityFunctionsRan(), "appendYulUtilityFunctions() was not called."); } std::shared_ptr Compiler::runtimeAssemblyPtr() const diff --git a/libsolidity/codegen/Compiler.h b/libsolidity/codegen/Compiler.h index 11d5c2abd..4dbbeb099 100644 --- a/libsolidity/codegen/Compiler.h +++ b/libsolidity/codegen/Compiler.h @@ -74,6 +74,9 @@ public: /// @returns Assembly items of the runtime compiler context evmasm::AssemblyItems const& runtimeAssemblyItems() const { return m_context.assembly().sub(m_runtimeSub).items(); } + std::string generatedYulUtilityCode() const { return m_context.generatedYulUtilityCode(); } + std::string runtimeGeneratedYulUtilityCode() const { return m_runtimeContext.generatedYulUtilityCode(); } + /// @returns the entry label of the given function. Might return an AssemblyItem of type /// UndefinedItem if it does not exist yet. evmasm::AssemblyItem functionEntryLabel(FunctionDefinition const& _function) const; diff --git a/libsolidity/codegen/CompilerContext.cpp b/libsolidity/codegen/CompilerContext.cpp index 9fde94e8a..ff52e626c 100644 --- a/libsolidity/codegen/CompilerContext.cpp +++ b/libsolidity/codegen/CompilerContext.cpp @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -37,6 +38,7 @@ #include #include #include +#include #include @@ -51,9 +53,6 @@ // Change to "define" to output all intermediate code #undef SOL_OUTPUT_ASM -#ifdef SOL_OUTPUT_ASM -#include -#endif using namespace std; @@ -191,14 +190,24 @@ void CompilerContext::appendMissingLowLevelFunctions() } } -pair> CompilerContext::requestedYulFunctions() +void CompilerContext::appendYulUtilityFunctions(OptimiserSettings const& _optimiserSettings) { - solAssert(!m_requestedYulFunctionsRan, "requestedYulFunctions called more than once."); - m_requestedYulFunctionsRan = true; + solAssert(!m_appendYulUtilityFunctionsRan, "requestedYulFunctions called more than once."); + m_appendYulUtilityFunctionsRan = true; - set empty; - swap(empty, m_externallyUsedYulFunctions); - return {m_yulFunctionCollector.requestedFunctions(), std::move(empty)}; + string code = m_yulFunctionCollector.requestedFunctions(); + if (!code.empty()) + { + appendInlineAssembly( + yul::reindent("{\n" + move(code) + "\n}"), + {}, + m_externallyUsedYulFunctions, + true, + _optimiserSettings, + yulUtilityFileName() + ); + solAssert(!m_generatedYulUtilityCode.empty(), ""); + } } void CompilerContext::addVariable( @@ -369,7 +378,8 @@ void CompilerContext::appendInlineAssembly( vector const& _localVariables, set const& _externallyUsedFunctions, bool _system, - OptimiserSettings const& _optimiserSettings + OptimiserSettings const& _optimiserSettings, + string _sourceName ) { unsigned startStackHeight = stackHeight(); @@ -420,7 +430,7 @@ void CompilerContext::appendInlineAssembly( ErrorList errors; ErrorReporter errorReporter(errors); - auto scanner = make_shared(langutil::CharStream(_assembly, "--CODEGEN--")); + auto scanner = make_shared(langutil::CharStream(_assembly, _sourceName)); yul::EVMDialect const& dialect = yul::EVMDialect::strictAssemblyForEVM(m_evmVersion); optional locationOverride; if (!_system) @@ -469,6 +479,17 @@ void CompilerContext::appendInlineAssembly( optimizeYul(obj, dialect, _optimiserSettings, externallyUsedIdentifiers); + if (_system) + { + // Store as generated sources, but first re-parse to update the source references. + solAssert(m_generatedYulUtilityCode.empty(), ""); + m_generatedYulUtilityCode = yul::AsmPrinter(dialect)(*obj.code); + string code = yul::AsmPrinter{dialect}(*obj.code); + scanner = make_shared(langutil::CharStream(m_generatedYulUtilityCode, _sourceName)); + obj.code = yul::Parser(errorReporter, dialect).parse(scanner, false); + *obj.analysisInfo = yul::AsmAnalyzer::analyzeStrictAssertCorrect(dialect, obj); + } + analysisInfo = std::move(*obj.analysisInfo); parserResult = std::move(obj.code); @@ -477,6 +498,12 @@ void CompilerContext::appendInlineAssembly( cout << yul::AsmPrinter(&dialect)(*parserResult) << endl; #endif } + else if (_system) + { + // Store as generated source. + solAssert(m_generatedYulUtilityCode.empty(), ""); + m_generatedYulUtilityCode = _assembly; + } if (!errorReporter.errors().empty()) reportError("Failed to analyze inline assembly block."); diff --git a/libsolidity/codegen/CompilerContext.h b/libsolidity/codegen/CompilerContext.h index f82c705d8..72ed4fe6f 100644 --- a/libsolidity/codegen/CompilerContext.h +++ b/libsolidity/codegen/CompilerContext.h @@ -163,12 +163,14 @@ public: void appendMissingLowLevelFunctions(); ABIFunctions& abiFunctions() { return m_abiFunctions; } YulUtilFunctions& utilFunctions() { return m_yulUtilFunctions; } - /// @returns concatenation of all generated functions and a set of the - /// externally used functions. - /// Clears the internal list, i.e. calling it again will result in an - /// empty return value. - std::pair> requestedYulFunctions(); - bool requestedYulFunctionsRan() const { return m_requestedYulFunctionsRan; } + + /// Appends concatenation of all generated Yul functions to the bytecode + /// and stores the Yul source code to be returned by @a generatedYulUtilityCode. + /// Should be called exactly once on each context. + void appendYulUtilityFunctions(OptimiserSettings const& _optimiserSettings); + bool appendYulUtilityFunctionsRan() const { return m_appendYulUtilityFunctionsRan; } + std::string const& generatedYulUtilityCode() const { return m_generatedYulUtilityCode; } + static std::string yulUtilityFileName() { return "#utility.yul"; } /// Returns the distance of the given local variable from the bottom of the stack (of the current function). unsigned baseStackOffsetOfVariable(Declaration const& _declaration) const; @@ -246,17 +248,21 @@ public: CompilerContext& operator<<(u256 const& _value) { m_asm->append(_value); return *this; } CompilerContext& operator<<(bytes const& _data) { m_asm->append(_data); return *this; } - /// Appends inline assembly (strict mode). - /// @a _replacements are string-matching replacements that are performed prior to parsing the inline assembly. + /// Appends inline assembly (strict-EVM dialect for the current version). + /// @param _assembly the assembly text, should be a block. /// @param _localVariables assigns stack positions to variables with the last one being the stack top /// @param _externallyUsedFunctions a set of function names that are not to be renamed or removed. - /// @param _system if true, this is a "system-level" assembly where all functions use named labels. + /// @param _system if true, this is a "system-level" assembly where all functions use named labels + /// and the code is marked to be exported as "compiler-generated assembly utility file". + /// @param _optimiserSettings settings for the Yul optimiser, which is run in this function already. + /// @param _sourceName the name of the assembly file to be used for source locations void appendInlineAssembly( std::string const& _assembly, std::vector const& _localVariables = std::vector(), std::set const& _externallyUsedFunctions = std::set(), bool _system = false, - OptimiserSettings const& _optimiserSettings = OptimiserSettings::none() + OptimiserSettings const& _optimiserSettings = OptimiserSettings::none(), + std::string _sourceName = "--CODEGEN--" ); /// If m_revertStrings is debug, @returns inline assembly code that @@ -385,14 +391,17 @@ private: MultiUseYulFunctionCollector m_yulFunctionCollector; /// Set of externally used yul functions. std::set m_externallyUsedYulFunctions; + /// Generated Yul code used as utility. Source references from the bytecode can point here. + /// Produced from @a m_yulFunctionCollector. + std::string m_generatedYulUtilityCode; /// Container for ABI functions to be generated. ABIFunctions m_abiFunctions; /// Container for Yul Util functions to be generated. YulUtilFunctions m_yulUtilFunctions; /// The queue of low-level functions to generate. std::queue>> m_lowLevelFunctionGenerationQueue; - /// Flag to check that requestedYulFunctions() was called exactly once - bool m_requestedYulFunctionsRan = false; + /// Flag to check that appendYulUtilityFunctions() was called exactly once + bool m_appendYulUtilityFunctionsRan = false; }; } diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp index cbad912a8..651152a2c 100644 --- a/libsolidity/codegen/ContractCompiler.cpp +++ b/libsolidity/codegen/ContractCompiler.cpp @@ -1272,15 +1272,7 @@ void ContractCompiler::appendMissingFunctions() solAssert(m_context.nextFunctionToCompile() != function, "Compiled the wrong function?"); } m_context.appendMissingLowLevelFunctions(); - auto [yulFunctions, externallyUsedYulFunctions] = m_context.requestedYulFunctions(); - if (!yulFunctions.empty()) - m_context.appendInlineAssembly( - "{" + move(yulFunctions) + "}", - {}, - externallyUsedYulFunctions, - true, - m_optimiserSettings - ); + m_context.appendYulUtilityFunctions(m_optimiserSettings); } void ContractCompiler::appendModifierOrFunctionCode() diff --git a/libsolidity/codegen/ContractCompiler.h b/libsolidity/codegen/ContractCompiler.h index d4badc197..64c86fc2d 100644 --- a/libsolidity/codegen/ContractCompiler.h +++ b/libsolidity/codegen/ContractCompiler.h @@ -143,6 +143,7 @@ private: /// Pointer to the runtime compiler in case this is a creation compiler. ContractCompiler* m_runtimeCompiler = nullptr; CompilerContext& m_context; + /// Tag to jump to for a "break" statement and the stack height after freeing the local loop variables. std::vector> m_breakTags; /// Tag to jump to for a "continue" statement and the stack height after freeing the local loop variables. diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index da42cbfa4..79380a703 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -57,7 +57,9 @@ #include #include +#include #include +#include #include #include @@ -591,6 +593,48 @@ evmasm::AssemblyItems const* CompilerStack::runtimeAssemblyItems(string const& _ return currentContract.compiler ? &contract(_contractName).compiler->runtimeAssemblyItems() : nullptr; } +Json::Value CompilerStack::generatedSources(string const& _contractName, bool _runtime) const +{ + if (m_stackState != CompilationSuccessful) + BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Compilation was not successful.")); + + Contract const& c = contract(_contractName); + util::LazyInit const& sources = + _runtime ? + c.runtimeGeneratedSources : + c.generatedSources; + return sources.init([&]{ + Json::Value sources{Json::arrayValue}; + // If there is no compiler, then no bytecode was generated and thus no + // sources were generated. + if (c.compiler) + { + string source = + _runtime ? + c.compiler->runtimeGeneratedYulUtilityCode() : + c.compiler->generatedYulUtilityCode(); + if (!source.empty()) + { + string sourceName = CompilerContext::yulUtilityFileName(); + unsigned sourceIndex = sourceIndices()[sourceName]; + ErrorList errors; + ErrorReporter errorReporter(errors); + auto scanner = make_shared(langutil::CharStream(source, sourceName)); + yul::EVMDialect const& dialect = yul::EVMDialect::strictAssemblyForEVM(m_evmVersion); + shared_ptr parserResult = yul::Parser{errorReporter, dialect}.parse(scanner, false); + solAssert(parserResult, ""); + sources[0]["ast"] = yul::AsmJsonConverter{sourceIndex}(*parserResult); + sources[0]["name"] = sourceName; + sources[0]["id"] = sourceIndex; + sources[0]["language"] = "Yul"; + sources[0]["contents"] = move(source); + + } + } + return sources; + }); +} + string const* CompilerStack::sourceMapping(string const& _contractName) const { if (m_stackState != CompilationSuccessful) @@ -733,6 +777,8 @@ map CompilerStack::sourceIndices() const unsigned index = 0; for (auto const& s: m_sources) indices[s.first] = index++; + solAssert(!indices.count(CompilerContext::yulUtilityFileName()), ""); + indices[CompilerContext::yulUtilityFileName()] = index++; return indices; } diff --git a/libsolidity/interface/CompilerStack.h b/libsolidity/interface/CompilerStack.h index 1f4575913..8b048ad01 100644 --- a/libsolidity/interface/CompilerStack.h +++ b/libsolidity/interface/CompilerStack.h @@ -277,6 +277,10 @@ public: /// @returns runtime contract assembly items evmasm::AssemblyItems const* runtimeAssemblyItems(std::string const& _contractName) const; + /// @returns an array containing all utility sources generated during compilation. + /// Format: [ { name: string, id: number, language: "Yul", contents: string }, ... ] + Json::Value generatedSources(std::string const& _contractName, bool _runtime = false) const; + /// @returns the string that provides a mapping between bytecode and sourcecode or a nullptr /// if the contract does not (yet) have bytecode. std::string const* sourceMapping(std::string const& _contractName) const; @@ -356,6 +360,8 @@ private: util::LazyInit storageLayout; util::LazyInit userDocumentation; util::LazyInit devDocumentation; + util::LazyInit generatedSources; + util::LazyInit runtimeGeneratedSources; mutable std::optional sourceMapping; mutable std::optional runtimeSourceMapping; }; diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp index 4506a6f7e..f708c5a4a 100644 --- a/libsolidity/interface/StandardCompiler.cpp +++ b/libsolidity/interface/StandardCompiler.cpp @@ -230,6 +230,16 @@ bool isArtifactRequested(Json::Value const& _outputSelection, string const& _fil return false; } +/// @returns all artifact names of the EVM object, either for creation or deploy time. +vector evmObjectComponents(string const& _objectKind) +{ + solAssert(_objectKind == "bytecode" || _objectKind == "deployedBytecode", ""); + vector components{"", ".object", ".opcodes", ".sourceMap", ".generatedSources", ".linkReferences"}; + if (_objectKind == "deployedBytecode") + components.push_back(".immutableReferences"); + return util::applyMap(components, [&](auto const& _s) { return "evm." + _objectKind + _s; }); +} + /// @returns true if any binary was requested, i.e. we actually have to perform compilation. bool isBinaryRequested(Json::Value const& _outputSelection) { @@ -237,17 +247,12 @@ bool isBinaryRequested(Json::Value const& _outputSelection) return false; // This does not include "evm.methodIdentifiers" on purpose! - static vector const outputsThatRequireBinaries{ + static vector const outputsThatRequireBinaries = vector{ "*", "ir", "irOptimized", "wast", "wasm", "ewasm.wast", "ewasm.wasm", - "evm.deployedBytecode", "evm.deployedBytecode.object", "evm.deployedBytecode.opcodes", - "evm.deployedBytecode.sourceMap", "evm.deployedBytecode.linkReferences", - "evm.deployedBytecode.immutableReferences", - "evm.bytecode", "evm.bytecode.object", "evm.bytecode.opcodes", "evm.bytecode.sourceMap", - "evm.bytecode.linkReferences", "evm.gasEstimates", "evm.legacyAssembly", "evm.assembly" - }; + } + evmObjectComponents("bytecode") + evmObjectComponents("deployedBytecode"); for (auto const& fileRequests: _outputSelection) for (auto const& requests: fileRequests) @@ -263,15 +268,10 @@ bool isEvmBytecodeRequested(Json::Value const& _outputSelection) if (!_outputSelection.isObject()) return false; - static vector const outputsThatRequireEvmBinaries{ + static vector const outputsThatRequireEvmBinaries = vector{ "*", - "evm.deployedBytecode", "evm.deployedBytecode.object", "evm.deployedBytecode.opcodes", - "evm.deployedBytecode.sourceMap", "evm.deployedBytecode.linkReferences", - "evm.deployedBytecode.immutableReferences", - "evm.bytecode", "evm.bytecode.object", "evm.bytecode.opcodes", "evm.bytecode.sourceMap", - "evm.bytecode.linkReferences", "evm.gasEstimates", "evm.legacyAssembly", "evm.assembly" - }; + } + evmObjectComponents("bytecode") + evmObjectComponents("deployedBytecode"); for (auto const& fileRequests: _outputSelection) for (auto const& requests: fileRequests) @@ -364,7 +364,12 @@ Json::Value formatImmutableReferences(map>> co return ret; } -Json::Value collectEVMObject(evmasm::LinkerObject const& _object, string const* _sourceMap, bool _runtimeObject) +Json::Value collectEVMObject( + evmasm::LinkerObject const& _object, + string const* _sourceMap, + Json::Value _generatedSources, + bool _runtimeObject +) { Json::Value output = Json::objectValue; output["object"] = _object.toHex(); @@ -373,6 +378,7 @@ Json::Value collectEVMObject(evmasm::LinkerObject const& _object, string const* output["linkReferences"] = formatLinkReferences(_object.linkReferences); if (_runtimeObject) output["immutableReferences"] = formatImmutableReferences(_object.immutableReferences); + output["generatedSources"] = move(_generatedSources); return output; } @@ -1074,12 +1080,13 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting _inputsAndSettings.outputSelection, file, name, - { "evm.bytecode", "evm.bytecode.object", "evm.bytecode.opcodes", "evm.bytecode.sourceMap", "evm.bytecode.linkReferences" }, + evmObjectComponents("bytecode"), wildcardMatchesExperimental )) evmData["bytecode"] = collectEVMObject( compilerStack.object(contractName), compilerStack.sourceMapping(contractName), + compilerStack.generatedSources(contractName), false ); @@ -1087,12 +1094,13 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting _inputsAndSettings.outputSelection, file, name, - { "evm.deployedBytecode", "evm.deployedBytecode.object", "evm.deployedBytecode.opcodes", "evm.deployedBytecode.sourceMap", "evm.deployedBytecode.linkReferences", "evm.deployedBytecode.immutableReferences" }, + evmObjectComponents("deployedBytecode"), wildcardMatchesExperimental )) evmData["deployedBytecode"] = collectEVMObject( compilerStack.runtimeObject(contractName), compilerStack.runtimeSourceMapping(contractName), + compilerStack.generatedSources(contractName, true), true ); @@ -1176,24 +1184,19 @@ Json::Value StandardCompiler::compileYul(InputsAndSettings _inputsAndSettings) tie(object, runtimeObject) = stack.assembleAndGuessRuntime(); for (string const& objectKind: vector{"bytecode", "deployedBytecode"}) - { - auto artifacts = util::applyMap( - vector{"", ".object", ".opcodes", ".sourceMap", ".linkReferences"}, - [&](auto const& _s) { return "evm." + objectKind + _s; } - ); if (isArtifactRequested( _inputsAndSettings.outputSelection, sourceName, contractName, - artifacts, + evmObjectComponents(objectKind), wildcardMatchesExperimental )) { MachineAssemblyObject const& o = objectKind == "bytecode" ? object : runtimeObject; if (o.bytecode) - output["contracts"][sourceName][contractName]["evm"][objectKind] = collectEVMObject(*o.bytecode, o.sourceMappings.get(), false); + output["contracts"][sourceName][contractName]["evm"][objectKind] = + collectEVMObject(*o.bytecode, o.sourceMappings.get(), Json::arrayValue, false); } - } if (isArtifactRequested(_inputsAndSettings.outputSelection, sourceName, contractName, "irOptimized", wildcardMatchesExperimental)) output["contracts"][sourceName][contractName]["irOptimized"] = stack.print(); diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 8e8abf4e5..596ae1728 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -127,6 +127,8 @@ static string const g_strEVM = "evm"; static string const g_strEVM15 = "evm15"; static string const g_strEVMVersion = "evm-version"; static string const g_strEwasm = "ewasm"; +static string const g_strGeneratedSources = "generated-sources"; +static string const g_strGeneratedSourcesRuntime = "generated-sources-runtime"; static string const g_strGas = "gas"; static string const g_strHelp = "help"; static string const g_strImportAst = "import-ast"; @@ -238,6 +240,8 @@ static set const g_combinedJsonArgs g_strBinary, g_strBinaryRuntime, g_strCompactJSON, + g_strGeneratedSources, + g_strGeneratedSourcesRuntime, g_strInterface, g_strMetadata, g_strNatspecUser, @@ -1523,6 +1527,10 @@ void CommandLineInterface::handleCombinedJSON() contractData[g_strAsm] = m_compiler->assemblyJSON(contractName); if (requests.count(g_strStorageLayout) && m_compiler->compilationSuccessful()) contractData[g_strStorageLayout] = jsonCompactPrint(m_compiler->storageLayout(contractName)); + if (requests.count(g_strGeneratedSources) && m_compiler->compilationSuccessful()) + contractData[g_strGeneratedSources] = m_compiler->generatedSources(contractName, false); + if (requests.count(g_strGeneratedSourcesRuntime) && m_compiler->compilationSuccessful()) + contractData[g_strGeneratedSourcesRuntime] = m_compiler->generatedSources(contractName, true); if (requests.count(g_strSrcMap) && m_compiler->compilationSuccessful()) { auto map = m_compiler->sourceMapping(contractName); diff --git a/test/cmdlineTests.sh b/test/cmdlineTests.sh index 448ba5a6e..a22fb7339 100755 --- a/test/cmdlineTests.sh +++ b/test/cmdlineTests.sh @@ -124,6 +124,7 @@ function test_solc_behaviour() sed -i.bak -e '/^Warning (3805): This is a pre-release compiler version, please do not use it in production./d' "$stderr_path" sed -i.bak -e 's/\(^[ ]*auxdata: \)0x[0-9a-f]*$/\1AUXDATA REMOVED/' "$stdout_path" sed -i.bak -e 's/ Consider adding "pragma .*$//' "$stderr_path" + sed -i.bak -e 's/"version": "[^"]*"/"version": "VERSION REMOVED"/' "$stdout_path" # Remove trailing empty lines. Needs a line break to make OSX sed happy. sed -i.bak -e '1{/^$/d }' "$stderr_path" diff --git a/test/cmdlineTests/combined_json_generated_sources/args b/test/cmdlineTests/combined_json_generated_sources/args new file mode 100644 index 000000000..425ca0a0b --- /dev/null +++ b/test/cmdlineTests/combined_json_generated_sources/args @@ -0,0 +1 @@ +--combined-json generated-sources,generated-sources-runtime --pretty-json diff --git a/test/cmdlineTests/combined_json_generated_sources/err b/test/cmdlineTests/combined_json_generated_sources/err new file mode 100644 index 000000000..c6113508b --- /dev/null +++ b/test/cmdlineTests/combined_json_generated_sources/err @@ -0,0 +1,5 @@ +Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: " to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information. +--> combined_json_generated_sources/input.sol + +Warning: Source file does not specify required compiler version! +--> combined_json_generated_sources/input.sol diff --git a/test/cmdlineTests/combined_json_generated_sources/exit b/test/cmdlineTests/combined_json_generated_sources/exit new file mode 100644 index 000000000..c22708346 --- /dev/null +++ b/test/cmdlineTests/combined_json_generated_sources/exit @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/test/cmdlineTests/combined_json_generated_sources/input.sol b/test/cmdlineTests/combined_json_generated_sources/input.sol new file mode 100644 index 000000000..7fce7aa65 --- /dev/null +++ b/test/cmdlineTests/combined_json_generated_sources/input.sol @@ -0,0 +1,5 @@ +pragma experimental ABIEncoderV2; + +contract C { + function f(uint[] calldata) pure external {} +} \ No newline at end of file diff --git a/test/cmdlineTests/combined_json_generated_sources/output b/test/cmdlineTests/combined_json_generated_sources/output new file mode 100644 index 000000000..d93c81871 --- /dev/null +++ b/test/cmdlineTests/combined_json_generated_sources/output @@ -0,0 +1,735 @@ +{ + "contracts": + { + "combined_json_generated_sources/input.sol:C": + { + "generated-sources": [], + "generated-sources-runtime": + [ + { + "ast": + { + "nodeType": "YulBlock", + "src": "0:823:1", + "statements": + [ + { + "body": + { + "nodeType": "YulBlock", + "src": "114:277:1", + "statements": + [ + { + "body": + { + "nodeType": "YulBlock", + "src": "163:16:1", + "statements": + [ + { + "expression": + { + "arguments": + [ + { + "kind": "number", + "nodeType": "YulLiteral", + "src": "172:1:1", + "type": "", + "value": "0" + }, + { + "kind": "number", + "nodeType": "YulLiteral", + "src": "175:1:1", + "type": "", + "value": "0" + } + ], + "functionName": + { + "name": "revert", + "nodeType": "YulIdentifier", + "src": "165:6:1" + }, + "nodeType": "YulFunctionCall", + "src": "165:12:1" + }, + "nodeType": "YulExpressionStatement", + "src": "165:12:1" + } + ] + }, + "condition": + { + "arguments": + [ + { + "arguments": + [ + { + "arguments": + [ + { + "name": "offset", + "nodeType": "YulIdentifier", + "src": "142:6:1" + }, + { + "kind": "number", + "nodeType": "YulLiteral", + "src": "150:4:1", + "type": "", + "value": "0x1f" + } + ], + "functionName": + { + "name": "add", + "nodeType": "YulIdentifier", + "src": "138:3:1" + }, + "nodeType": "YulFunctionCall", + "src": "138:17:1" + }, + { + "name": "end", + "nodeType": "YulIdentifier", + "src": "157:3:1" + } + ], + "functionName": + { + "name": "slt", + "nodeType": "YulIdentifier", + "src": "134:3:1" + }, + "nodeType": "YulFunctionCall", + "src": "134:27:1" + } + ], + "functionName": + { + "name": "iszero", + "nodeType": "YulIdentifier", + "src": "127:6:1" + }, + "nodeType": "YulFunctionCall", + "src": "127:35:1" + }, + "nodeType": "YulIf", + "src": "124:2:1" + }, + { + "nodeType": "YulAssignment", + "src": "188:30:1", + "value": + { + "arguments": + [ + { + "name": "offset", + "nodeType": "YulIdentifier", + "src": "211:6:1" + } + ], + "functionName": + { + "name": "calldataload", + "nodeType": "YulIdentifier", + "src": "198:12:1" + }, + "nodeType": "YulFunctionCall", + "src": "198:20:1" + }, + "variableNames": + [ + { + "name": "length", + "nodeType": "YulIdentifier", + "src": "188:6:1" + } + ] + }, + { + "body": + { + "nodeType": "YulBlock", + "src": "261:16:1", + "statements": + [ + { + "expression": + { + "arguments": + [ + { + "kind": "number", + "nodeType": "YulLiteral", + "src": "270:1:1", + "type": "", + "value": "0" + }, + { + "kind": "number", + "nodeType": "YulLiteral", + "src": "273:1:1", + "type": "", + "value": "0" + } + ], + "functionName": + { + "name": "revert", + "nodeType": "YulIdentifier", + "src": "263:6:1" + }, + "nodeType": "YulFunctionCall", + "src": "263:12:1" + }, + "nodeType": "YulExpressionStatement", + "src": "263:12:1" + } + ] + }, + "condition": + { + "arguments": + [ + { + "name": "length", + "nodeType": "YulIdentifier", + "src": "233:6:1" + }, + { + "kind": "number", + "nodeType": "YulLiteral", + "src": "241:18:1", + "type": "", + "value": "0xffffffffffffffff" + } + ], + "functionName": + { + "name": "gt", + "nodeType": "YulIdentifier", + "src": "230:2:1" + }, + "nodeType": "YulFunctionCall", + "src": "230:30:1" + }, + "nodeType": "YulIf", + "src": "227:2:1" + }, + { + "nodeType": "YulAssignment", + "src": "286:29:1", + "value": + { + "arguments": + [ + { + "name": "offset", + "nodeType": "YulIdentifier", + "src": "302:6:1" + }, + { + "kind": "number", + "nodeType": "YulLiteral", + "src": "310:4:1", + "type": "", + "value": "0x20" + } + ], + "functionName": + { + "name": "add", + "nodeType": "YulIdentifier", + "src": "298:3:1" + }, + "nodeType": "YulFunctionCall", + "src": "298:17:1" + }, + "variableNames": + [ + { + "name": "arrayPos", + "nodeType": "YulIdentifier", + "src": "286:8:1" + } + ] + }, + { + "body": + { + "nodeType": "YulBlock", + "src": "369:16:1", + "statements": + [ + { + "expression": + { + "arguments": + [ + { + "kind": "number", + "nodeType": "YulLiteral", + "src": "378:1:1", + "type": "", + "value": "0" + }, + { + "kind": "number", + "nodeType": "YulLiteral", + "src": "381:1:1", + "type": "", + "value": "0" + } + ], + "functionName": + { + "name": "revert", + "nodeType": "YulIdentifier", + "src": "371:6:1" + }, + "nodeType": "YulFunctionCall", + "src": "371:12:1" + }, + "nodeType": "YulExpressionStatement", + "src": "371:12:1" + } + ] + }, + "condition": + { + "arguments": + [ + { + "arguments": + [ + { + "name": "arrayPos", + "nodeType": "YulIdentifier", + "src": "334:8:1" + }, + { + "arguments": + [ + { + "name": "length", + "nodeType": "YulIdentifier", + "src": "348:6:1" + }, + { + "kind": "number", + "nodeType": "YulLiteral", + "src": "356:4:1", + "type": "", + "value": "0x20" + } + ], + "functionName": + { + "name": "mul", + "nodeType": "YulIdentifier", + "src": "344:3:1" + }, + "nodeType": "YulFunctionCall", + "src": "344:17:1" + } + ], + "functionName": + { + "name": "add", + "nodeType": "YulIdentifier", + "src": "330:3:1" + }, + "nodeType": "YulFunctionCall", + "src": "330:32:1" + }, + { + "name": "end", + "nodeType": "YulIdentifier", + "src": "364:3:1" + } + ], + "functionName": + { + "name": "gt", + "nodeType": "YulIdentifier", + "src": "327:2:1" + }, + "nodeType": "YulFunctionCall", + "src": "327:41:1" + }, + "nodeType": "YulIf", + "src": "324:2:1" + } + ] + }, + "name": "abi_decode_t_array$_t_uint256_$dyn_calldata_ptr", + "nodeType": "YulFunctionDefinition", + "parameters": + [ + { + "name": "offset", + "nodeType": "YulTypedName", + "src": "81:6:1", + "type": "" + }, + { + "name": "end", + "nodeType": "YulTypedName", + "src": "89:3:1", + "type": "" + } + ], + "returnVariables": + [ + { + "name": "arrayPos", + "nodeType": "YulTypedName", + "src": "97:8:1", + "type": "" + }, + { + "name": "length", + "nodeType": "YulTypedName", + "src": "107:6:1", + "type": "" + } + ], + "src": "24:367:1" + }, + { + "body": + { + "nodeType": "YulBlock", + "src": "498:322:1", + "statements": + [ + { + "body": + { + "nodeType": "YulBlock", + "src": "544:16:1", + "statements": + [ + { + "expression": + { + "arguments": + [ + { + "kind": "number", + "nodeType": "YulLiteral", + "src": "553:1:1", + "type": "", + "value": "0" + }, + { + "kind": "number", + "nodeType": "YulLiteral", + "src": "556:1:1", + "type": "", + "value": "0" + } + ], + "functionName": + { + "name": "revert", + "nodeType": "YulIdentifier", + "src": "546:6:1" + }, + "nodeType": "YulFunctionCall", + "src": "546:12:1" + }, + "nodeType": "YulExpressionStatement", + "src": "546:12:1" + } + ] + }, + "condition": + { + "arguments": + [ + { + "arguments": + [ + { + "name": "dataEnd", + "nodeType": "YulIdentifier", + "src": "519:7:1" + }, + { + "name": "headStart", + "nodeType": "YulIdentifier", + "src": "528:9:1" + } + ], + "functionName": + { + "name": "sub", + "nodeType": "YulIdentifier", + "src": "515:3:1" + }, + "nodeType": "YulFunctionCall", + "src": "515:23:1" + }, + { + "kind": "number", + "nodeType": "YulLiteral", + "src": "540:2:1", + "type": "", + "value": "32" + } + ], + "functionName": + { + "name": "slt", + "nodeType": "YulIdentifier", + "src": "511:3:1" + }, + "nodeType": "YulFunctionCall", + "src": "511:32:1" + }, + "nodeType": "YulIf", + "src": "508:2:1" + }, + { + "nodeType": "YulBlock", + "src": "570:243:1", + "statements": + [ + { + "nodeType": "YulVariableDeclaration", + "src": "584:45:1", + "value": + { + "arguments": + [ + { + "arguments": + [ + { + "name": "headStart", + "nodeType": "YulIdentifier", + "src": "615:9:1" + }, + { + "kind": "number", + "nodeType": "YulLiteral", + "src": "626:1:1", + "type": "", + "value": "0" + } + ], + "functionName": + { + "name": "add", + "nodeType": "YulIdentifier", + "src": "611:3:1" + }, + "nodeType": "YulFunctionCall", + "src": "611:17:1" + } + ], + "functionName": + { + "name": "calldataload", + "nodeType": "YulIdentifier", + "src": "598:12:1" + }, + "nodeType": "YulFunctionCall", + "src": "598:31:1" + }, + "variables": + [ + { + "name": "offset", + "nodeType": "YulTypedName", + "src": "588:6:1", + "type": "" + } + ] + }, + { + "body": + { + "nodeType": "YulBlock", + "src": "676:16:1", + "statements": + [ + { + "expression": + { + "arguments": + [ + { + "kind": "number", + "nodeType": "YulLiteral", + "src": "685:1:1", + "type": "", + "value": "0" + }, + { + "kind": "number", + "nodeType": "YulLiteral", + "src": "688:1:1", + "type": "", + "value": "0" + } + ], + "functionName": + { + "name": "revert", + "nodeType": "YulIdentifier", + "src": "678:6:1" + }, + "nodeType": "YulFunctionCall", + "src": "678:12:1" + }, + "nodeType": "YulExpressionStatement", + "src": "678:12:1" + } + ] + }, + "condition": + { + "arguments": + [ + { + "name": "offset", + "nodeType": "YulIdentifier", + "src": "648:6:1" + }, + { + "kind": "number", + "nodeType": "YulLiteral", + "src": "656:18:1", + "type": "", + "value": "0xffffffffffffffff" + } + ], + "functionName": + { + "name": "gt", + "nodeType": "YulIdentifier", + "src": "645:2:1" + }, + "nodeType": "YulFunctionCall", + "src": "645:30:1" + }, + "nodeType": "YulIf", + "src": "642:2:1" + }, + { + "nodeType": "YulAssignment", + "src": "705:98:1", + "value": + { + "arguments": + [ + { + "arguments": + [ + { + "name": "headStart", + "nodeType": "YulIdentifier", + "src": "775:9:1" + }, + { + "name": "offset", + "nodeType": "YulIdentifier", + "src": "786:6:1" + } + ], + "functionName": + { + "name": "add", + "nodeType": "YulIdentifier", + "src": "771:3:1" + }, + "nodeType": "YulFunctionCall", + "src": "771:22:1" + }, + { + "name": "dataEnd", + "nodeType": "YulIdentifier", + "src": "795:7:1" + } + ], + "functionName": + { + "name": "abi_decode_t_array$_t_uint256_$dyn_calldata_ptr", + "nodeType": "YulIdentifier", + "src": "723:47:1" + }, + "nodeType": "YulFunctionCall", + "src": "723:80:1" + }, + "variableNames": + [ + { + "name": "value0", + "nodeType": "YulIdentifier", + "src": "705:6:1" + }, + { + "name": "value1", + "nodeType": "YulIdentifier", + "src": "713:6:1" + } + ] + } + ] + } + ] + }, + "name": "abi_decode_tuple_t_array$_t_uint256_$dyn_calldata_ptr", + "nodeType": "YulFunctionDefinition", + "parameters": + [ + { + "name": "headStart", + "nodeType": "YulTypedName", + "src": "460:9:1", + "type": "" + }, + { + "name": "dataEnd", + "nodeType": "YulTypedName", + "src": "471:7:1", + "type": "" + } + ], + "returnVariables": + [ + { + "name": "value0", + "nodeType": "YulTypedName", + "src": "483:6:1", + "type": "" + }, + { + "name": "value1", + "nodeType": "YulTypedName", + "src": "491:6:1", + "type": "" + } + ], + "src": "397:423:1" + } + ] + }, + "contents": "{\n\n // uint256[]\n function abi_decode_t_array$_t_uint256_$dyn_calldata_ptr(offset, end) -> arrayPos, length {\n if iszero(slt(add(offset, 0x1f), end)) { revert(0, 0) }\n length := calldataload(offset)\n if gt(length, 0xffffffffffffffff) { revert(0, 0) }\n arrayPos := add(offset, 0x20)\n if gt(add(arrayPos, mul(length, 0x20)), end) { revert(0, 0) }\n }\n\n function abi_decode_tuple_t_array$_t_uint256_$dyn_calldata_ptr(headStart, dataEnd) -> value0, value1 {\n if slt(sub(dataEnd, headStart), 32) { revert(0, 0) }\n\n {\n let offset := calldataload(add(headStart, 0))\n if gt(offset, 0xffffffffffffffff) { revert(0, 0) }\n value0, value1 := abi_decode_t_array$_t_uint256_$dyn_calldata_ptr(add(headStart, offset), dataEnd)\n }\n\n }\n\n}\n", + "id": 1, + "language": "Yul", + "name": "#utility.yul" + } + ] + } + }, + "version": "VERSION REMOVED" +} diff --git a/test/cmdlineTests/output_selection_all_A1/output.json b/test/cmdlineTests/output_selection_all_A1/output.json index 1e4a0b11f..9f0cfa596 100644 --- a/test/cmdlineTests/output_selection_all_A1/output.json +++ b/test/cmdlineTests/output_selection_all_A1/output.json @@ -1,4 +1,4 @@ -{"contracts":{"a.sol":{"A1":{"evm":{"bytecode":{"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}}}},"b.sol":{"A1":{"evm":{"bytecode":{"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}}}}},"errors":[{"component":"general","errorCode":"3420","formattedMessage":"a.sol: Warning: Source file does not specify required compiler version! +{"contracts":{"a.sol":{"A1":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}}}},"b.sol":{"A1":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}}}}},"errors":[{"component":"general","errorCode":"3420","formattedMessage":"a.sol: Warning: Source file does not specify required compiler version! ","message":"Source file does not specify required compiler version!","severity":"warning","sourceLocation":{"end":-1,"file":"a.sol","start":-1},"type":"Warning"},{"component":"general","errorCode":"3420","formattedMessage":"b.sol: Warning: Source file does not specify required compiler version! ","message":"Source file does not specify required compiler version!","severity":"warning","sourceLocation":{"end":-1,"file":"b.sol","start":-1},"type":"Warning"},{"component":"general","errorCode":"2018","formattedMessage":"b.sol:2:15: Warning: Function state mutability can be restricted to pure contract A1 { function b(uint x) public { assert(x > 0); } } contract B2 { function b(uint x) public pure { assert(x > 0); } } diff --git a/test/cmdlineTests/output_selection_all_A2/output.json b/test/cmdlineTests/output_selection_all_A2/output.json index 5b0b55bbf..ae00e3485 100644 --- a/test/cmdlineTests/output_selection_all_A2/output.json +++ b/test/cmdlineTests/output_selection_all_A2/output.json @@ -1,4 +1,4 @@ -{"contracts":{"a.sol":{"A2":{"evm":{"bytecode":{"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}}}}},"errors":[{"component":"general","errorCode":"3420","formattedMessage":"a.sol: Warning: Source file does not specify required compiler version! +{"contracts":{"a.sol":{"A2":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}}}}},"errors":[{"component":"general","errorCode":"3420","formattedMessage":"a.sol: Warning: Source file does not specify required compiler version! ","message":"Source file does not specify required compiler version!","severity":"warning","sourceLocation":{"end":-1,"file":"a.sol","start":-1},"type":"Warning"},{"component":"general","errorCode":"3420","formattedMessage":"b.sol: Warning: Source file does not specify required compiler version! ","message":"Source file does not specify required compiler version!","severity":"warning","sourceLocation":{"end":-1,"file":"b.sol","start":-1},"type":"Warning"},{"component":"general","errorCode":"2018","formattedMessage":"b.sol:2:15: Warning: Function state mutability can be restricted to pure contract A1 { function b(uint x) public { assert(x > 0); } } contract B2 { function b(uint x) public pure { assert(x > 0); } } diff --git a/test/cmdlineTests/output_selection_all_star/output.json b/test/cmdlineTests/output_selection_all_star/output.json index d885876d9..64653e63f 100644 --- a/test/cmdlineTests/output_selection_all_star/output.json +++ b/test/cmdlineTests/output_selection_all_star/output.json @@ -1,4 +1,4 @@ -{"contracts":{"a.sol":{"A1":{"evm":{"bytecode":{"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}}},"A2":{"evm":{"bytecode":{"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}}}},"b.sol":{"A1":{"evm":{"bytecode":{"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}}},"B2":{"evm":{"bytecode":{"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}}}}},"errors":[{"component":"general","errorCode":"3420","formattedMessage":"a.sol: Warning: Source file does not specify required compiler version! +{"contracts":{"a.sol":{"A1":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}}},"A2":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}}}},"b.sol":{"A1":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}}},"B2":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}}}}},"errors":[{"component":"general","errorCode":"3420","formattedMessage":"a.sol: Warning: Source file does not specify required compiler version! ","message":"Source file does not specify required compiler version!","severity":"warning","sourceLocation":{"end":-1,"file":"a.sol","start":-1},"type":"Warning"},{"component":"general","errorCode":"3420","formattedMessage":"b.sol: Warning: Source file does not specify required compiler version! ","message":"Source file does not specify required compiler version!","severity":"warning","sourceLocation":{"end":-1,"file":"b.sol","start":-1},"type":"Warning"},{"component":"general","errorCode":"2018","formattedMessage":"b.sol:2:15: Warning: Function state mutability can be restricted to pure contract A1 { function b(uint x) public { assert(x > 0); } } contract B2 { function b(uint x) public pure { assert(x > 0); } } diff --git a/test/cmdlineTests/output_selection_single_A1/output.json b/test/cmdlineTests/output_selection_single_A1/output.json index b32b519dd..e29036fde 100644 --- a/test/cmdlineTests/output_selection_single_A1/output.json +++ b/test/cmdlineTests/output_selection_single_A1/output.json @@ -1,2 +1,2 @@ -{"contracts":{"a.sol":{"A1":{"evm":{"bytecode":{"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}}}}},"errors":[{"component":"general","errorCode":"3420","formattedMessage":"a.sol: Warning: Source file does not specify required compiler version! +{"contracts":{"a.sol":{"A1":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}}}}},"errors":[{"component":"general","errorCode":"3420","formattedMessage":"a.sol: Warning: Source file does not specify required compiler version! ","message":"Source file does not specify required compiler version!","severity":"warning","sourceLocation":{"end":-1,"file":"a.sol","start":-1},"type":"Warning"}],"sources":{"a.sol":{"id":0},"b.sol":{"id":1}}} diff --git a/test/cmdlineTests/output_selection_single_B1/output.json b/test/cmdlineTests/output_selection_single_B1/output.json index aeb29d7ae..9915b12ab 100644 --- a/test/cmdlineTests/output_selection_single_B1/output.json +++ b/test/cmdlineTests/output_selection_single_B1/output.json @@ -1,4 +1,4 @@ -{"contracts":{"b.sol":{"B2":{"evm":{"bytecode":{"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}}}}},"errors":[{"component":"general","errorCode":"3420","formattedMessage":"b.sol: Warning: Source file does not specify required compiler version! +{"contracts":{"b.sol":{"B2":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}}}}},"errors":[{"component":"general","errorCode":"3420","formattedMessage":"b.sol: Warning: Source file does not specify required compiler version! ","message":"Source file does not specify required compiler version!","severity":"warning","sourceLocation":{"end":-1,"file":"b.sol","start":-1},"type":"Warning"},{"component":"general","errorCode":"2018","formattedMessage":"b.sol:2:15: Warning: Function state mutability can be restricted to pure contract A1 { function b(uint x) public { assert(x > 0); } } contract B2 { function b(uint x) public pure { assert(x > 0); } } ^------------------------------------------^ diff --git a/test/cmdlineTests/output_selection_single_all/output.json b/test/cmdlineTests/output_selection_single_all/output.json index 07b1a5453..f98685b2e 100644 --- a/test/cmdlineTests/output_selection_single_all/output.json +++ b/test/cmdlineTests/output_selection_single_all/output.json @@ -1,2 +1,2 @@ -{"contracts":{"a.sol":{"A1":{"evm":{"bytecode":{"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}}},"A2":{"evm":{"bytecode":{"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}}}}},"errors":[{"component":"general","errorCode":"3420","formattedMessage":"a.sol: Warning: Source file does not specify required compiler version! +{"contracts":{"a.sol":{"A1":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}}},"A2":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}}}}},"errors":[{"component":"general","errorCode":"3420","formattedMessage":"a.sol: Warning: Source file does not specify required compiler version! ","message":"Source file does not specify required compiler version!","severity":"warning","sourceLocation":{"end":-1,"file":"a.sol","start":-1},"type":"Warning"}],"sources":{"a.sol":{"id":0},"b.sol":{"id":1}}} diff --git a/test/cmdlineTests/standard_generatedSources/input.json b/test/cmdlineTests/standard_generatedSources/input.json new file mode 100644 index 000000000..75537c4fb --- /dev/null +++ b/test/cmdlineTests/standard_generatedSources/input.json @@ -0,0 +1,20 @@ +{ + "language": "Solidity", + "sources": { + "a.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma experimental ABIEncoderV2; contract A { function f(uint[] memory) public view returns (uint256) { } }" + } + }, + "settings": { + "evmVersion": "petersburg", + "outputSelection": { + "*": { + "A": [ + "evm.bytecode.object", + "evm.deployedBytecode.generatedSources", + "evm.bytecode.generatedSources" + ] + } + } + } +} diff --git a/test/cmdlineTests/standard_generatedSources/output.json b/test/cmdlineTests/standard_generatedSources/output.json new file mode 100644 index 000000000..2cd4b057b --- /dev/null +++ b/test/cmdlineTests/standard_generatedSources/output.json @@ -0,0 +1,77 @@ +{"contracts":{"a.sol":{"A":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"},"deployedBytecode":{"generatedSources":[{"ast":{"nodeType":"YulBlock","src":"0:2499:1","statements":[{"body":{"nodeType":"YulBlock","src":"101:684:1","statements":[{"body":{"nodeType":"YulBlock","src":"150:16:1","statements":[{"expression":{"arguments":[{"kind":"number","nodeType":"YulLiteral","src":"159:1:1","type":"","value":"0"},{"kind":"number","nodeType":"YulLiteral","src":"162:1:1","type":"","value":"0"}],"functionName":{"name":"revert","nodeType":"YulIdentifier","src":"152:6:1"},"nodeType":"YulFunctionCall","src":"152:12:1"},"nodeType":"YulExpressionStatement","src":"152:12:1"}]},"condition":{"arguments":[{"arguments":[{"arguments":[{"name":"offset","nodeType":"YulIdentifier","src":"129:6:1"},{"kind":"number","nodeType":"YulLiteral","src":"137:4:1","type":"","value":"0x1f"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"125:3:1"},"nodeType":"YulFunctionCall","src":"125:17:1"},{"name":"end","nodeType":"YulIdentifier","src":"144:3:1"}],"functionName":{"name":"slt","nodeType":"YulIdentifier","src":"121:3:1"},"nodeType":"YulFunctionCall","src":"121:27:1"}],"functionName":{"name":"iszero","nodeType":"YulIdentifier","src":"114:6:1"},"nodeType":"YulFunctionCall","src":"114:35:1"},"nodeType":"YulIf","src":"111:2:1"},{"nodeType":"YulVariableDeclaration","src":"175:34:1","value":{"arguments":[{"name":"offset","nodeType":"YulIdentifier","src":"202:6:1"}],"functionName":{"name":"calldataload","nodeType":"YulIdentifier","src":"189:12:1"},"nodeType":"YulFunctionCall","src":"189:20:1"},"variables":[{"name":"length","nodeType":"YulTypedName","src":"179:6:1","type":""}]},{"nodeType":"YulAssignment","src":"218:89:1","value":{"arguments":[{"arguments":[{"name":"length","nodeType":"YulIdentifier","src":"299:6:1"}],"functionName":{"name":"array_allocation_size_t_array$_t_uint256_$dyn_memory_ptr","nodeType":"YulIdentifier","src":"242:56:1"},"nodeType":"YulFunctionCall","src":"242:64:1"}],"functionName":{"name":"allocateMemory","nodeType":"YulIdentifier","src":"227:14:1"},"nodeType":"YulFunctionCall","src":"227:80:1"},"variableNames":[{"name":"array","nodeType":"YulIdentifier","src":"218:5:1"}]},{"nodeType":"YulVariableDeclaration","src":"316:16:1","value":{"name":"array","nodeType":"YulIdentifier","src":"327:5:1"},"variables":[{"name":"dst","nodeType":"YulTypedName","src":"320:3:1","type":""}]},{"expression":{"arguments":[{"name":"array","nodeType":"YulIdentifier","src":"348:5:1"},{"name":"length","nodeType":"YulIdentifier","src":"355:6:1"}],"functionName":{"name":"mstore","nodeType":"YulIdentifier","src":"341:6:1"},"nodeType":"YulFunctionCall","src":"341:21:1"},"nodeType":"YulExpressionStatement","src":"341:21:1"},{"nodeType":"YulAssignment","src":"363:27:1","value":{"arguments":[{"name":"offset","nodeType":"YulIdentifier","src":"377:6:1"},{"kind":"number","nodeType":"YulLiteral","src":"385:4:1","type":"","value":"0x20"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"373:3:1"},"nodeType":"YulFunctionCall","src":"373:17:1"},"variableNames":[{"name":"offset","nodeType":"YulIdentifier","src":"363:6:1"}]},{"nodeType":"YulAssignment","src":"391:21:1","value":{"arguments":[{"name":"dst","nodeType":"YulIdentifier","src":"402:3:1"},{"kind":"number","nodeType":"YulLiteral","src":"407:4:1","type":"","value":"0x20"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"398:3:1"},"nodeType":"YulFunctionCall","src":"398:14:1"},"variableNames":[{"name":"dst","nodeType":"YulIdentifier","src":"391:3:1"}]},{"nodeType":"YulVariableDeclaration","src":"452:17:1","value":{"name":"offset","nodeType":"YulIdentifier","src":"463:6:1"},"variables":[{"name":"src","nodeType":"YulTypedName","src":"456:3:1","type":""}]},{"body":{"nodeType":"YulBlock","src":"518:16:1","statements":[{"expression":{"arguments":[{"kind":"number","nodeType":"YulLiteral","src":"527:1:1","type":"","value":"0"},{"kind":"number","nodeType":"YulLiteral","src":"530:1:1","type":"","value":"0"}],"functionName":{"name":"revert","nodeType":"YulIdentifier","src":"520:6:1"},"nodeType":"YulFunctionCall","src":"520:12:1"},"nodeType":"YulExpressionStatement","src":"520:12:1"}]},"condition":{"arguments":[{"arguments":[{"name":"src","nodeType":"YulIdentifier","src":"488:3:1"},{"arguments":[{"name":"length","nodeType":"YulIdentifier","src":"497:6:1"},{"kind":"number","nodeType":"YulLiteral","src":"505:4:1","type":"","value":"0x20"}],"functionName":{"name":"mul","nodeType":"YulIdentifier","src":"493:3:1"},"nodeType":"YulFunctionCall","src":"493:17:1"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"484:3:1"},"nodeType":"YulFunctionCall","src":"484:27:1"},{"name":"end","nodeType":"YulIdentifier","src":"513:3:1"}],"functionName":{"name":"gt","nodeType":"YulIdentifier","src":"481:2:1"},"nodeType":"YulFunctionCall","src":"481:36:1"},"nodeType":"YulIf","src":"478:2:1"},{"body":{"nodeType":"YulBlock","src":"603:176:1","statements":[{"nodeType":"YulVariableDeclaration","src":"617:21:1","value":{"name":"src","nodeType":"YulIdentifier","src":"635:3:1"},"variables":[{"name":"elementPos","nodeType":"YulTypedName","src":"621:10:1","type":""}]},{"expression":{"arguments":[{"name":"dst","nodeType":"YulIdentifier","src":"658:3:1"},{"arguments":[{"name":"elementPos","nodeType":"YulIdentifier","src":"684:10:1"},{"name":"end","nodeType":"YulIdentifier","src":"696:3:1"}],"functionName":{"name":"abi_decode_t_uint256","nodeType":"YulIdentifier","src":"663:20:1"},"nodeType":"YulFunctionCall","src":"663:37:1"}],"functionName":{"name":"mstore","nodeType":"YulIdentifier","src":"651:6:1"},"nodeType":"YulFunctionCall","src":"651:50:1"},"nodeType":"YulExpressionStatement","src":"651:50:1"},{"nodeType":"YulAssignment","src":"714:21:1","value":{"arguments":[{"name":"dst","nodeType":"YulIdentifier","src":"725:3:1"},{"kind":"number","nodeType":"YulLiteral","src":"730:4:1","type":"","value":"0x20"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"721:3:1"},"nodeType":"YulFunctionCall","src":"721:14:1"},"variableNames":[{"name":"dst","nodeType":"YulIdentifier","src":"714:3:1"}]},{"nodeType":"YulAssignment","src":"748:21:1","value":{"arguments":[{"name":"src","nodeType":"YulIdentifier","src":"759:3:1"},{"kind":"number","nodeType":"YulLiteral","src":"764:4:1","type":"","value":"0x20"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"755:3:1"},"nodeType":"YulFunctionCall","src":"755:14:1"},"variableNames":[{"name":"src","nodeType":"YulIdentifier","src":"748:3:1"}]}]},"condition":{"arguments":[{"name":"i","nodeType":"YulIdentifier","src":"565:1:1"},{"name":"length","nodeType":"YulIdentifier","src":"568:6:1"}],"functionName":{"name":"lt","nodeType":"YulIdentifier","src":"562:2:1"},"nodeType":"YulFunctionCall","src":"562:13:1"},"nodeType":"YulForLoop","post":{"nodeType":"YulBlock","src":"576:18:1","statements":[{"nodeType":"YulAssignment","src":"578:14:1","value":{"arguments":[{"name":"i","nodeType":"YulIdentifier","src":"587:1:1"},{"kind":"number","nodeType":"YulLiteral","src":"590:1:1","type":"","value":"1"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"583:3:1"},"nodeType":"YulFunctionCall","src":"583:9:1"},"variableNames":[{"name":"i","nodeType":"YulIdentifier","src":"578:1:1"}]}]},"pre":{"nodeType":"YulBlock","src":"547:14:1","statements":[{"nodeType":"YulVariableDeclaration","src":"549:10:1","value":{"kind":"number","nodeType":"YulLiteral","src":"558:1:1","type":"","value":"0"},"variables":[{"name":"i","nodeType":"YulTypedName","src":"553:1:1","type":""}]}]},"src":"543:236:1"}]},"name":"abi_decode_t_array$_t_uint256_$dyn_memory_ptr","nodeType":"YulFunctionDefinition","parameters":[{"name":"offset","nodeType":"YulTypedName","src":"79:6:1","type":""},{"name":"end","nodeType":"YulTypedName","src":"87:3:1","type":""}],"returnVariables":[{"name":"array","nodeType":"YulTypedName","src":"95:5:1","type":""}],"src":"24:761:1"},{"body":{"nodeType":"YulBlock","src":"843:87:1","statements":[{"nodeType":"YulAssignment","src":"853:29:1","value":{"arguments":[{"name":"offset","nodeType":"YulIdentifier","src":"875:6:1"}],"functionName":{"name":"calldataload","nodeType":"YulIdentifier","src":"862:12:1"},"nodeType":"YulFunctionCall","src":"862:20:1"},"variableNames":[{"name":"value","nodeType":"YulIdentifier","src":"853:5:1"}]},{"expression":{"arguments":[{"name":"value","nodeType":"YulIdentifier","src":"918:5:1"}],"functionName":{"name":"validator_revert_t_uint256","nodeType":"YulIdentifier","src":"891:26:1"},"nodeType":"YulFunctionCall","src":"891:33:1"},"nodeType":"YulExpressionStatement","src":"891:33:1"}]},"name":"abi_decode_t_uint256","nodeType":"YulFunctionDefinition","parameters":[{"name":"offset","nodeType":"YulTypedName","src":"821:6:1","type":""},{"name":"end","nodeType":"YulTypedName","src":"829:3:1","type":""}],"returnVariables":[{"name":"value","nodeType":"YulTypedName","src":"837:5:1","type":""}],"src":"791:139:1"},{"body":{"nodeType":"YulBlock","src":"1027:312:1","statements":[{"body":{"nodeType":"YulBlock","src":"1073:16:1","statements":[{"expression":{"arguments":[{"kind":"number","nodeType":"YulLiteral","src":"1082:1:1","type":"","value":"0"},{"kind":"number","nodeType":"YulLiteral","src":"1085:1:1","type":"","value":"0"}],"functionName":{"name":"revert","nodeType":"YulIdentifier","src":"1075:6:1"},"nodeType":"YulFunctionCall","src":"1075:12:1"},"nodeType":"YulExpressionStatement","src":"1075:12:1"}]},"condition":{"arguments":[{"arguments":[{"name":"dataEnd","nodeType":"YulIdentifier","src":"1048:7:1"},{"name":"headStart","nodeType":"YulIdentifier","src":"1057:9:1"}],"functionName":{"name":"sub","nodeType":"YulIdentifier","src":"1044:3:1"},"nodeType":"YulFunctionCall","src":"1044:23:1"},{"kind":"number","nodeType":"YulLiteral","src":"1069:2:1","type":"","value":"32"}],"functionName":{"name":"slt","nodeType":"YulIdentifier","src":"1040:3:1"},"nodeType":"YulFunctionCall","src":"1040:32:1"},"nodeType":"YulIf","src":"1037:2:1"},{"nodeType":"YulBlock","src":"1099:233:1","statements":[{"nodeType":"YulVariableDeclaration","src":"1113:45:1","value":{"arguments":[{"arguments":[{"name":"headStart","nodeType":"YulIdentifier","src":"1144:9:1"},{"kind":"number","nodeType":"YulLiteral","src":"1155:1:1","type":"","value":"0"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"1140:3:1"},"nodeType":"YulFunctionCall","src":"1140:17:1"}],"functionName":{"name":"calldataload","nodeType":"YulIdentifier","src":"1127:12:1"},"nodeType":"YulFunctionCall","src":"1127:31:1"},"variables":[{"name":"offset","nodeType":"YulTypedName","src":"1117:6:1","type":""}]},{"body":{"nodeType":"YulBlock","src":"1205:16:1","statements":[{"expression":{"arguments":[{"kind":"number","nodeType":"YulLiteral","src":"1214:1:1","type":"","value":"0"},{"kind":"number","nodeType":"YulLiteral","src":"1217:1:1","type":"","value":"0"}],"functionName":{"name":"revert","nodeType":"YulIdentifier","src":"1207:6:1"},"nodeType":"YulFunctionCall","src":"1207:12:1"},"nodeType":"YulExpressionStatement","src":"1207:12:1"}]},"condition":{"arguments":[{"name":"offset","nodeType":"YulIdentifier","src":"1177:6:1"},{"kind":"number","nodeType":"YulLiteral","src":"1185:18:1","type":"","value":"0xffffffffffffffff"}],"functionName":{"name":"gt","nodeType":"YulIdentifier","src":"1174:2:1"},"nodeType":"YulFunctionCall","src":"1174:30:1"},"nodeType":"YulIf","src":"1171:2:1"},{"nodeType":"YulAssignment","src":"1234:88:1","value":{"arguments":[{"arguments":[{"name":"headStart","nodeType":"YulIdentifier","src":"1294:9:1"},{"name":"offset","nodeType":"YulIdentifier","src":"1305:6:1"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"1290:3:1"},"nodeType":"YulFunctionCall","src":"1290:22:1"},{"name":"dataEnd","nodeType":"YulIdentifier","src":"1314:7:1"}],"functionName":{"name":"abi_decode_t_array$_t_uint256_$dyn_memory_ptr","nodeType":"YulIdentifier","src":"1244:45:1"},"nodeType":"YulFunctionCall","src":"1244:78:1"},"variableNames":[{"name":"value0","nodeType":"YulIdentifier","src":"1234:6:1"}]}]}]},"name":"abi_decode_tuple_t_array$_t_uint256_$dyn_memory_ptr","nodeType":"YulFunctionDefinition","parameters":[{"name":"headStart","nodeType":"YulTypedName","src":"997:9:1","type":""},{"name":"dataEnd","nodeType":"YulTypedName","src":"1008:7:1","type":""}],"returnVariables":[{"name":"value0","nodeType":"YulTypedName","src":"1020:6:1","type":""}],"src":"936:403:1"},{"body":{"nodeType":"YulBlock","src":"1410:53:1","statements":[{"expression":{"arguments":[{"name":"pos","nodeType":"YulIdentifier","src":"1427:3:1"},{"arguments":[{"name":"value","nodeType":"YulIdentifier","src":"1450:5:1"}],"functionName":{"name":"cleanup_t_uint256","nodeType":"YulIdentifier","src":"1432:17:1"},"nodeType":"YulFunctionCall","src":"1432:24:1"}],"functionName":{"name":"mstore","nodeType":"YulIdentifier","src":"1420:6:1"},"nodeType":"YulFunctionCall","src":"1420:37:1"},"nodeType":"YulExpressionStatement","src":"1420:37:1"}]},"name":"abi_encode_t_uint256_to_t_uint256_fromStack","nodeType":"YulFunctionDefinition","parameters":[{"name":"value","nodeType":"YulTypedName","src":"1398:5:1","type":""},{"name":"pos","nodeType":"YulTypedName","src":"1405:3:1","type":""}],"src":"1345:118:1"},{"body":{"nodeType":"YulBlock","src":"1567:124:1","statements":[{"nodeType":"YulAssignment","src":"1577:26:1","value":{"arguments":[{"name":"headStart","nodeType":"YulIdentifier","src":"1589:9:1"},{"kind":"number","nodeType":"YulLiteral","src":"1600:2:1","type":"","value":"32"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"1585:3:1"},"nodeType":"YulFunctionCall","src":"1585:18:1"},"variableNames":[{"name":"tail","nodeType":"YulIdentifier","src":"1577:4:1"}]},{"expression":{"arguments":[{"name":"value0","nodeType":"YulIdentifier","src":"1657:6:1"},{"arguments":[{"name":"headStart","nodeType":"YulIdentifier","src":"1670:9:1"},{"kind":"number","nodeType":"YulLiteral","src":"1681:1:1","type":"","value":"0"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"1666:3:1"},"nodeType":"YulFunctionCall","src":"1666:17:1"}],"functionName":{"name":"abi_encode_t_uint256_to_t_uint256_fromStack","nodeType":"YulIdentifier","src":"1613:43:1"},"nodeType":"YulFunctionCall","src":"1613:71:1"},"nodeType":"YulExpressionStatement","src":"1613:71:1"}]},"name":"abi_encode_tuple_t_uint256__to_t_uint256__fromStack_reversed","nodeType":"YulFunctionDefinition","parameters":[{"name":"headStart","nodeType":"YulTypedName","src":"1539:9:1","type":""},{"name":"value0","nodeType":"YulTypedName","src":"1551:6:1","type":""}],"returnVariables":[{"name":"tail","nodeType":"YulTypedName","src":"1562:4:1","type":""}],"src":"1469:222:1"},{"body":{"nodeType":"YulBlock","src":"1737:237:1","statements":[{"nodeType":"YulAssignment","src":"1747:19:1","value":{"arguments":[{"kind":"number","nodeType":"YulLiteral","src":"1763:2:1","type":"","value":"64"}],"functionName":{"name":"mload","nodeType":"YulIdentifier","src":"1757:5:1"},"nodeType":"YulFunctionCall","src":"1757:9:1"},"variableNames":[{"name":"memPtr","nodeType":"YulIdentifier","src":"1747:6:1"}]},{"nodeType":"YulVariableDeclaration","src":"1775:35:1","value":{"arguments":[{"name":"memPtr","nodeType":"YulIdentifier","src":"1797:6:1"},{"name":"size","nodeType":"YulIdentifier","src":"1805:4:1"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"1793:3:1"},"nodeType":"YulFunctionCall","src":"1793:17:1"},"variables":[{"name":"newFreePtr","nodeType":"YulTypedName","src":"1779:10:1","type":""}]},{"body":{"nodeType":"YulBlock","src":"1921:16:1","statements":[{"expression":{"arguments":[{"kind":"number","nodeType":"YulLiteral","src":"1930:1:1","type":"","value":"0"},{"kind":"number","nodeType":"YulLiteral","src":"1933:1:1","type":"","value":"0"}],"functionName":{"name":"revert","nodeType":"YulIdentifier","src":"1923:6:1"},"nodeType":"YulFunctionCall","src":"1923:12:1"},"nodeType":"YulExpressionStatement","src":"1923:12:1"}]},"condition":{"arguments":[{"arguments":[{"name":"newFreePtr","nodeType":"YulIdentifier","src":"1864:10:1"},{"kind":"number","nodeType":"YulLiteral","src":"1876:18:1","type":"","value":"0xffffffffffffffff"}],"functionName":{"name":"gt","nodeType":"YulIdentifier","src":"1861:2:1"},"nodeType":"YulFunctionCall","src":"1861:34:1"},{"arguments":[{"name":"newFreePtr","nodeType":"YulIdentifier","src":"1900:10:1"},{"name":"memPtr","nodeType":"YulIdentifier","src":"1912:6:1"}],"functionName":{"name":"lt","nodeType":"YulIdentifier","src":"1897:2:1"},"nodeType":"YulFunctionCall","src":"1897:22:1"}],"functionName":{"name":"or","nodeType":"YulIdentifier","src":"1858:2:1"},"nodeType":"YulFunctionCall","src":"1858:62:1"},"nodeType":"YulIf","src":"1855:2:1"},{"expression":{"arguments":[{"kind":"number","nodeType":"YulLiteral","src":"1953:2:1","type":"","value":"64"},{"name":"newFreePtr","nodeType":"YulIdentifier","src":"1957:10:1"}],"functionName":{"name":"mstore","nodeType":"YulIdentifier","src":"1946:6:1"},"nodeType":"YulFunctionCall","src":"1946:22:1"},"nodeType":"YulExpressionStatement","src":"1946:22:1"}]},"name":"allocateMemory","nodeType":"YulFunctionDefinition","parameters":[{"name":"size","nodeType":"YulTypedName","src":"1721:4:1","type":""}],"returnVariables":[{"name":"memPtr","nodeType":"YulTypedName","src":"1730:6:1","type":""}],"src":"1697:277:1"},{"body":{"nodeType":"YulBlock","src":"2062:223:1","statements":[{"body":{"nodeType":"YulBlock","src":"2167:16:1","statements":[{"expression":{"arguments":[{"kind":"number","nodeType":"YulLiteral","src":"2176:1:1","type":"","value":"0"},{"kind":"number","nodeType":"YulLiteral","src":"2179:1:1","type":"","value":"0"}],"functionName":{"name":"revert","nodeType":"YulIdentifier","src":"2169:6:1"},"nodeType":"YulFunctionCall","src":"2169:12:1"},"nodeType":"YulExpressionStatement","src":"2169:12:1"}]},"condition":{"arguments":[{"name":"length","nodeType":"YulIdentifier","src":"2139:6:1"},{"kind":"number","nodeType":"YulLiteral","src":"2147:18:1","type":"","value":"0xffffffffffffffff"}],"functionName":{"name":"gt","nodeType":"YulIdentifier","src":"2136:2:1"},"nodeType":"YulFunctionCall","src":"2136:30:1"},"nodeType":"YulIf","src":"2133:2:1"},{"nodeType":"YulAssignment","src":"2193:25:1","value":{"arguments":[{"name":"length","nodeType":"YulIdentifier","src":"2205:6:1"},{"kind":"number","nodeType":"YulLiteral","src":"2213:4:1","type":"","value":"0x20"}],"functionName":{"name":"mul","nodeType":"YulIdentifier","src":"2201:3:1"},"nodeType":"YulFunctionCall","src":"2201:17:1"},"variableNames":[{"name":"size","nodeType":"YulIdentifier","src":"2193:4:1"}]},{"nodeType":"YulAssignment","src":"2255:23:1","value":{"arguments":[{"name":"size","nodeType":"YulIdentifier","src":"2267:4:1"},{"kind":"number","nodeType":"YulLiteral","src":"2273:4:1","type":"","value":"0x20"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"2263:3:1"},"nodeType":"YulFunctionCall","src":"2263:15:1"},"variableNames":[{"name":"size","nodeType":"YulIdentifier","src":"2255:4:1"}]}]},"name":"array_allocation_size_t_array$_t_uint256_$dyn_memory_ptr","nodeType":"YulFunctionDefinition","parameters":[{"name":"length","nodeType":"YulTypedName","src":"2046:6:1","type":""}],"returnVariables":[{"name":"size","nodeType":"YulTypedName","src":"2057:4:1","type":""}],"src":"1980:305:1"},{"body":{"nodeType":"YulBlock","src":"2336:32:1","statements":[{"nodeType":"YulAssignment","src":"2346:16:1","value":{"name":"value","nodeType":"YulIdentifier","src":"2357:5:1"},"variableNames":[{"name":"cleaned","nodeType":"YulIdentifier","src":"2346:7:1"}]}]},"name":"cleanup_t_uint256","nodeType":"YulFunctionDefinition","parameters":[{"name":"value","nodeType":"YulTypedName","src":"2318:5:1","type":""}],"returnVariables":[{"name":"cleaned","nodeType":"YulTypedName","src":"2328:7:1","type":""}],"src":"2291:77:1"},{"body":{"nodeType":"YulBlock","src":"2417:79:1","statements":[{"body":{"nodeType":"YulBlock","src":"2474:16:1","statements":[{"expression":{"arguments":[{"kind":"number","nodeType":"YulLiteral","src":"2483:1:1","type":"","value":"0"},{"kind":"number","nodeType":"YulLiteral","src":"2486:1:1","type":"","value":"0"}],"functionName":{"name":"revert","nodeType":"YulIdentifier","src":"2476:6:1"},"nodeType":"YulFunctionCall","src":"2476:12:1"},"nodeType":"YulExpressionStatement","src":"2476:12:1"}]},"condition":{"arguments":[{"arguments":[{"name":"value","nodeType":"YulIdentifier","src":"2440:5:1"},{"arguments":[{"name":"value","nodeType":"YulIdentifier","src":"2465:5:1"}],"functionName":{"name":"cleanup_t_uint256","nodeType":"YulIdentifier","src":"2447:17:1"},"nodeType":"YulFunctionCall","src":"2447:24:1"}],"functionName":{"name":"eq","nodeType":"YulIdentifier","src":"2437:2:1"},"nodeType":"YulFunctionCall","src":"2437:35:1"}],"functionName":{"name":"iszero","nodeType":"YulIdentifier","src":"2430:6:1"},"nodeType":"YulFunctionCall","src":"2430:43:1"},"nodeType":"YulIf","src":"2427:2:1"}]},"name":"validator_revert_t_uint256","nodeType":"YulFunctionDefinition","parameters":[{"name":"value","nodeType":"YulTypedName","src":"2410:5:1","type":""}],"src":"2374:122:1"}]},"contents":"{ + + // uint256[] + function abi_decode_t_array$_t_uint256_$dyn_memory_ptr(offset, end) -> array { + if iszero(slt(add(offset, 0x1f), end)) { revert(0, 0) } + let length := calldataload(offset) + array := allocateMemory(array_allocation_size_t_array$_t_uint256_$dyn_memory_ptr(length)) + let dst := array + mstore(array, length) offset := add(offset, 0x20) dst := add(dst, 0x20) // might update offset and dst + let src := offset + if gt(add(src, mul(length, 0x20)), end) { revert(0, 0) } + for { let i := 0 } lt(i, length) { i := add(i, 1) } + { + let elementPos := src + mstore(dst, abi_decode_t_uint256(elementPos, end)) + dst := add(dst, 0x20) + src := add(src, 0x20) + } + } + + function abi_decode_t_uint256(offset, end) -> value { + value := calldataload(offset) + validator_revert_t_uint256(value) + } + + function abi_decode_tuple_t_array$_t_uint256_$dyn_memory_ptr(headStart, dataEnd) -> value0 { + if slt(sub(dataEnd, headStart), 32) { revert(0, 0) } + + { + let offset := calldataload(add(headStart, 0)) + if gt(offset, 0xffffffffffffffff) { revert(0, 0) } + value0 := abi_decode_t_array$_t_uint256_$dyn_memory_ptr(add(headStart, offset), dataEnd) + } + + } + + function abi_encode_t_uint256_to_t_uint256_fromStack(value, pos) { + mstore(pos, cleanup_t_uint256(value)) + } + + function abi_encode_tuple_t_uint256__to_t_uint256__fromStack_reversed(headStart , value0) -> tail { + tail := add(headStart, 32) + + abi_encode_t_uint256_to_t_uint256_fromStack(value0, add(headStart, 0)) + + } + + function allocateMemory(size) -> memPtr { + memPtr := mload(64) + let newFreePtr := add(memPtr, size) + // protect against overflow + if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { revert(0, 0) } + mstore(64, newFreePtr) + } + + function array_allocation_size_t_array$_t_uint256_$dyn_memory_ptr(length) -> size { + // Make sure we can allocate memory without overflow + if gt(length, 0xffffffffffffffff) { revert(0, 0) } + + size := mul(length, 0x20) + + // add length slot + size := add(size, 0x20) + + } + + function cleanup_t_uint256(value) -> cleaned { + cleaned := value + } + + function validator_revert_t_uint256(value) { + if iszero(eq(value, cleanup_t_uint256(value))) { revert(0, 0) } + } + +} +","id":1,"language":"Yul","name":"#utility.yul"}],"immutableReferences":{},"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"70:74:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;83:59;;;;;;;;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;;130:7;83:59;;;:::o;24:761:1:-;;144:3;137:4;129:6;125:17;121:27;111:2;;162:1;159;152:12;111:2;202:6;189:20;227:80;242:64;299:6;242:64;:::i;:::-;227:80;:::i;:::-;218:89;;327:5;355:6;348:5;341:21;385:4;377:6;373:17;363:27;;407:4;402:3;398:14;391:21;;463:6;513:3;505:4;497:6;493:17;488:3;484:27;481:36;478:2;;;530:1;527;520:12;478:2;558:1;543:236;568:6;565:1;562:13;543:236;;;635:3;663:37;696:3;684:10;663:37;:::i;:::-;658:3;651:50;730:4;725:3;721:14;714:21;;764:4;759:3;755:14;748:21;;603:176;590:1;587;583:9;578:14;;543:236;;;547:14;101:684;;;;;;;:::o;791:139::-;;875:6;862:20;853:29;;891:33;918:5;891:33;:::i;:::-;843:87;;;;:::o;936:403::-;;1069:2;1057:9;1048:7;1044:23;1040:32;1037:2;;;1085:1;1082;1075:12;1037:2;1155:1;1144:9;1140:17;1127:31;1185:18;1177:6;1174:30;1171:2;;;1217:1;1214;1207:12;1171:2;1244:78;1314:7;1305:6;1294:9;1290:22;1244:78;:::i;:::-;1234:88;;1099:233;1027:312;;;;:::o;1345:118::-;1432:24;1450:5;1432:24;:::i;:::-;1427:3;1420:37;1410:53;;:::o;1469:222::-;;1600:2;1589:9;1585:18;1577:26;;1613:71;1681:1;1670:9;1666:17;1657:6;1613:71;:::i;:::-;1567:124;;;;:::o;1697:277::-;;1763:2;1757:9;1747:19;;1805:4;1797:6;1793:17;1912:6;1900:10;1897:22;1876:18;1864:10;1861:34;1858:62;1855:2;;;1933:1;1930;1923:12;1855:2;1957:10;1953:2;1946:22;1737:237;;;;:::o;1980:305::-;;2147:18;2139:6;2136:30;2133:2;;;2179:1;2176;2169:12;2133:2;2213:4;2205:6;2201:17;2193:25;;2273:4;2267;2263:15;2255:23;;2062:223;;;:::o;2291:77::-;;2357:5;2346:16;;2336:32;;;:::o;2374:122::-;2447:24;2465:5;2447:24;:::i;:::-;2440:5;2437:35;2427:2;;2486:1;2483;2476:12;2427:2;2417:79;:::o"}}}}},"errors":[{"component":"general","errorCode":"3420","formattedMessage":"a.sol: Warning: Source file does not specify required compiler version! +","message":"Source file does not specify required compiler version!","severity":"warning","sourceLocation":{"end":-1,"file":"a.sol","start":-1},"type":"Warning"}],"sources":{"a.sol":{"id":0}}} diff --git a/test/cmdlineTests/standard_immutable_references/output.json b/test/cmdlineTests/standard_immutable_references/output.json index 48376adc5..2f935a12d 100644 --- a/test/cmdlineTests/standard_immutable_references/output.json +++ b/test/cmdlineTests/standard_immutable_references/output.json @@ -1,2 +1,2 @@ -{"contracts":{"a.sol":{"A":{"evm":{"deployedBytecode":{"immutableReferences":{"3":[{"length":32,"start":77}]},"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"36:96:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;74:56;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;108:7;126:1;119:8;;74:56;:::o"}}}}},"errors":[{"component":"general","errorCode":"3420","formattedMessage":"a.sol: Warning: Source file does not specify required compiler version! +{"contracts":{"a.sol":{"A":{"evm":{"deployedBytecode":{"generatedSources":[],"immutableReferences":{"3":[{"length":32,"start":77}]},"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"36:96:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;74:56;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;108:7;126:1;119:8;;74:56;:::o"}}}}},"errors":[{"component":"general","errorCode":"3420","formattedMessage":"a.sol: Warning: Source file does not specify required compiler version! ","message":"Source file does not specify required compiler version!","severity":"warning","sourceLocation":{"end":-1,"file":"a.sol","start":-1},"type":"Warning"}],"sources":{"a.sol":{"id":0}}} diff --git a/test/cmdlineTests/standard_optimizer_generatedSources/input.json b/test/cmdlineTests/standard_optimizer_generatedSources/input.json new file mode 100644 index 000000000..f3682dd28 --- /dev/null +++ b/test/cmdlineTests/standard_optimizer_generatedSources/input.json @@ -0,0 +1,21 @@ +{ + "language": "Solidity", + "sources": { + "a.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma experimental ABIEncoderV2; contract A { function f(uint[] memory) public view returns (uint256) { } }" + } + }, + "settings": { + "evmVersion": "petersburg", + "optimizer": { "enabled": true }, + "outputSelection": { + "*": { + "A": [ + "evm.bytecode.object", + "evm.deployedBytecode.generatedSources", + "evm.bytecode.generatedSources" + ] + } + } + } +} diff --git a/test/cmdlineTests/standard_optimizer_generatedSources/output.json b/test/cmdlineTests/standard_optimizer_generatedSources/output.json new file mode 100644 index 000000000..6a6e976a9 --- /dev/null +++ b/test/cmdlineTests/standard_optimizer_generatedSources/output.json @@ -0,0 +1,43 @@ +{"contracts":{"a.sol":{"A":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"},"deployedBytecode":{"generatedSources":[{"ast":{"nodeType":"YulBlock","src":"0:1474:1","statements":[{"nodeType":"YulBlock","src":"6:3:1","statements":[]},{"body":{"nodeType":"YulBlock","src":"109:931:1","statements":[{"nodeType":"YulVariableDeclaration","src":"119:12:1","value":{"kind":"number","nodeType":"YulLiteral","src":"129:2:1","type":"","value":"32"},"variables":[{"name":"_1","nodeType":"YulTypedName","src":"123:2:1","type":""}]},{"body":{"nodeType":"YulBlock","src":"176:26:1","statements":[{"expression":{"arguments":[{"name":"value0","nodeType":"YulIdentifier","src":"185:6:1"},{"name":"value0","nodeType":"YulIdentifier","src":"193:6:1"}],"functionName":{"name":"revert","nodeType":"YulIdentifier","src":"178:6:1"},"nodeType":"YulFunctionCall","src":"178:22:1"},"nodeType":"YulExpressionStatement","src":"178:22:1"}]},"condition":{"arguments":[{"arguments":[{"name":"dataEnd","nodeType":"YulIdentifier","src":"151:7:1"},{"name":"headStart","nodeType":"YulIdentifier","src":"160:9:1"}],"functionName":{"name":"sub","nodeType":"YulIdentifier","src":"147:3:1"},"nodeType":"YulFunctionCall","src":"147:23:1"},{"name":"_1","nodeType":"YulIdentifier","src":"172:2:1"}],"functionName":{"name":"slt","nodeType":"YulIdentifier","src":"143:3:1"},"nodeType":"YulFunctionCall","src":"143:32:1"},"nodeType":"YulIf","src":"140:2:1"},{"nodeType":"YulVariableDeclaration","src":"211:37:1","value":{"arguments":[{"name":"headStart","nodeType":"YulIdentifier","src":"238:9:1"}],"functionName":{"name":"calldataload","nodeType":"YulIdentifier","src":"225:12:1"},"nodeType":"YulFunctionCall","src":"225:23:1"},"variables":[{"name":"offset","nodeType":"YulTypedName","src":"215:6:1","type":""}]},{"nodeType":"YulVariableDeclaration","src":"257:28:1","value":{"kind":"number","nodeType":"YulLiteral","src":"267:18:1","type":"","value":"0xffffffffffffffff"},"variables":[{"name":"_2","nodeType":"YulTypedName","src":"261:2:1","type":""}]},{"body":{"nodeType":"YulBlock","src":"312:26:1","statements":[{"expression":{"arguments":[{"name":"value0","nodeType":"YulIdentifier","src":"321:6:1"},{"name":"value0","nodeType":"YulIdentifier","src":"329:6:1"}],"functionName":{"name":"revert","nodeType":"YulIdentifier","src":"314:6:1"},"nodeType":"YulFunctionCall","src":"314:22:1"},"nodeType":"YulExpressionStatement","src":"314:22:1"}]},"condition":{"arguments":[{"name":"offset","nodeType":"YulIdentifier","src":"300:6:1"},{"name":"_2","nodeType":"YulIdentifier","src":"308:2:1"}],"functionName":{"name":"gt","nodeType":"YulIdentifier","src":"297:2:1"},"nodeType":"YulFunctionCall","src":"297:14:1"},"nodeType":"YulIf","src":"294:2:1"},{"nodeType":"YulVariableDeclaration","src":"347:32:1","value":{"arguments":[{"name":"headStart","nodeType":"YulIdentifier","src":"361:9:1"},{"name":"offset","nodeType":"YulIdentifier","src":"372:6:1"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"357:3:1"},"nodeType":"YulFunctionCall","src":"357:22:1"},"variables":[{"name":"_3","nodeType":"YulTypedName","src":"351:2:1","type":""}]},{"body":{"nodeType":"YulBlock","src":"427:26:1","statements":[{"expression":{"arguments":[{"name":"value0","nodeType":"YulIdentifier","src":"436:6:1"},{"name":"value0","nodeType":"YulIdentifier","src":"444:6:1"}],"functionName":{"name":"revert","nodeType":"YulIdentifier","src":"429:6:1"},"nodeType":"YulFunctionCall","src":"429:22:1"},"nodeType":"YulExpressionStatement","src":"429:22:1"}]},"condition":{"arguments":[{"arguments":[{"arguments":[{"name":"_3","nodeType":"YulIdentifier","src":"406:2:1"},{"kind":"number","nodeType":"YulLiteral","src":"410:4:1","type":"","value":"0x1f"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"402:3:1"},"nodeType":"YulFunctionCall","src":"402:13:1"},{"name":"dataEnd","nodeType":"YulIdentifier","src":"417:7:1"}],"functionName":{"name":"slt","nodeType":"YulIdentifier","src":"398:3:1"},"nodeType":"YulFunctionCall","src":"398:27:1"}],"functionName":{"name":"iszero","nodeType":"YulIdentifier","src":"391:6:1"},"nodeType":"YulFunctionCall","src":"391:35:1"},"nodeType":"YulIf","src":"388:2:1"},{"nodeType":"YulVariableDeclaration","src":"462:30:1","value":{"arguments":[{"name":"_3","nodeType":"YulIdentifier","src":"489:2:1"}],"functionName":{"name":"calldataload","nodeType":"YulIdentifier","src":"476:12:1"},"nodeType":"YulFunctionCall","src":"476:16:1"},"variables":[{"name":"length","nodeType":"YulTypedName","src":"466:6:1","type":""}]},{"body":{"nodeType":"YulBlock","src":"519:26:1","statements":[{"expression":{"arguments":[{"name":"value0","nodeType":"YulIdentifier","src":"528:6:1"},{"name":"value0","nodeType":"YulIdentifier","src":"536:6:1"}],"functionName":{"name":"revert","nodeType":"YulIdentifier","src":"521:6:1"},"nodeType":"YulFunctionCall","src":"521:22:1"},"nodeType":"YulExpressionStatement","src":"521:22:1"}]},"condition":{"arguments":[{"name":"length","nodeType":"YulIdentifier","src":"507:6:1"},{"name":"_2","nodeType":"YulIdentifier","src":"515:2:1"}],"functionName":{"name":"gt","nodeType":"YulIdentifier","src":"504:2:1"},"nodeType":"YulFunctionCall","src":"504:14:1"},"nodeType":"YulIf","src":"501:2:1"},{"nodeType":"YulVariableDeclaration","src":"554:25:1","value":{"arguments":[{"name":"length","nodeType":"YulIdentifier","src":"568:6:1"},{"name":"_1","nodeType":"YulIdentifier","src":"576:2:1"}],"functionName":{"name":"mul","nodeType":"YulIdentifier","src":"564:3:1"},"nodeType":"YulFunctionCall","src":"564:15:1"},"variables":[{"name":"_4","nodeType":"YulTypedName","src":"558:2:1","type":""}]},{"nodeType":"YulVariableDeclaration","src":"588:38:1","value":{"arguments":[{"arguments":[{"name":"_4","nodeType":"YulIdentifier","src":"618:2:1"},{"name":"_1","nodeType":"YulIdentifier","src":"622:2:1"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"614:3:1"},"nodeType":"YulFunctionCall","src":"614:11:1"}],"functionName":{"name":"allocateMemory","nodeType":"YulIdentifier","src":"599:14:1"},"nodeType":"YulFunctionCall","src":"599:27:1"},"variables":[{"name":"dst","nodeType":"YulTypedName","src":"592:3:1","type":""}]},{"nodeType":"YulVariableDeclaration","src":"635:16:1","value":{"name":"dst","nodeType":"YulIdentifier","src":"648:3:1"},"variables":[{"name":"dst_1","nodeType":"YulTypedName","src":"639:5:1","type":""}]},{"expression":{"arguments":[{"name":"dst","nodeType":"YulIdentifier","src":"667:3:1"},{"name":"length","nodeType":"YulIdentifier","src":"672:6:1"}],"functionName":{"name":"mstore","nodeType":"YulIdentifier","src":"660:6:1"},"nodeType":"YulFunctionCall","src":"660:19:1"},"nodeType":"YulExpressionStatement","src":"660:19:1"},{"nodeType":"YulAssignment","src":"688:19:1","value":{"arguments":[{"name":"dst","nodeType":"YulIdentifier","src":"699:3:1"},{"name":"_1","nodeType":"YulIdentifier","src":"704:2:1"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"695:3:1"},"nodeType":"YulFunctionCall","src":"695:12:1"},"variableNames":[{"name":"dst","nodeType":"YulIdentifier","src":"688:3:1"}]},{"nodeType":"YulVariableDeclaration","src":"716:22:1","value":{"arguments":[{"name":"_3","nodeType":"YulIdentifier","src":"731:2:1"},{"name":"_1","nodeType":"YulIdentifier","src":"735:2:1"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"727:3:1"},"nodeType":"YulFunctionCall","src":"727:11:1"},"variables":[{"name":"src","nodeType":"YulTypedName","src":"720:3:1","type":""}]},{"body":{"nodeType":"YulBlock","src":"784:26:1","statements":[{"expression":{"arguments":[{"name":"value0","nodeType":"YulIdentifier","src":"793:6:1"},{"name":"value0","nodeType":"YulIdentifier","src":"801:6:1"}],"functionName":{"name":"revert","nodeType":"YulIdentifier","src":"786:6:1"},"nodeType":"YulFunctionCall","src":"786:22:1"},"nodeType":"YulExpressionStatement","src":"786:22:1"}]},"condition":{"arguments":[{"arguments":[{"arguments":[{"name":"_3","nodeType":"YulIdentifier","src":"761:2:1"},{"name":"_4","nodeType":"YulIdentifier","src":"765:2:1"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"757:3:1"},"nodeType":"YulFunctionCall","src":"757:11:1"},{"name":"_1","nodeType":"YulIdentifier","src":"770:2:1"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"753:3:1"},"nodeType":"YulFunctionCall","src":"753:20:1"},{"name":"dataEnd","nodeType":"YulIdentifier","src":"775:7:1"}],"functionName":{"name":"gt","nodeType":"YulIdentifier","src":"750:2:1"},"nodeType":"YulFunctionCall","src":"750:33:1"},"nodeType":"YulIf","src":"747:2:1"},{"nodeType":"YulVariableDeclaration","src":"819:15:1","value":{"name":"value0","nodeType":"YulIdentifier","src":"828:6:1"},"variables":[{"name":"i","nodeType":"YulTypedName","src":"823:1:1","type":""}]},{"body":{"nodeType":"YulBlock","src":"892:118:1","statements":[{"expression":{"arguments":[{"name":"dst","nodeType":"YulIdentifier","src":"913:3:1"},{"arguments":[{"name":"src","nodeType":"YulIdentifier","src":"931:3:1"}],"functionName":{"name":"calldataload","nodeType":"YulIdentifier","src":"918:12:1"},"nodeType":"YulFunctionCall","src":"918:17:1"}],"functionName":{"name":"mstore","nodeType":"YulIdentifier","src":"906:6:1"},"nodeType":"YulFunctionCall","src":"906:30:1"},"nodeType":"YulExpressionStatement","src":"906:30:1"},{"nodeType":"YulAssignment","src":"949:19:1","value":{"arguments":[{"name":"dst","nodeType":"YulIdentifier","src":"960:3:1"},{"name":"_1","nodeType":"YulIdentifier","src":"965:2:1"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"956:3:1"},"nodeType":"YulFunctionCall","src":"956:12:1"},"variableNames":[{"name":"dst","nodeType":"YulIdentifier","src":"949:3:1"}]},{"nodeType":"YulAssignment","src":"981:19:1","value":{"arguments":[{"name":"src","nodeType":"YulIdentifier","src":"992:3:1"},{"name":"_1","nodeType":"YulIdentifier","src":"997:2:1"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"988:3:1"},"nodeType":"YulFunctionCall","src":"988:12:1"},"variableNames":[{"name":"src","nodeType":"YulIdentifier","src":"981:3:1"}]}]},"condition":{"arguments":[{"name":"i","nodeType":"YulIdentifier","src":"854:1:1"},{"name":"length","nodeType":"YulIdentifier","src":"857:6:1"}],"functionName":{"name":"lt","nodeType":"YulIdentifier","src":"851:2:1"},"nodeType":"YulFunctionCall","src":"851:13:1"},"nodeType":"YulForLoop","post":{"nodeType":"YulBlock","src":"865:18:1","statements":[{"nodeType":"YulAssignment","src":"867:14:1","value":{"arguments":[{"name":"i","nodeType":"YulIdentifier","src":"876:1:1"},{"kind":"number","nodeType":"YulLiteral","src":"879:1:1","type":"","value":"1"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"872:3:1"},"nodeType":"YulFunctionCall","src":"872:9:1"},"variableNames":[{"name":"i","nodeType":"YulIdentifier","src":"867:1:1"}]}]},"pre":{"nodeType":"YulBlock","src":"847:3:1","statements":[]},"src":"843:167:1"},{"nodeType":"YulAssignment","src":"1019:15:1","value":{"name":"dst_1","nodeType":"YulIdentifier","src":"1029:5:1"},"variableNames":[{"name":"value0","nodeType":"YulIdentifier","src":"1019:6:1"}]}]},"name":"abi_decode_tuple_t_array$_t_uint256_$dyn_memory_ptr","nodeType":"YulFunctionDefinition","parameters":[{"name":"headStart","nodeType":"YulTypedName","src":"75:9:1","type":""},{"name":"dataEnd","nodeType":"YulTypedName","src":"86:7:1","type":""}],"returnVariables":[{"name":"value0","nodeType":"YulTypedName","src":"98:6:1","type":""}],"src":"14:1026:1"},{"body":{"nodeType":"YulBlock","src":"1146:76:1","statements":[{"nodeType":"YulAssignment","src":"1156:26:1","value":{"arguments":[{"name":"headStart","nodeType":"YulIdentifier","src":"1168:9:1"},{"kind":"number","nodeType":"YulLiteral","src":"1179:2:1","type":"","value":"32"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"1164:3:1"},"nodeType":"YulFunctionCall","src":"1164:18:1"},"variableNames":[{"name":"tail","nodeType":"YulIdentifier","src":"1156:4:1"}]},{"expression":{"arguments":[{"name":"headStart","nodeType":"YulIdentifier","src":"1198:9:1"},{"name":"value0","nodeType":"YulIdentifier","src":"1209:6:1"}],"functionName":{"name":"mstore","nodeType":"YulIdentifier","src":"1191:6:1"},"nodeType":"YulFunctionCall","src":"1191:25:1"},"nodeType":"YulExpressionStatement","src":"1191:25:1"}]},"name":"abi_encode_tuple_t_uint256__to_t_uint256__fromStack_reversed","nodeType":"YulFunctionDefinition","parameters":[{"name":"headStart","nodeType":"YulTypedName","src":"1115:9:1","type":""},{"name":"value0","nodeType":"YulTypedName","src":"1126:6:1","type":""}],"returnVariables":[{"name":"tail","nodeType":"YulTypedName","src":"1137:4:1","type":""}],"src":"1045:177:1"},{"body":{"nodeType":"YulBlock","src":"1271:201:1","statements":[{"nodeType":"YulAssignment","src":"1281:19:1","value":{"arguments":[{"kind":"number","nodeType":"YulLiteral","src":"1297:2:1","type":"","value":"64"}],"functionName":{"name":"mload","nodeType":"YulIdentifier","src":"1291:5:1"},"nodeType":"YulFunctionCall","src":"1291:9:1"},"variableNames":[{"name":"memPtr","nodeType":"YulIdentifier","src":"1281:6:1"}]},{"nodeType":"YulVariableDeclaration","src":"1309:35:1","value":{"arguments":[{"name":"memPtr","nodeType":"YulIdentifier","src":"1331:6:1"},{"name":"size","nodeType":"YulIdentifier","src":"1339:4:1"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"1327:3:1"},"nodeType":"YulFunctionCall","src":"1327:17:1"},"variables":[{"name":"newFreePtr","nodeType":"YulTypedName","src":"1313:10:1","type":""}]},{"body":{"nodeType":"YulBlock","src":"1419:16:1","statements":[{"expression":{"arguments":[{"kind":"number","nodeType":"YulLiteral","src":"1428:1:1","type":"","value":"0"},{"kind":"number","nodeType":"YulLiteral","src":"1431:1:1","type":"","value":"0"}],"functionName":{"name":"revert","nodeType":"YulIdentifier","src":"1421:6:1"},"nodeType":"YulFunctionCall","src":"1421:12:1"},"nodeType":"YulExpressionStatement","src":"1421:12:1"}]},"condition":{"arguments":[{"arguments":[{"name":"newFreePtr","nodeType":"YulIdentifier","src":"1362:10:1"},{"kind":"number","nodeType":"YulLiteral","src":"1374:18:1","type":"","value":"0xffffffffffffffff"}],"functionName":{"name":"gt","nodeType":"YulIdentifier","src":"1359:2:1"},"nodeType":"YulFunctionCall","src":"1359:34:1"},{"arguments":[{"name":"newFreePtr","nodeType":"YulIdentifier","src":"1398:10:1"},{"name":"memPtr","nodeType":"YulIdentifier","src":"1410:6:1"}],"functionName":{"name":"lt","nodeType":"YulIdentifier","src":"1395:2:1"},"nodeType":"YulFunctionCall","src":"1395:22:1"}],"functionName":{"name":"or","nodeType":"YulIdentifier","src":"1356:2:1"},"nodeType":"YulFunctionCall","src":"1356:62:1"},"nodeType":"YulIf","src":"1353:2:1"},{"expression":{"arguments":[{"kind":"number","nodeType":"YulLiteral","src":"1451:2:1","type":"","value":"64"},{"name":"newFreePtr","nodeType":"YulIdentifier","src":"1455:10:1"}],"functionName":{"name":"mstore","nodeType":"YulIdentifier","src":"1444:6:1"},"nodeType":"YulFunctionCall","src":"1444:22:1"},"nodeType":"YulExpressionStatement","src":"1444:22:1"}]},"name":"allocateMemory","nodeType":"YulFunctionDefinition","parameters":[{"name":"size","nodeType":"YulTypedName","src":"1251:4:1","type":""}],"returnVariables":[{"name":"memPtr","nodeType":"YulTypedName","src":"1260:6:1","type":""}],"src":"1227:245:1"}]},"contents":"{ + { } + function abi_decode_tuple_t_array$_t_uint256_$dyn_memory_ptr(headStart, dataEnd) -> value0 + { + let _1 := 32 + if slt(sub(dataEnd, headStart), _1) { revert(value0, value0) } + let offset := calldataload(headStart) + let _2 := 0xffffffffffffffff + if gt(offset, _2) { revert(value0, value0) } + let _3 := add(headStart, offset) + if iszero(slt(add(_3, 0x1f), dataEnd)) { revert(value0, value0) } + let length := calldataload(_3) + if gt(length, _2) { revert(value0, value0) } + let _4 := mul(length, _1) + let dst := allocateMemory(add(_4, _1)) + let dst_1 := dst + mstore(dst, length) + dst := add(dst, _1) + let src := add(_3, _1) + if gt(add(add(_3, _4), _1), dataEnd) { revert(value0, value0) } + let i := value0 + for { } lt(i, length) { i := add(i, 1) } + { + mstore(dst, calldataload(src)) + dst := add(dst, _1) + src := add(src, _1) + } + value0 := dst_1 + } + function abi_encode_tuple_t_uint256__to_t_uint256__fromStack_reversed(headStart, value0) -> tail + { + tail := add(headStart, 32) + mstore(headStart, value0) + } + function allocateMemory(size) -> memPtr + { + memPtr := mload(64) + let newFreePtr := add(memPtr, size) + if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { revert(0, 0) } + mstore(64, newFreePtr) + } +}","id":1,"language":"Yul","name":"#utility.yul"}],"immutableReferences":{},"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"70:74:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;83:59;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;;-1:-1:-1;130:7:0;;83:59::o;14:1026:1:-;;129:2;172;160:9;151:7;147:23;143:32;140:2;;;193:6;185;178:22;140:2;238:9;225:23;267:18;308:2;300:6;297:14;294:2;;;329:6;321;314:22;294:2;372:6;361:9;357:22;347:32;;417:7;410:4;406:2;402:13;398:27;388:2;;444:6;436;429:22;388:2;489;476:16;515:2;507:6;504:14;501:2;;;536:6;528;521:22;501:2;576;568:6;564:15;554:25;;599:27;622:2;618;614:11;599:27;:::i;:::-;660:19;;;695:12;;;;727:11;;;757;;;753:20;;750:33;-1:-1:-1;747:2:1;;;801:6;793;786:22;747:2;828:6;819:15;;843:167;857:6;854:1;851:13;843:167;;;918:17;;906:30;;879:1;872:9;;;;;956:12;;;;988;;843:167;;;-1:-1:-1;1029:5:1;109:931;-1:-1:-1;;;;;;;;109:931:1:o;1045:177::-;1191:25;;;1179:2;1164:18;;1146:76::o;1227:245::-;1297:2;1291:9;1327:17;;;1374:18;1359:34;;1395:22;;;1356:62;1353:2;;;1431:1;1428;1421:12;1353:2;1451;1444:22;1271:201;;-1:-1:-1;1271:201:1:o"}}}}},"errors":[{"component":"general","errorCode":"3420","formattedMessage":"a.sol: Warning: Source file does not specify required compiler version! +","message":"Source file does not specify required compiler version!","severity":"warning","sourceLocation":{"end":-1,"file":"a.sol","start":-1},"type":"Warning"}],"sources":{"a.sol":{"id":0}}} diff --git a/test/cmdlineTests/standard_yul/output.json b/test/cmdlineTests/standard_yul/output.json index ac6c8f7cb..3b048f04e 100644 --- a/test/cmdlineTests/standard_yul/output.json +++ b/test/cmdlineTests/standard_yul/output.json @@ -14,7 +14,7 @@ sstore /* \"A\":0:42 */ pop -","bytecode":{"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}},"ir":"object \"object\" { +","bytecode":{"generatedSources":[],"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}},"ir":"object \"object\" { code { let x := mload(0) sstore(add(x, 0), 0) diff --git a/test/cmdlineTests/standard_yul_object/output.json b/test/cmdlineTests/standard_yul_object/output.json index 946e5773b..4e770527b 100644 --- a/test/cmdlineTests/standard_yul_object/output.json +++ b/test/cmdlineTests/standard_yul_object/output.json @@ -13,7 +13,7 @@ pop stop data_4e03657aea45a94fc7d47ba826c8d667c0d1e6e33a64a036ec44f58fa12d6c45 616263 -","bytecode":{"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}},"ir":"object \"NamedObject\" { +","bytecode":{"generatedSources":[],"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}},"ir":"object \"NamedObject\" { code { let x := dataoffset(\"DataName\") sstore(add(x, 0), 0) diff --git a/test/cmdlineTests/standard_yul_object_name/output.json b/test/cmdlineTests/standard_yul_object_name/output.json index 58d78b3a9..e23e4a7af 100644 --- a/test/cmdlineTests/standard_yul_object_name/output.json +++ b/test/cmdlineTests/standard_yul_object_name/output.json @@ -22,7 +22,7 @@ sub_0: assembly { /* \"A\":137:149 */ revert } -","bytecode":{"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"},"deployedBytecode":{"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}},"ir":"object \"NamedObject\" { +","bytecode":{"generatedSources":[],"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"},"deployedBytecode":{"generatedSources":[],"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}},"ir":"object \"NamedObject\" { code { let x := dataoffset(\"DataName\") sstore(add(x, 0), 0) diff --git a/test/cmdlineTests/standard_yul_optimiserSteps/output.json b/test/cmdlineTests/standard_yul_optimiserSteps/output.json index 383ad8557..6a1ac3d40 100644 --- a/test/cmdlineTests/standard_yul_optimiserSteps/output.json +++ b/test/cmdlineTests/standard_yul_optimiserSteps/output.json @@ -13,7 +13,7 @@ /* \"A\":20:40 */ sstore pop -","bytecode":{"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}},"ir":"object \"object\" { +","bytecode":{"generatedSources":[],"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}},"ir":"object \"object\" { code { let x := mload(0) sstore(add(x, 0), 0) diff --git a/test/cmdlineTests/standard_yul_optimized/output.json b/test/cmdlineTests/standard_yul_optimized/output.json index 532ff00d9..962d92a32 100644 --- a/test/cmdlineTests/standard_yul_optimized/output.json +++ b/test/cmdlineTests/standard_yul_optimized/output.json @@ -5,7 +5,7 @@ mload /* \"A\":20:40 */ sstore -","bytecode":{"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}},"ir":"object \"object\" { +","bytecode":{"generatedSources":[],"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}},"ir":"object \"object\" { code { let x := mload(0) sstore(add(x, 0), 0)