mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Introduce assemblyString
This commit is contained in:
@@ -60,9 +60,9 @@ public:
|
||||
/// @returns Only the runtime object (without constructor).
|
||||
eth::LinkerObject runtimeObject() const { return m_context.assembledRuntimeObject(m_runtimeSub); }
|
||||
/// @arg _sourceCodes is the map of input files to source code strings
|
||||
void assemblyStream(std::ostream& _stream, StringMap const& _sourceCodes = StringMap()) const
|
||||
std::string assemblyString(StringMap const& _sourceCodes = StringMap()) const
|
||||
{
|
||||
m_context.assemblyStream(_stream, _sourceCodes);
|
||||
return m_context.assemblyString(_sourceCodes);
|
||||
}
|
||||
/// @arg _sourceCodes is the map of input files to source code strings
|
||||
Json::Value assemblyJSON(StringMap const& _sourceCodes = StringMap()) const
|
||||
|
||||
@@ -209,9 +209,9 @@ public:
|
||||
eth::Assembly& nonConstAssembly() { return *m_asm; }
|
||||
|
||||
/// @arg _sourceCodes is the map of input files to source code strings
|
||||
void assemblyStream(std::ostream& _stream, StringMap const& _sourceCodes = StringMap()) const
|
||||
std::string assemblyString(StringMap const& _sourceCodes = StringMap()) const
|
||||
{
|
||||
m_asm->assemblyStream(_stream, "", _sourceCodes);
|
||||
return m_asm->assemblyString(_sourceCodes);
|
||||
}
|
||||
|
||||
/// @arg _sourceCodes is the map of input files to source code strings
|
||||
|
||||
@@ -91,9 +91,7 @@ MachineAssemblyObject AssemblyStack::assemble(Machine _machine) const
|
||||
eth::Assembly assembly;
|
||||
assembly::CodeGenerator::assemble(*m_parserResult, *m_analysisInfo, assembly);
|
||||
object.bytecode = make_shared<eth::LinkerObject>(assembly.assemble());
|
||||
ostringstream tmp;
|
||||
assembly.assemblyStream(tmp);
|
||||
object.assembly = tmp.str();
|
||||
object.assembly = assembly.assemblyString();
|
||||
return object;
|
||||
}
|
||||
case Machine::EVM15:
|
||||
|
||||
@@ -347,15 +347,14 @@ eth::LinkerObject const& CompilerStack::cloneObject(string const& _contractName)
|
||||
return contract(_contractName).cloneObject;
|
||||
}
|
||||
|
||||
void CompilerStack::assemblyStream(ostream& _outStream, string const& _contractName, StringMap _sourceCodes) const
|
||||
/// FIXME: cache this string
|
||||
string CompilerStack::assemblyString(string const& _contractName, StringMap _sourceCodes) const
|
||||
{
|
||||
Contract const& currentContract = contract(_contractName);
|
||||
if (currentContract.compiler)
|
||||
currentContract.compiler->assemblyStream(_outStream, _sourceCodes);
|
||||
return currentContract.compiler->assemblyString(_sourceCodes);
|
||||
else
|
||||
{
|
||||
_outStream << "Contract not fully implemented" << endl;
|
||||
}
|
||||
return string();
|
||||
}
|
||||
|
||||
/// FIXME: cache the JSON
|
||||
|
||||
@@ -190,10 +190,10 @@ public:
|
||||
/// if the contract does not (yet) have bytecode.
|
||||
std::string const* runtimeSourceMapping(std::string const& _contractName = "") const;
|
||||
|
||||
/// Streams a verbose version of the assembly to @a _outStream.
|
||||
/// @return a verbose text representation of the assembly.
|
||||
/// @arg _sourceCodes is the map of input files to source code strings
|
||||
/// Prerequisite: Successful compilation.
|
||||
void assemblyStream(std::ostream& _outStream, std::string const& _contractName = "", StringMap _sourceCodes = StringMap()) const;
|
||||
std::string assemblyString(std::string const& _contractName = "", StringMap _sourceCodes = StringMap()) const;
|
||||
|
||||
/// @returns a JSON representation of the assembly.
|
||||
/// @arg _sourceCodes is the map of input files to source code strings
|
||||
|
||||
@@ -400,9 +400,7 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input)
|
||||
// EVM
|
||||
Json::Value evmData(Json::objectValue);
|
||||
// @TODO: add ir
|
||||
ostringstream tmp;
|
||||
m_compilerStack.assemblyStream(tmp, contractName, createSourceList(_input));
|
||||
evmData["assembly"] = tmp.str();
|
||||
evmData["assembly"] = m_compilerStack.assemblyString(contractName, createSourceList(_input));
|
||||
evmData["legacyAssembly"] = m_compilerStack.assemblyJSON(contractName, createSourceList(_input));
|
||||
evmData["methodIdentifiers"] = m_compilerStack.methodIdentifiers(contractName);
|
||||
evmData["gasEstimates"] = m_compilerStack.gasEstimates(contractName);
|
||||
|
||||
Reference in New Issue
Block a user