aboutsummaryrefslogtreecommitdiffstats
path: root/solc
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-11-03 23:05:08 +0800
committerchriseth <chris@ethereum.org>2018-12-01 06:39:05 +0800
commit6c44c5f0c93d6ce623bec773cc151a73d4b12bff (patch)
tree5a5d79f49211e87737b9c3b74bf40cb1c43e877c /solc
parentcc00d8172b6cd7f9fc032e4a21857455ace2f290 (diff)
downloaddexon-solidity-6c44c5f0c93d6ce623bec773cc151a73d4b12bff.tar.gz
dexon-solidity-6c44c5f0c93d6ce623bec773cc151a73d4b12bff.tar.zst
dexon-solidity-6c44c5f0c93d6ce623bec773cc151a73d4b12bff.zip
Apply the optimize commandline parameter to assembly mode.
Diffstat (limited to 'solc')
-rw-r--r--solc/CommandLineInterface.cpp25
-rw-r--r--solc/CommandLineInterface.h2
2 files changed, 21 insertions, 6 deletions
diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp
index e2baca7f..38e778c6 100644
--- a/solc/CommandLineInterface.cpp
+++ b/solc/CommandLineInterface.cpp
@@ -626,15 +626,15 @@ Allowed options)",
)
(
g_argAssemble.c_str(),
- "Switch to assembly mode, ignoring all options except --machine and assumes input is assembly."
+ "Switch to assembly mode, ignoring all options except --machine and --optimize and assumes input is assembly."
)
(
g_argYul.c_str(),
- "Switch to Yul mode, ignoring all options except --machine and assumes input is Yul."
+ "Switch to Yul mode, ignoring all options except --machine and --optimize and assumes input is Yul."
)
(
g_argStrictAssembly.c_str(),
- "Switch to strict assembly mode, ignoring all options except --machine and assumes input is strict assembly."
+ "Switch to strict assembly mode, ignoring all options except --machine and --optimize and assumes input is strict assembly."
)
(
g_argMachine.c_str(),
@@ -820,6 +820,7 @@ bool CommandLineInterface::processInput()
using Machine = AssemblyStack::Machine;
Input inputLanguage = m_args.count(g_argYul) ? Input::Yul : (m_args.count(g_argStrictAssembly) ? Input::StrictAssembly : Input::Assembly);
Machine targetMachine = Machine::EVM;
+ bool optimize = m_args.count(g_argOptimize);
if (m_args.count(g_argMachine))
{
string machine = m_args[g_argMachine].as<string>();
@@ -835,7 +836,18 @@ bool CommandLineInterface::processInput()
return false;
}
}
- return assemble(inputLanguage, targetMachine);
+ if (optimize && inputLanguage == Input::Assembly)
+ {
+ serr() <<
+ "Optimizer cannot be used for loose assembly. Use --" <<
+ g_strStrictAssembly <<
+ " or --" <<
+ g_strYul <<
+ "." <<
+ endl;
+ return false;
+ }
+ return assemble(inputLanguage, targetMachine, optimize);
}
if (m_args.count(g_argLink))
{
@@ -1179,7 +1191,8 @@ string CommandLineInterface::objectWithLinkRefsHex(eth::LinkerObject const& _obj
bool CommandLineInterface::assemble(
AssemblyStack::Language _language,
- AssemblyStack::Machine _targetMachine
+ AssemblyStack::Machine _targetMachine,
+ bool _optimize
)
{
bool successful = true;
@@ -1191,6 +1204,8 @@ bool CommandLineInterface::assemble(
{
if (!stack.parseAndAnalyze(src.first, src.second))
successful = false;
+ else if (_optimize)
+ stack.optimize();
}
catch (Exception const& _exception)
{
diff --git a/solc/CommandLineInterface.h b/solc/CommandLineInterface.h
index 8dc00370..0b22ca29 100644
--- a/solc/CommandLineInterface.h
+++ b/solc/CommandLineInterface.h
@@ -59,7 +59,7 @@ private:
/// @returns the full object with library placeholder hints in hex.
static std::string objectWithLinkRefsHex(eth::LinkerObject const& _obj);
- bool assemble(AssemblyStack::Language _language, AssemblyStack::Machine _targetMachine);
+ bool assemble(AssemblyStack::Language _language, AssemblyStack::Machine _targetMachine, bool _optimize);
void outputCompilationResults();