aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLefteris Karapetsas <lefteris@refu.co>2014-12-10 03:29:29 +0800
committerLefteris Karapetsas <lefteris@refu.co>2014-12-10 03:29:29 +0800
commitd377ad3fb13dda6e8a629adfe7484359bda0706d (patch)
treec740795bcbdb3d4bbfffa90806b929503459017f
parente851d2173daea4f464d5f72910bb2934c0596a65 (diff)
downloaddexon-solidity-d377ad3fb13dda6e8a629adfe7484359bda0706d.tar
dexon-solidity-d377ad3fb13dda6e8a629adfe7484359bda0706d.tar.gz
dexon-solidity-d377ad3fb13dda6e8a629adfe7484359bda0706d.tar.bz2
dexon-solidity-d377ad3fb13dda6e8a629adfe7484359bda0706d.tar.lz
dexon-solidity-d377ad3fb13dda6e8a629adfe7484359bda0706d.tar.xz
dexon-solidity-d377ad3fb13dda6e8a629adfe7484359bda0706d.tar.zst
dexon-solidity-d377ad3fb13dda6e8a629adfe7484359bda0706d.zip
Cleaner interface for Solc CLI bytecode handling
-rw-r--r--CommandLineInterface.cpp68
-rw-r--r--CommandLineInterface.h7
2 files changed, 41 insertions, 34 deletions
diff --git a/CommandLineInterface.cpp b/CommandLineInterface.cpp
index aef5512e..d3dd3945 100644
--- a/CommandLineInterface.cpp
+++ b/CommandLineInterface.cpp
@@ -92,41 +92,50 @@ static std::istream& operator>>(std::istream& _in, OutputType& io_output)
return _in;
}
-void CommandLineInterface::handleBytecode(string const& _argName,
- string const& _title,
- string const& _contract,
- string const& _suffix)
+void CommandLineInterface::handleBinary(string const& _contract)
{
- if (m_args.count(_argName))
+ auto choice = m_args["binary"].as<OutputType>();
+ if (outputToStdout(choice))
{
- auto choice = m_args[_argName].as<OutputType>();
- if (outputToStdout(choice))
- {
- cout << _title << 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 << "Binary: " << endl;
+ cout << toHex(m_compiler.getBytecode(_contract)) << endl;
+ }
- if (outputToFile(choice))
- {
- ofstream outFile(_contract + _suffix);
- if (_suffix == "opcodes")
- // TODO: Figure out why the wrong operator << (from boost) is used here
- dev::operator<<(outFile, m_compiler.getBytecode(_contract));
+ if (outputToFile(choice))
+ {
+ ofstream outFile(_contract + ".binary");
+ outFile << toHex(m_compiler.getBytecode(_contract));
+ outFile.close();
+ }
+}
- else
- outFile << toHex(m_compiler.getBytecode(_contract));
- 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,
string const& _contract)
{
@@ -348,8 +357,7 @@ void CommandLineInterface::actOnInput()
}
}
- handleBytecode("opcodes", "Opcodes:", contract, ".opcodes");
- handleBytecode("binary", "Binary:", contract, ".binary");
+ handleBytecode(contract);
handleJson(DocumentationType::ABI_INTERFACE, contract);
handleJson(DocumentationType::NATSPEC_DEV, contract);
handleJson(DocumentationType::NATSPEC_USER, contract);
diff --git a/CommandLineInterface.h b/CommandLineInterface.h
index 8eb1fff3..7e3ad250 100644
--- a/CommandLineInterface.h
+++ b/CommandLineInterface.h
@@ -53,10 +53,9 @@ public:
void actOnInput();
private:
- void handleBytecode(std::string const& _argName,
- std::string const& _title,
- std::string const& _contract,
- std::string const& _suffix);
+ void handleBinary(std::string const& _contract);
+ void handleOpcode(std::string const& _contract);
+ void handleBytecode(std::string const& _contract);
void handleJson(DocumentationType _type,
std::string const& _contract);