mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge remote-tracking branch 'ethereum/develop' into sol_jumptable
Conflicts: libsolidity/Compiler.cpp
This commit is contained in:
commit
d1789250b6
@ -32,11 +32,11 @@ using namespace std;
|
|||||||
namespace dev {
|
namespace dev {
|
||||||
namespace solidity {
|
namespace solidity {
|
||||||
|
|
||||||
bytes Compiler::compile(ContractDefinition& _contract)
|
bytes Compiler::compile(ContractDefinition& _contract, bool _optimize)
|
||||||
{
|
{
|
||||||
Compiler compiler;
|
Compiler compiler;
|
||||||
compiler.compileContract(_contract);
|
compiler.compileContract(_contract);
|
||||||
return compiler.m_context.getAssembledBytecode();
|
return compiler.m_context.getAssembledBytecode(_optimize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Compiler::compileContract(ContractDefinition& _contract)
|
void Compiler::compileContract(ContractDefinition& _contract)
|
||||||
|
@ -33,11 +33,11 @@ public:
|
|||||||
Compiler(): m_returnTag(m_context.newTag()) {}
|
Compiler(): m_returnTag(m_context.newTag()) {}
|
||||||
|
|
||||||
void compileContract(ContractDefinition& _contract);
|
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); }
|
void streamAssembly(std::ostream& _stream) const { m_context.streamAssembly(_stream); }
|
||||||
|
|
||||||
/// Compile the given contract and return the EVM bytecode.
|
/// Compile the given contract and return the EVM bytecode.
|
||||||
static bytes compile(ContractDefinition& _contract);
|
static bytes compile(ContractDefinition& _contract, bool _optimize);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Creates a new compiler context / assembly and packs the current code into the data part.
|
/// Creates a new compiler context / assembly and packs the current code into the data part.
|
||||||
|
@ -84,7 +84,7 @@ public:
|
|||||||
|
|
||||||
eth::Assembly const& getAssembly() const { return m_asm; }
|
eth::Assembly const& getAssembly() const { return m_asm; }
|
||||||
void streamAssembly(std::ostream& _stream) const { _stream << 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:
|
private:
|
||||||
eth::Assembly m_asm;
|
eth::Assembly m_asm;
|
||||||
|
|
||||||
|
@ -34,7 +34,8 @@ namespace dev
|
|||||||
namespace solidity
|
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)
|
if (!_scanner)
|
||||||
_scanner = make_shared<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);
|
ASTPointer<ContractDefinition> contract = Parser().parse(_scanner);
|
||||||
NameAndTypeResolver().resolveNamesAndTypes(*contract);
|
NameAndTypeResolver().resolveNamesAndTypes(*contract);
|
||||||
return Compiler::compile(*contract);
|
return Compiler::compile(*contract, _optimize);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ class CompilerStack
|
|||||||
public:
|
public:
|
||||||
/// Compile the given @a _sourceCode to bytecode. If a scanner is provided, it is used for
|
/// 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.
|
/// 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);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user