diff options
author | chriseth <chris@ethereum.org> | 2018-02-22 06:43:40 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-03-02 00:19:34 +0800 |
commit | 5ab4a1ae7819004415293bf72a86824beb43cd51 (patch) | |
tree | 6129bf94bcc3c9ab581bbae48a0d5b7449de65c9 /solc | |
parent | c9840c98f45e6fa9258ec4624219622f5f71c75c (diff) | |
download | dexon-solidity-5ab4a1ae7819004415293bf72a86824beb43cd51.tar.gz dexon-solidity-5ab4a1ae7819004415293bf72a86824beb43cd51.tar.zst dexon-solidity-5ab4a1ae7819004415293bf72a86824beb43cd51.zip |
Add ability to set the target EVM version.
Diffstat (limited to 'solc')
-rw-r--r-- | solc/CommandLineInterface.cpp | 24 |
1 files changed, 21 insertions, 3 deletions
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 = "<stdin>"; 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<string>()->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<unsigned>()->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<string>(); + boost::optional<EVMVersion> 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<unsigned>(); |