diff options
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/interface/CompilerStack.cpp | 5 | ||||
-rw-r--r-- | libsolidity/interface/CompilerStack.h | 13 | ||||
-rw-r--r-- | libsolidity/interface/StandardCompiler.cpp | 3 |
3 files changed, 12 insertions, 9 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()) { |