aboutsummaryrefslogtreecommitdiffstats
path: root/solc
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2016-12-02 18:23:45 +0800
committerGitHub <noreply@github.com>2016-12-02 18:23:45 +0800
commit3a01a87afe3468421f31aa5097796dcc88e37e26 (patch)
tree9069fcc823ca4b27b6add0c7278f1086923eb36e /solc
parent55a719a79c1ab5b78ea6e1bcb4f27a888494a538 (diff)
parent5098e1eb15678859d1bd5e9172184d6525e03863 (diff)
downloaddexon-solidity-3a01a87afe3468421f31aa5097796dcc88e37e26.tar.gz
dexon-solidity-3a01a87afe3468421f31aa5097796dcc88e37e26.tar.zst
dexon-solidity-3a01a87afe3468421f31aa5097796dcc88e37e26.zip
Merge pull request #1386 from ethereum/metadataOut
Metadata stamp
Diffstat (limited to 'solc')
-rw-r--r--solc/CommandLineInterface.cpp23
-rw-r--r--solc/CommandLineInterface.h1
-rw-r--r--solc/jsonCompiler.cpp1
3 files changed, 22 insertions, 3 deletions
diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp
index 49fac51c..6e59099a 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.json", 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);
diff --git a/solc/CommandLineInterface.h b/solc/CommandLineInterface.h
index 33ae6ee6..b8fc1823 100644
--- a/solc/CommandLineInterface.h
+++ b/solc/CommandLineInterface.h
@@ -63,6 +63,7 @@ private:
void handleOpcode(std::string const& _contract);
void handleBytecode(std::string const& _contract);
void handleSignatureHashes(std::string const& _contract);
+ void handleOnChainMetadata(std::string const& _contract);
void handleMeta(DocumentationType _type, std::string const& _contract);
void handleGasEstimation(std::string const& _contract);
void handleFormal();
diff --git a/solc/jsonCompiler.cpp b/solc/jsonCompiler.cpp
index 0f95ebe5..d761b541 100644
--- a/solc/jsonCompiler.cpp
+++ b/solc/jsonCompiler.cpp
@@ -218,6 +218,7 @@ string compile(StringMap const& _sources, bool _optimize, CStyleReadFileCallback
contractData["bytecode"] = compiler.object(contractName).toHex();
contractData["runtimeBytecode"] = compiler.runtimeObject(contractName).toHex();
contractData["opcodes"] = solidity::disassemble(compiler.object(contractName).bytecode);
+ contractData["metadata"] = compiler.onChainMetadata(contractName);
contractData["functionHashes"] = functionHashes(compiler.contractDefinition(contractName));
contractData["gasEstimates"] = estimateGas(compiler, contractName);
auto sourceMap = compiler.sourceMapping(contractName);