aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libsolidity/interface/CompilerStack.cpp5
-rw-r--r--libsolidity/interface/CompilerStack.h13
-rw-r--r--libsolidity/interface/StandardCompiler.cpp3
-rw-r--r--solc/CommandLineInterface.cpp4
-rw-r--r--test/contracts/AuctionRegistrar.cpp3
-rw-r--r--test/contracts/FixedFeeRegistrar.cpp3
-rw-r--r--test/contracts/Wallet.cpp3
-rw-r--r--test/libsolidity/GasMeter.cpp3
-rw-r--r--test/libsolidity/Metadata.cpp3
-rw-r--r--test/libsolidity/SolidityExecutionFramework.h3
10 files changed, 27 insertions, 16 deletions
diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp
index 89e024b3..d5a4e554 100644
--- a/libsolidity/interface/CompilerStack.cpp
+++ b/libsolidity/interface/CompilerStack.cpp
@@ -262,15 +262,12 @@ vector<string> CompilerStack::contractNames() const
return contractNames;
}
-bool CompilerStack::compile(bool _optimize, unsigned _runs)
+bool CompilerStack::compile()
{
if (m_stackState < AnalysisSuccessful)
if (!parseAndAnalyze())
return false;
- m_optimize = _optimize;
- m_optimizeRuns = _runs;
-
map<ContractDefinition const*, eth::Assembly const*> compiledContracts;
for (Source const* source: m_sourceOrder)
for (ASTPointer<ASTNode> const& node: source->ast->nodes())
diff --git a/libsolidity/interface/CompilerStack.h b/libsolidity/interface/CompilerStack.h
index 39875c32..356389db 100644
--- a/libsolidity/interface/CompilerStack.h
+++ b/libsolidity/interface/CompilerStack.h
@@ -103,6 +103,14 @@ public:
m_libraries = _libraries;
}
+ /// Changes the optimiser settings.
+ /// Will not take effect before running compile.
+ void setOptimiserSettings(bool _optimize, unsigned _runs = 200)
+ {
+ m_optimize = _optimize;
+ m_optimizeRuns = _runs;
+ }
+
/// Resets the compiler to a state where the sources are not parsed or even removed.
/// Sets the state to SourcesSet if @a _keepSources is true, otherwise to Empty.
/// All settings, with the exception of remappings, are reset.
@@ -126,10 +134,7 @@ public:
/// Compiles the source units that were previously added and parsed.
/// @returns false on error.
- bool compile(
- bool _optimize = false,
- unsigned _runs = 200
- );
+ bool compile();
/// @returns the assembled object for a contract.
eth::LinkerObject const& object(std::string const& _contractName = "") const;
diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp
index 1690f3cc..23687340 100644
--- a/libsolidity/interface/StandardCompiler.cpp
+++ b/libsolidity/interface/StandardCompiler.cpp
@@ -249,6 +249,7 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input)
Json::Value optimizerSettings = settings.get("optimizer", Json::Value());
bool const optimize = optimizerSettings.get("enabled", Json::Value(false)).asBool();
unsigned const optimizeRuns = optimizerSettings.get("runs", Json::Value(200u)).asUInt();
+ m_compilerStack.setOptimiserSettings(optimize, optimizeRuns);
map<string, h160> libraries;
Json::Value jsonLibraries = settings.get("libraries", Json::Value());
@@ -268,7 +269,7 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input)
try
{
- m_compilerStack.compile(optimize, optimizeRuns);
+ m_compilerStack.compile();
for (auto const& error: m_compilerStack.errors())
{
diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp
index 38f72713..740061a1 100644
--- a/solc/CommandLineInterface.cpp
+++ b/solc/CommandLineInterface.cpp
@@ -779,7 +779,9 @@ bool CommandLineInterface::processInput()
// TODO: Perhaps we should not compile unless requested
bool optimize = m_args.count(g_argOptimize) > 0;
unsigned runs = m_args[g_argOptimizeRuns].as<unsigned>();
- bool successful = m_compiler->compile(optimize, runs);
+ m_compiler->setOptimiserSettings(optimize, runs);
+
+ bool successful = m_compiler->compile();
for (auto const& error: m_compiler->errors())
SourceReferenceFormatter::printExceptionInformation(
diff --git a/test/contracts/AuctionRegistrar.cpp b/test/contracts/AuctionRegistrar.cpp
index fb8c1c68..773b14b9 100644
--- a/test/contracts/AuctionRegistrar.cpp
+++ b/test/contracts/AuctionRegistrar.cpp
@@ -223,7 +223,8 @@ protected:
{
m_compiler.reset(false);
m_compiler.addSource("", registrarCode);
- ETH_TEST_REQUIRE_NO_THROW(m_compiler.compile(m_optimize, m_optimizeRuns), "Compiling contract failed");
+ m_compiler.setOptimiserSettings(m_optimize, m_optimizeRuns);
+ ETH_TEST_REQUIRE_NO_THROW(m_compiler.compile(), "Compiling contract failed");
s_compiledRegistrar.reset(new bytes(m_compiler.object("GlobalRegistrar").bytecode));
}
sendMessage(*s_compiledRegistrar, true);
diff --git a/test/contracts/FixedFeeRegistrar.cpp b/test/contracts/FixedFeeRegistrar.cpp
index d2904b5f..967d60b6 100644
--- a/test/contracts/FixedFeeRegistrar.cpp
+++ b/test/contracts/FixedFeeRegistrar.cpp
@@ -135,7 +135,8 @@ protected:
{
m_compiler.reset(false);
m_compiler.addSource("", registrarCode);
- ETH_TEST_REQUIRE_NO_THROW(m_compiler.compile(m_optimize, m_optimizeRuns), "Compiling contract failed");
+ m_compiler.setOptimiserSettings(m_optimize, m_optimizeRuns);
+ ETH_TEST_REQUIRE_NO_THROW(m_compiler.compile(), "Compiling contract failed");
s_compiledRegistrar.reset(new bytes(m_compiler.object("FixedFeeRegistrar").bytecode));
}
sendMessage(*s_compiledRegistrar, true);
diff --git a/test/contracts/Wallet.cpp b/test/contracts/Wallet.cpp
index ef345d86..d12b7493 100644
--- a/test/contracts/Wallet.cpp
+++ b/test/contracts/Wallet.cpp
@@ -450,7 +450,8 @@ protected:
{
m_compiler.reset(false);
m_compiler.addSource("", walletCode);
- ETH_TEST_REQUIRE_NO_THROW(m_compiler.compile(m_optimize, m_optimizeRuns), "Compiling contract failed");
+ m_compiler.setOptimiserSettings(m_optimize, m_optimizeRuns);
+ ETH_TEST_REQUIRE_NO_THROW(m_compiler.compile(), "Compiling contract failed");
s_compiledWallet.reset(new bytes(m_compiler.object("Wallet").bytecode));
}
bytes args = encodeArgs(u256(0x60), _required, _dailyLimit, u256(_owners.size()), _owners);
diff --git a/test/libsolidity/GasMeter.cpp b/test/libsolidity/GasMeter.cpp
index 8b41e1db..df9afaae 100644
--- a/test/libsolidity/GasMeter.cpp
+++ b/test/libsolidity/GasMeter.cpp
@@ -49,7 +49,8 @@ public:
{
m_compiler.reset(false);
m_compiler.addSource("", "pragma solidity >=0.0;\n" + _sourceCode);
- ETH_TEST_REQUIRE_NO_THROW(m_compiler.compile(dev::test::Options::get().optimize), "Compiling contract failed");
+ m_compiler.setOptimiserSettings(dev::test::Options::get().optimize);
+ ETH_TEST_REQUIRE_NO_THROW(m_compiler.compile(), "Compiling contract failed");
AssemblyItems const* items = m_compiler.runtimeAssemblyItems("");
ASTNode const& sourceUnit = m_compiler.ast();
diff --git a/test/libsolidity/Metadata.cpp b/test/libsolidity/Metadata.cpp
index ce1a7b18..e4820ad2 100644
--- a/test/libsolidity/Metadata.cpp
+++ b/test/libsolidity/Metadata.cpp
@@ -44,7 +44,8 @@ BOOST_AUTO_TEST_CASE(metadata_stamp)
)";
CompilerStack compilerStack;
compilerStack.addSource("", std::string(sourceCode));
- ETH_TEST_REQUIRE_NO_THROW(compilerStack.compile(dev::test::Options::get().optimize), "Compiling contract failed");
+ compilerStack.setOptimiserSettings(dev::test::Options::get().optimize);
+ ETH_TEST_REQUIRE_NO_THROW(compilerStack.compile(), "Compiling contract failed");
bytes const& bytecode = compilerStack.runtimeObject("test").bytecode;
std::string const& metadata = compilerStack.metadata("test");
BOOST_CHECK(dev::test::isValidMetadata(metadata));
diff --git a/test/libsolidity/SolidityExecutionFramework.h b/test/libsolidity/SolidityExecutionFramework.h
index 6a13423b..a8e58c25 100644
--- a/test/libsolidity/SolidityExecutionFramework.h
+++ b/test/libsolidity/SolidityExecutionFramework.h
@@ -57,7 +57,8 @@ public:
m_compiler.reset(false);
m_compiler.addSource("", sourceCode);
m_compiler.setLibraries(_libraryAddresses);
- if (!m_compiler.compile(m_optimize, m_optimizeRuns))
+ m_compiler.setOptimiserSettings(m_optimize, m_optimizeRuns);
+ if (!m_compiler.compile())
{
for (auto const& error: m_compiler.errors())
SourceReferenceFormatter::printExceptionInformation(