aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian <c@ethdev.com>2014-11-11 17:39:59 +0800
committerChristian <c@ethdev.com>2014-11-11 17:39:59 +0800
commitd1789250b66f79ab45bc8469eedba410f4ae388f (patch)
tree3205ad7f977d2b99b6a6c92175d2d58c5b822502
parent41b26e491b9a4eaa1ef481e7e57ebc1111315033 (diff)
parenta0c72065fee89c4558eeb4a98e5273633635bc39 (diff)
downloaddexon-solidity-d1789250b66f79ab45bc8469eedba410f4ae388f.tar
dexon-solidity-d1789250b66f79ab45bc8469eedba410f4ae388f.tar.gz
dexon-solidity-d1789250b66f79ab45bc8469eedba410f4ae388f.tar.bz2
dexon-solidity-d1789250b66f79ab45bc8469eedba410f4ae388f.tar.lz
dexon-solidity-d1789250b66f79ab45bc8469eedba410f4ae388f.tar.xz
dexon-solidity-d1789250b66f79ab45bc8469eedba410f4ae388f.tar.zst
dexon-solidity-d1789250b66f79ab45bc8469eedba410f4ae388f.zip
Merge remote-tracking branch 'ethereum/develop' into sol_jumptable
Conflicts: libsolidity/Compiler.cpp
-rw-r--r--Compiler.cpp4
-rw-r--r--Compiler.h4
-rw-r--r--CompilerContext.h2
-rw-r--r--CompilerStack.cpp5
-rw-r--r--CompilerStack.h2
5 files changed, 9 insertions, 8 deletions
diff --git a/Compiler.cpp b/Compiler.cpp
index c5e25a12..da28ba8a 100644
--- a/Compiler.cpp
+++ b/Compiler.cpp
@@ -32,11 +32,11 @@ using namespace std;
namespace dev {
namespace solidity {
-bytes Compiler::compile(ContractDefinition& _contract)
+bytes Compiler::compile(ContractDefinition& _contract, bool _optimize)
{
Compiler compiler;
compiler.compileContract(_contract);
- return compiler.m_context.getAssembledBytecode();
+ return compiler.m_context.getAssembledBytecode(_optimize);
}
void Compiler::compileContract(ContractDefinition& _contract)
diff --git a/Compiler.h b/Compiler.h
index 4e4d90d4..d931f535 100644
--- a/Compiler.h
+++ b/Compiler.h
@@ -33,11 +33,11 @@ public:
Compiler(): m_returnTag(m_context.newTag()) {}
void compileContract(ContractDefinition& _contract);
- bytes getAssembledBytecode() { return m_context.getAssembledBytecode(); }
+ bytes getAssembledBytecode(bool _optimize = false) { return m_context.getAssembledBytecode(_optimize); }
void streamAssembly(std::ostream& _stream) const { m_context.streamAssembly(_stream); }
/// Compile the given contract and return the EVM bytecode.
- static bytes compile(ContractDefinition& _contract);
+ static bytes compile(ContractDefinition& _contract, bool _optimize);
private:
/// Creates a new compiler context / assembly and packs the current code into the data part.
diff --git a/CompilerContext.h b/CompilerContext.h
index 9f8658c3..562c2932 100644
--- a/CompilerContext.h
+++ b/CompilerContext.h
@@ -84,7 +84,7 @@ public:
eth::Assembly const& getAssembly() const { return m_asm; }
void streamAssembly(std::ostream& _stream) const { _stream << m_asm; }
- bytes getAssembledBytecode() const { return m_asm.assemble(); }
+ bytes getAssembledBytecode(bool _optimize = false) { return m_asm.optimise(_optimize).assemble(); }
private:
eth::Assembly m_asm;
diff --git a/CompilerStack.cpp b/CompilerStack.cpp
index bbd693ae..c991171a 100644
--- a/CompilerStack.cpp
+++ b/CompilerStack.cpp
@@ -34,7 +34,8 @@ namespace dev
namespace solidity
{
-bytes CompilerStack::compile(std::string const& _sourceCode, shared_ptr<Scanner> _scanner)
+bytes CompilerStack::compile(std::string const& _sourceCode, shared_ptr<Scanner> _scanner,
+ bool _optimize)
{
if (!_scanner)
_scanner = make_shared<Scanner>();
@@ -42,7 +43,7 @@ bytes CompilerStack::compile(std::string const& _sourceCode, shared_ptr<Scanner>
ASTPointer<ContractDefinition> contract = Parser().parse(_scanner);
NameAndTypeResolver().resolveNamesAndTypes(*contract);
- return Compiler::compile(*contract);
+ return Compiler::compile(*contract, _optimize);
}
}
diff --git a/CompilerStack.h b/CompilerStack.h
index 9f3f81c0..b003745d 100644
--- a/CompilerStack.h
+++ b/CompilerStack.h
@@ -36,7 +36,7 @@ class CompilerStack
public:
/// Compile the given @a _sourceCode to bytecode. If a scanner is provided, it is used for
/// scanning the source code - this is useful for printing exception information.
- static bytes compile(std::string const& _sourceCode, std::shared_ptr<Scanner> _scanner = std::shared_ptr<Scanner>());
+ static bytes compile(std::string const& _sourceCode, std::shared_ptr<Scanner> _scanner = std::shared_ptr<Scanner>(), bool _optimize = false);
};
}