aboutsummaryrefslogtreecommitdiffstats
path: root/solc/CommandLineInterface.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2016-11-14 18:46:43 +0800
committerchriseth <c@ethdev.com>2016-12-01 23:03:59 +0800
commit5789eaa78d0e00f6289101e02f7de5e9decdc7e5 (patch)
tree8964f493235d310baa50806fdff65138054d2439 /solc/CommandLineInterface.cpp
parent55a719a79c1ab5b78ea6e1bcb4f27a888494a538 (diff)
downloaddexon-solidity-5789eaa78d0e00f6289101e02f7de5e9decdc7e5.tar.gz
dexon-solidity-5789eaa78d0e00f6289101e02f7de5e9decdc7e5.tar.zst
dexon-solidity-5789eaa78d0e00f6289101e02f7de5e9decdc7e5.zip
Metadata stamp.
Diffstat (limited to 'solc/CommandLineInterface.cpp')
-rw-r--r--solc/CommandLineInterface.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp
index 49fac51c..fdfcabb4 100644
--- a/solc/CommandLineInterface.cpp
+++ b/solc/CommandLineInterface.cpp
@@ -78,6 +78,7 @@ static string const g_argCloneBinaryStr = "clone-bin";
static string const g_argOpcodesStr = "opcodes";
static string const g_argNatspecDevStr = "devdoc";
static string const g_argNatspecUserStr = "userdoc";
+static string const g_argMetadata = "metadata";
static string const g_argAddStandard = "add-std";
static string const g_stdinFileName = "<stdin>";
@@ -91,6 +92,7 @@ static set<string> const g_combinedJsonArgs{
"opcodes",
"abi",
"interface",
+ "metadata",
"asm",
"ast",
"userdoc",
@@ -117,6 +119,7 @@ static bool needsHumanTargetedStdout(po::variables_map const& _args)
for (string const& arg: {
g_argAbiStr,
g_argSignatureHashes,
+ g_argMetadata,
g_argNatspecUserStr,
g_argAstJson,
g_argNatspecDevStr,
@@ -202,6 +205,18 @@ void CommandLineInterface::handleSignatureHashes(string const& _contract)
cout << "Function signatures: " << endl << out;
}
+void CommandLineInterface::handleOnChainMetadata(string const& _contract)
+{
+ if (!m_args.count(g_argMetadata))
+ return;
+
+ string data = m_compiler->onChainMetadata(_contract);
+ if (m_args.count("output-dir"))
+ createFile(_contract + ".meta", data);
+ else
+ cout << "Metadata: " << endl << data << endl;
+}
+
void CommandLineInterface::handleMeta(DocumentationType _type, string const& _contract)
{
std::string argName;
@@ -467,6 +482,7 @@ Allowed options)",
(g_argSignatureHashes.c_str(), "Function signature hashes of the contracts.")
(g_argNatspecUserStr.c_str(), "Natspec user documentation of all contracts.")
(g_argNatspecDevStr.c_str(), "Natspec developer documentation of all contracts.")
+ (g_argMetadata.c_str(), "Combined metadata JSON whose swarm hash is stored on-chain.")
("formal", "Translated source suitable for formal analysis.");
desc.add(outputComponents);
@@ -581,9 +597,7 @@ bool CommandLineInterface::processInput()
// TODO: Perhaps we should not compile unless requested
bool optimize = m_args.count("optimize") > 0;
unsigned runs = m_args["optimize-runs"].as<unsigned>();
- bool successful = m_compiler->compile(optimize, runs);
- if (successful)
- m_compiler->link(m_libraries);
+ bool successful = m_compiler->compile(optimize, runs, m_libraries);
if (successful && m_args.count("formal"))
if (!m_compiler->prepareFormalAnalysis())
@@ -659,6 +673,8 @@ void CommandLineInterface::handleCombinedJSON()
Json::Value contractData(Json::objectValue);
if (requests.count("abi"))
contractData["abi"] = dev::jsonCompactPrint(m_compiler->interface(contractName));
+ if (requests.count("metadata"))
+ contractData["metadata"] = m_compiler->onChainMetadata(contractName);
if (requests.count("bin"))
contractData["bin"] = m_compiler->object(contractName).toHex();
if (requests.count("bin-runtime"))
@@ -918,6 +934,7 @@ void CommandLineInterface::outputCompilationResults()
handleBytecode(contract);
handleSignatureHashes(contract);
+ handleOnChainMetadata(contract);
handleMeta(DocumentationType::ABIInterface, contract);
handleMeta(DocumentationType::NatspecDev, contract);
handleMeta(DocumentationType::NatspecUser, contract);