mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Wasm to binary assembly stack.
This commit is contained in:
parent
4cd0c84f75
commit
e79a32e9d5
@ -578,6 +578,14 @@ string const& CompilerStack::eWasm(string const& _contractName) const
|
||||
return contract(_contractName).eWasm;
|
||||
}
|
||||
|
||||
eth::LinkerObject const& CompilerStack::eWasmObject(string const& _contractName) const
|
||||
{
|
||||
if (m_stackState != CompilationSuccessful)
|
||||
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Compilation was not successful."));
|
||||
|
||||
return contract(_contractName).eWasmObject;
|
||||
}
|
||||
|
||||
eth::LinkerObject const& CompilerStack::object(string const& _contractName) const
|
||||
{
|
||||
if (m_stackState != CompilationSuccessful)
|
||||
@ -1047,7 +1055,9 @@ void CompilerStack::generateEWasm(ContractDefinition const& _contract)
|
||||
//cout << yul::AsmPrinter{}(*ewasmStack.parserResult()->code) << endl;
|
||||
|
||||
// Turn into eWasm text representation.
|
||||
compiledContract.eWasm = ewasmStack.assemble(yul::AssemblyStack::Machine::eWasm).assembly;
|
||||
auto result = ewasmStack.assemble(yul::AssemblyStack::Machine::eWasm);
|
||||
compiledContract.eWasm = std::move(result.assembly);
|
||||
compiledContract.eWasmObject = std::move(*result.bytecode);
|
||||
}
|
||||
|
||||
CompilerStack::Contract const& CompilerStack::contract(string const& _contractName) const
|
||||
|
@ -232,9 +232,12 @@ public:
|
||||
/// @returns the optimized IR representation of a contract.
|
||||
std::string const& yulIROptimized(std::string const& _contractName) const;
|
||||
|
||||
/// @returns the eWasm (text) representation of a contract.
|
||||
/// @returns the eWasm text representation of a contract.
|
||||
std::string const& eWasm(std::string const& _contractName) const;
|
||||
|
||||
/// @returns the eWasm representation of a contract.
|
||||
eth::LinkerObject const& eWasmObject(std::string const& _contractName) const;
|
||||
|
||||
/// @returns the assembled object for a contract.
|
||||
eth::LinkerObject const& object(std::string const& _contractName) const;
|
||||
|
||||
@ -312,7 +315,8 @@ private:
|
||||
eth::LinkerObject runtimeObject; ///< Runtime object.
|
||||
std::string yulIR; ///< Experimental Yul IR code.
|
||||
std::string yulIROptimized; ///< Optimized experimental Yul IR code.
|
||||
std::string eWasm; ///< Experimental eWasm code (text representation).
|
||||
std::string eWasm; ///< Experimental eWasm text representation
|
||||
eth::LinkerObject eWasmObject; ///< Experimental eWasm code
|
||||
mutable std::unique_ptr<std::string const> metadata; ///< The metadata json that will be hashed into the chain.
|
||||
mutable std::unique_ptr<Json::Value const> abi;
|
||||
mutable std::unique_ptr<Json::Value const> userDocumentation;
|
||||
@ -346,7 +350,7 @@ private:
|
||||
/// The IR is stored but otherwise unused.
|
||||
void generateIR(ContractDefinition const& _contract);
|
||||
|
||||
/// Generate eWasm text representation for a single contract.
|
||||
/// Generate eWasm representation for a single contract.
|
||||
void generateEWasm(ContractDefinition const& _contract);
|
||||
|
||||
/// Links all the known library addresses in the available objects. Any unknown
|
||||
|
@ -200,7 +200,10 @@ MachineAssemblyObject AssemblyStack::assemble(Machine _machine) const
|
||||
Dialect const& dialect = languageToDialect(m_language, EVMVersion{});
|
||||
|
||||
MachineAssemblyObject object;
|
||||
object.assembly = EWasmObjectCompiler::compile(*m_parserResult, dialect).first;
|
||||
auto result = EWasmObjectCompiler::compile(*m_parserResult, dialect);
|
||||
object.assembly = std::move(result.first);
|
||||
object.bytecode = make_shared<dev::eth::LinkerObject>();
|
||||
object.bytecode->bytecode = std::move(result.second);
|
||||
return object;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user