mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Cleaner interface for Solc CLI bytecode handling
This commit is contained in:
parent
e851d2173d
commit
d377ad3fb1
@ -92,39 +92,48 @@ static std::istream& operator>>(std::istream& _in, OutputType& io_output)
|
|||||||
return _in;
|
return _in;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandLineInterface::handleBytecode(string const& _argName,
|
void CommandLineInterface::handleBinary(string const& _contract)
|
||||||
string const& _title,
|
|
||||||
string const& _contract,
|
|
||||||
string const& _suffix)
|
|
||||||
{
|
{
|
||||||
if (m_args.count(_argName))
|
auto choice = m_args["binary"].as<OutputType>();
|
||||||
{
|
|
||||||
auto choice = m_args[_argName].as<OutputType>();
|
|
||||||
if (outputToStdout(choice))
|
if (outputToStdout(choice))
|
||||||
{
|
{
|
||||||
cout << _title << endl;
|
cout << "Binary: " << endl;
|
||||||
if (_suffix == "opcodes")
|
|
||||||
{
|
|
||||||
// TODO: Figure out why the wrong operator << (from boost) is used here
|
|
||||||
dev::operator<<(cout, m_compiler.getBytecode(_contract));
|
|
||||||
cout << endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
cout << toHex(m_compiler.getBytecode(_contract)) << endl;
|
cout << toHex(m_compiler.getBytecode(_contract)) << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (outputToFile(choice))
|
if (outputToFile(choice))
|
||||||
{
|
{
|
||||||
ofstream outFile(_contract + _suffix);
|
ofstream outFile(_contract + ".binary");
|
||||||
if (_suffix == "opcodes")
|
|
||||||
// TODO: Figure out why the wrong operator << (from boost) is used here
|
|
||||||
dev::operator<<(outFile, m_compiler.getBytecode(_contract));
|
|
||||||
|
|
||||||
else
|
|
||||||
outFile << toHex(m_compiler.getBytecode(_contract));
|
outFile << toHex(m_compiler.getBytecode(_contract));
|
||||||
outFile.close();
|
outFile.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CommandLineInterface::handleOpcode(string const& _contract)
|
||||||
|
{
|
||||||
|
// TODO: Figure out why the wrong operator << (from boost) is used here
|
||||||
|
auto choice = m_args["opcode"].as<OutputType>();
|
||||||
|
if (outputToStdout(choice))
|
||||||
|
{
|
||||||
|
cout << "Opcodes: " << endl;
|
||||||
|
dev::operator<<(cout, m_compiler.getBytecode(_contract));
|
||||||
|
cout << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (outputToFile(choice))
|
||||||
|
{
|
||||||
|
ofstream outFile(_contract + ".opcode");
|
||||||
|
dev::operator<<(outFile, m_compiler.getBytecode(_contract));
|
||||||
|
outFile.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommandLineInterface::handleBytecode(string const& _contract)
|
||||||
|
{
|
||||||
|
if (m_args.count("opcodes"))
|
||||||
|
handleOpcode(_contract);
|
||||||
|
if (m_args.count("binary"))
|
||||||
|
handleBinary(_contract);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandLineInterface::handleJson(DocumentationType _type,
|
void CommandLineInterface::handleJson(DocumentationType _type,
|
||||||
@ -348,8 +357,7 @@ void CommandLineInterface::actOnInput()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleBytecode("opcodes", "Opcodes:", contract, ".opcodes");
|
handleBytecode(contract);
|
||||||
handleBytecode("binary", "Binary:", contract, ".binary");
|
|
||||||
handleJson(DocumentationType::ABI_INTERFACE, contract);
|
handleJson(DocumentationType::ABI_INTERFACE, contract);
|
||||||
handleJson(DocumentationType::NATSPEC_DEV, contract);
|
handleJson(DocumentationType::NATSPEC_DEV, contract);
|
||||||
handleJson(DocumentationType::NATSPEC_USER, contract);
|
handleJson(DocumentationType::NATSPEC_USER, contract);
|
||||||
|
@ -53,10 +53,9 @@ public:
|
|||||||
void actOnInput();
|
void actOnInput();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void handleBytecode(std::string const& _argName,
|
void handleBinary(std::string const& _contract);
|
||||||
std::string const& _title,
|
void handleOpcode(std::string const& _contract);
|
||||||
std::string const& _contract,
|
void handleBytecode(std::string const& _contract);
|
||||||
std::string const& _suffix);
|
|
||||||
void handleJson(DocumentationType _type,
|
void handleJson(DocumentationType _type,
|
||||||
std::string const& _contract);
|
std::string const& _contract);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user