From d7532f7b9c33cd191f400e9af34f4f06a4aef0fa Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Thu, 26 Oct 2017 17:56:00 -0300 Subject: Convert static SourceReferenceFormatter functions to member ones --- solc/CommandLineInterface.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'solc/CommandLineInterface.cpp') diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index adcfee9c..8383afed 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -777,7 +777,10 @@ bool CommandLineInterface::processInput() } m_compiler.reset(new CompilerStack(fileReader)); + auto scannerFromSourceName = [&](string const& _sourceName) -> solidity::Scanner const& { return m_compiler->scanner(_sourceName); }; + SourceReferenceFormatter formatter(cerr, scannerFromSourceName); + try { if (m_args.count(g_argMetadataLiteral) > 0) @@ -796,11 +799,9 @@ bool CommandLineInterface::processInput() bool successful = m_compiler->compile(); for (auto const& error: m_compiler->errors()) - SourceReferenceFormatter::printExceptionInformation( - cerr, + formatter.printExceptionInformation( *error, - (error->type() == Error::Type::Warning) ? "Warning" : "Error", - scannerFromSourceName + (error->type() == Error::Type::Warning) ? "Warning" : "Error" ); if (!successful) @@ -808,7 +809,7 @@ bool CommandLineInterface::processInput() } catch (CompilerError const& _exception) { - SourceReferenceFormatter::printExceptionInformation(cerr, _exception, "Compiler error", scannerFromSourceName); + formatter.printExceptionInformation(_exception, "Compiler error"); return false; } catch (InternalCompilerError const& _exception) @@ -828,7 +829,7 @@ bool CommandLineInterface::processInput() if (_error.type() == Error::Type::DocstringParsingError) cerr << "Documentation parsing error: " << *boost::get_error_info(_error) << endl; else - SourceReferenceFormatter::printExceptionInformation(cerr, _error, _error.typeName(), scannerFromSourceName); + formatter.printExceptionInformation(_error, _error.typeName()); return false; } @@ -1086,15 +1087,17 @@ bool CommandLineInterface::assemble( return false; } } + for (auto const& sourceAndStack: assemblyStacks) { auto const& stack = sourceAndStack.second; + auto scannerFromSourceName = [&](string const&) -> Scanner const& { return stack.scanner(); }; + SourceReferenceFormatter formatter(cerr, scannerFromSourceName); + for (auto const& error: stack.errors()) - SourceReferenceFormatter::printExceptionInformation( - cerr, + formatter.printExceptionInformation( *error, - (error->type() == Error::Type::Warning) ? "Warning" : "Error", - [&](string const&) -> Scanner const& { return stack.scanner(); } + (error->type() == Error::Type::Warning) ? "Warning" : "Error" ); if (!Error::containsOnlyWarnings(stack.errors())) successful = false; -- cgit v1.2.3 From 5fd9ea4b2abf9d2498fa725cfdbdf152c3d3d15a Mon Sep 17 00:00:00 2001 From: Zhen Zhang Date: Tue, 27 Feb 2018 12:31:09 +0800 Subject: Stop allow_guessing for command line option parser --- solc/CommandLineInterface.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'solc/CommandLineInterface.cpp') diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 8383afed..62b24975 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -627,6 +627,7 @@ Allowed options)", try { po::command_line_parser cmdLineParser(_argc, _argv); + cmdLineParser.style(po::command_line_style::default_style & (~po::command_line_style::allow_guessing)); cmdLineParser.options(allOptions).positional(filesPositions); po::store(cmdLineParser.run(), m_args); } -- cgit v1.2.3 From 5ab4a1ae7819004415293bf72a86824beb43cd51 Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 21 Feb 2018 23:43:40 +0100 Subject: Add ability to set the target EVM version. --- solc/CommandLineInterface.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'solc/CommandLineInterface.cpp') diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 62b24975..04d6d1a8 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -71,7 +71,6 @@ namespace solidity static string const g_stdinFileNameStr = ""; static string const g_strAbi = "abi"; -static string const g_strAddStandard = "add-std"; static string const g_strAllowPaths = "allow-paths"; static string const g_strAsm = "asm"; static string const g_strAsmJson = "asm-json"; @@ -87,6 +86,7 @@ static string const g_strCompactJSON = "compact-format"; static string const g_strContracts = "contracts"; 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_strFormal = "formal"; static string const g_strGas = "gas"; @@ -118,7 +118,6 @@ static string const g_strPrettyJson = "pretty-json"; static string const g_strVersion = "version"; static string const g_argAbi = g_strAbi; -static string const g_argAddStandard = g_strAddStandard; static string const g_argPrettyJson = g_strPrettyJson; static string const g_argAllowPaths = g_strAllowPaths; static string const g_argAsm = g_strAsm; @@ -537,13 +536,17 @@ Allowed options)", (g_argHelp.c_str(), "Show help message and exit.") (g_argVersion.c_str(), "Show version and exit.") (g_strLicense.c_str(), "Show licensing information and exit.") + ( + g_strEVMVersion.c_str(), + po::value()->value_name("version"), + "Select desired EVM version. Either homestead or byzantium (default)." + ) (g_argOptimize.c_str(), "Enable bytecode optimizer.") ( g_argOptimizeRuns.c_str(), po::value()->value_name("n")->default_value(200), "Estimated number of contract runs for optimizer tuning." ) - (g_argAddStandard.c_str(), "Add standard contracts.") (g_argPrettyJson.c_str(), "Output JSON in pretty format. Currently it only works with the combined JSON output.") ( g_argLibraries.c_str(), @@ -779,6 +782,19 @@ bool CommandLineInterface::processInput() m_compiler.reset(new CompilerStack(fileReader)); + EVMVersion evmVersion; + if (m_args.count(g_strEVMVersion)) + { + string versionOptionStr = m_args[g_strEVMVersion].as(); + boost::optional versionOption = EVMVersion::fromString(versionOptionStr); + if (!versionOption) + { + cerr << "Invalid option for --evm-version: " << versionOptionStr << endl; + return false; + } + evmVersion = *versionOption; + } + auto scannerFromSourceName = [&](string const& _sourceName) -> solidity::Scanner const& { return m_compiler->scanner(_sourceName); }; SourceReferenceFormatter formatter(cerr, scannerFromSourceName); @@ -792,6 +808,8 @@ bool CommandLineInterface::processInput() m_compiler->addSource(sourceCode.first, sourceCode.second); if (m_args.count(g_argLibraries)) m_compiler->setLibraries(m_libraries); + if (m_args.count(g_strEVMVersion)) + m_compiler->setEVMVersion(evmVersion); // TODO: Perhaps we should not compile unless requested bool optimize = m_args.count(g_argOptimize) > 0; unsigned runs = m_args[g_argOptimizeRuns].as(); -- cgit v1.2.3 From dc317a44e031d45ebf745b47248bf06bc92d58bf Mon Sep 17 00:00:00 2001 From: chriseth Date: Fri, 23 Feb 2018 11:42:53 +0100 Subject: Provide EVM version to assembly analysis. --- solc/CommandLineInterface.cpp | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'solc/CommandLineInterface.cpp') diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 04d6d1a8..8ccb04ee 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -748,6 +748,19 @@ bool CommandLineInterface::processInput() if (!parseLibraryOption(library)) return false; + EVMVersion evmVersion; + if (m_args.count(g_strEVMVersion)) + { + string versionOptionStr = m_args[g_strEVMVersion].as(); + boost::optional versionOption = EVMVersion::fromString(versionOptionStr); + if (!versionOption) + { + cerr << "Invalid option for --evm-version: " << versionOptionStr << endl; + return false; + } + evmVersion = *versionOption; + } + if (m_args.count(g_argAssemble) || m_args.count(g_argStrictAssembly) || m_args.count(g_argJulia)) { // switch to assembly mode @@ -771,7 +784,7 @@ bool CommandLineInterface::processInput() return false; } } - return assemble(inputLanguage, targetMachine); + return assemble(evmVersion, inputLanguage, targetMachine); } if (m_args.count(g_argLink)) { @@ -782,19 +795,6 @@ bool CommandLineInterface::processInput() m_compiler.reset(new CompilerStack(fileReader)); - EVMVersion evmVersion; - if (m_args.count(g_strEVMVersion)) - { - string versionOptionStr = m_args[g_strEVMVersion].as(); - boost::optional versionOption = EVMVersion::fromString(versionOptionStr); - if (!versionOption) - { - cerr << "Invalid option for --evm-version: " << versionOptionStr << endl; - return false; - } - evmVersion = *versionOption; - } - auto scannerFromSourceName = [&](string const& _sourceName) -> solidity::Scanner const& { return m_compiler->scanner(_sourceName); }; SourceReferenceFormatter formatter(cerr, scannerFromSourceName); @@ -1081,6 +1081,7 @@ void CommandLineInterface::writeLinkedFiles() } bool CommandLineInterface::assemble( + EVMVersion _evmVersion, AssemblyStack::Language _language, AssemblyStack::Machine _targetMachine ) @@ -1089,7 +1090,7 @@ bool CommandLineInterface::assemble( map assemblyStacks; for (auto const& src: m_sourceCodes) { - auto& stack = assemblyStacks[src.first] = AssemblyStack(_language); + auto& stack = assemblyStacks[src.first] = AssemblyStack(_evmVersion, _language); try { if (!stack.parseAndAnalyze(src.first, src.second)) -- cgit v1.2.3 From 982476f99d085072d25b703a146a6d92cd280714 Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 26 Feb 2018 19:53:38 +0100 Subject: Add TangerineWhistle. --- solc/CommandLineInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'solc/CommandLineInterface.cpp') diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 8ccb04ee..caa564bc 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -539,7 +539,7 @@ Allowed options)", ( g_strEVMVersion.c_str(), po::value()->value_name("version"), - "Select desired EVM version. Either homestead or byzantium (default)." + "Select desired EVM version. Either homestead, tangerineWhistle, spuriousDragon or byzantium (default)." ) (g_argOptimize.c_str(), "Enable bytecode optimizer.") ( -- cgit v1.2.3 From 4ce0e7775d86076b2f1d0e1d1390f7a76636d257 Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 27 Feb 2018 18:51:12 +0100 Subject: Add constantinople. --- solc/CommandLineInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'solc/CommandLineInterface.cpp') diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index caa564bc..fd079656 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -539,7 +539,7 @@ Allowed options)", ( g_strEVMVersion.c_str(), po::value()->value_name("version"), - "Select desired EVM version. Either homestead, tangerineWhistle, spuriousDragon or byzantium (default)." + "Select desired EVM version. Either homestead, tangerineWhistle, spuriousDragon, byzantium (default) or constantinople." ) (g_argOptimize.c_str(), "Enable bytecode optimizer.") ( -- cgit v1.2.3 From 6ec4517929e8c0eca022f4771ba217db5d80beed Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 1 Mar 2018 12:06:36 +0100 Subject: Use EVM version in gas meter and optimizer. --- solc/CommandLineInterface.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'solc/CommandLineInterface.cpp') diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index fd079656..d3d234c3 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -748,7 +748,6 @@ bool CommandLineInterface::processInput() if (!parseLibraryOption(library)) return false; - EVMVersion evmVersion; if (m_args.count(g_strEVMVersion)) { string versionOptionStr = m_args[g_strEVMVersion].as(); @@ -758,7 +757,7 @@ bool CommandLineInterface::processInput() cerr << "Invalid option for --evm-version: " << versionOptionStr << endl; return false; } - evmVersion = *versionOption; + m_evmVersion = *versionOption; } if (m_args.count(g_argAssemble) || m_args.count(g_argStrictAssembly) || m_args.count(g_argJulia)) @@ -784,7 +783,7 @@ bool CommandLineInterface::processInput() return false; } } - return assemble(evmVersion, inputLanguage, targetMachine); + return assemble(inputLanguage, targetMachine); } if (m_args.count(g_argLink)) { @@ -808,8 +807,7 @@ bool CommandLineInterface::processInput() m_compiler->addSource(sourceCode.first, sourceCode.second); if (m_args.count(g_argLibraries)) m_compiler->setLibraries(m_libraries); - if (m_args.count(g_strEVMVersion)) - m_compiler->setEVMVersion(evmVersion); + m_compiler->setEVMVersion(m_evmVersion); // TODO: Perhaps we should not compile unless requested bool optimize = m_args.count(g_argOptimize) > 0; unsigned runs = m_args[g_argOptimizeRuns].as(); @@ -968,7 +966,7 @@ void CommandLineInterface::handleAst(string const& _argStr) // FIXME: shouldn't this be done for every contract? if (m_compiler->runtimeAssemblyItems(m_compiler->lastContractName())) gasCosts = GasEstimator::breakToStatementLevel( - GasEstimator::structuralEstimation(*m_compiler->runtimeAssemblyItems(m_compiler->lastContractName()), asts), + GasEstimator(m_evmVersion).structuralEstimation(*m_compiler->runtimeAssemblyItems(m_compiler->lastContractName()), asts), asts ); @@ -1081,7 +1079,6 @@ void CommandLineInterface::writeLinkedFiles() } bool CommandLineInterface::assemble( - EVMVersion _evmVersion, AssemblyStack::Language _language, AssemblyStack::Machine _targetMachine ) @@ -1090,7 +1087,7 @@ bool CommandLineInterface::assemble( map assemblyStacks; for (auto const& src: m_sourceCodes) { - auto& stack = assemblyStacks[src.first] = AssemblyStack(_evmVersion, _language); + auto& stack = assemblyStacks[src.first] = AssemblyStack(m_evmVersion, _language); try { if (!stack.parseAndAnalyze(src.first, src.second)) -- cgit v1.2.3