renamed extensions for output files

Conflicts:
	solc/CommandLineInterface.cpp
This commit is contained in:
Liana Husikyan 2015-08-10 12:49:28 +02:00
parent 96fb0f4534
commit 5cb639d3e0

View File

@ -54,32 +54,32 @@ namespace dev
namespace solidity namespace solidity
{ {
static string const g_argAbiStr = "json-abi"; static string const g_argAbiStr = "abi";
static string const g_argSolAbiStr = "sol-abi"; static string const g_argSolAbiStr = "interface";
static string const g_argSignatureHashes = "hashes"; static string const g_argSignatureHashes = "hashes";
static string const g_argGas = "gas"; static string const g_argGas = "gas";
static string const g_argAsmStr = "asm"; static string const g_argAsmStr = "asm";
static string const g_argAsmJsonStr = "asm-json"; static string const g_argAsmJsonStr = "asm-json";
static string const g_argAstStr = "ast"; static string const g_argAstStr = "ast";
static string const g_argAstJson = "ast-json"; static string const g_argAstJson = "ast-json";
static string const g_argBinaryStr = "binary"; static string const g_argBinaryStr = "bin";
static string const g_argCloneBinaryStr = "clone-binary"; static string const g_argCloneBinaryStr = "clone-bin";
static string const g_argOpcodesStr = "opcodes"; static string const g_argOpcodesStr = "opcodes";
static string const g_argNatspecDevStr = "natspec-dev"; static string const g_argNatspecDevStr = "devdoc";
static string const g_argNatspecUserStr = "natspec-user"; static string const g_argNatspecUserStr = "userdoc";
static string const g_argAddStandard = "add-std"; static string const g_argAddStandard = "add-std";
/// Possible arguments to for --combined-json /// Possible arguments to for --combined-json
static set<string> const g_combinedJsonArgs{ static set<string> const g_combinedJsonArgs{
"binary", "bin",
"clone-binary", "clone-bin",
"opcodes", "opcodes",
"json-abi", "abi",
"sol-abi", "interface",
"asm", "asm",
"ast", "ast",
"natspec-user", "userdoc",
"natspec-dev" "devdoc"
}; };
static void version() static void version()
@ -118,14 +118,13 @@ static bool needsHumanTargetedStdout(po::variables_map const& _args)
void CommandLineInterface::handleBinary(string const& _contract) void CommandLineInterface::handleBinary(string const& _contract)
{ {
<<<<<<< HEAD
if (m_args.count(g_argBinaryStr)) if (m_args.count(g_argBinaryStr))
{ {
if (m_args.count("output-dir")) if (m_args.count("output-dir"))
{ {
stringstream data; stringstream data;
data << toHex(m_compiler->getBytecode(_contract)); data << toHex(m_compiler->getBytecode(_contract));
createFile(_contract + ".binary", data.str()); createFile(_contract + ".bin", data.str());
} }
else else
{ {
@ -140,7 +139,7 @@ void CommandLineInterface::handleBinary(string const& _contract)
{ {
stringstream data; stringstream data;
data << toHex(m_compiler->getCloneBytecode(_contract)); data << toHex(m_compiler->getCloneBytecode(_contract));
createFile(_contract + ".clone_binary", data.str()); createFile(_contract + ".clone_bin", data.str());
} }
else else
{ {
@ -214,7 +213,7 @@ void CommandLineInterface::handleMeta(DocumentationType _type, string const& _co
break; break;
case DocumentationType::ABISolidityInterface: case DocumentationType::ABISolidityInterface:
argName = g_argSolAbiStr; argName = g_argSolAbiStr;
suffix = ".sol"; suffix = "_interface.sol";
title = "Contract Solidity ABI"; title = "Contract Solidity ABI";
break; break;
case DocumentationType::NatspecUser: case DocumentationType::NatspecUser:
@ -323,12 +322,12 @@ bool CommandLineInterface::parseArguments(int _argc, char** _argv)
("optimize-runs", po::value<unsigned>()->default_value(200), "Estimated number of contract runs for optimizer.") ("optimize-runs", po::value<unsigned>()->default_value(200), "Estimated number of contract runs for optimizer.")
("add-std", po::value<bool>()->default_value(false), "Add standard contracts") ("add-std", po::value<bool>()->default_value(false), "Add standard contracts")
("input-file", po::value<vector<string>>(), "input file") ("input-file", po::value<vector<string>>(), "input file")
("output-dir,o", po::value<string>(), "Output directory path")
( (
"combined-json", "combined-json",
po::value<string>()->value_name(boost::join(g_combinedJsonArgs, ",")), po::value<string>()->value_name(boost::join(g_combinedJsonArgs, ",")),
"Output a single json document containing the specified information, can be combined." "Output a single json document containing the specified information, can be combined."
) )
("output-dir,o", po::value<string>(), "Output directory path")
(g_argAstStr.c_str(), "Request to output the AST of the contract.") (g_argAstStr.c_str(), "Request to output the AST of the contract.")
(g_argAstJson.c_str(), "Request to output the AST of the contract in JSON format.") (g_argAstJson.c_str(), "Request to output the AST of the contract in JSON format.")
(g_argAsmStr.c_str(), "Request to output the EVM assembly of the contract.") (g_argAsmStr.c_str(), "Request to output the EVM assembly of the contract.")
@ -488,14 +487,14 @@ void CommandLineInterface::handleCombinedJSON()
for (string const& contractName: contracts) for (string const& contractName: contracts)
{ {
Json::Value contractData(Json::objectValue); Json::Value contractData(Json::objectValue);
if (requests.count("sol-abi")) if (requests.count("interface"))
contractData["sol-abi"] = m_compiler->getSolidityInterface(contractName); contractData["interface"] = m_compiler->getSolidityInterface(contractName);
if (requests.count("json-abi")) if (requests.count("abi"))
contractData["json-abi"] = m_compiler->getInterface(contractName); contractData["abi"] = m_compiler->getInterface(contractName);
if (requests.count("binary")) if (requests.count("bin"))
contractData["binary"] = toHex(m_compiler->getBytecode(contractName)); contractData["bin"] = toHex(m_compiler->getBytecode(contractName));
if (requests.count("clone-binary")) if (requests.count("clone-bin"))
contractData["clone-binary"] = toHex(m_compiler->getCloneBytecode(contractName)); contractData["clone-bin"] = toHex(m_compiler->getCloneBytecode(contractName));
if (requests.count("opcodes")) if (requests.count("opcodes"))
contractData["opcodes"] = eth::disassemble(m_compiler->getBytecode(contractName)); contractData["opcodes"] = eth::disassemble(m_compiler->getBytecode(contractName));
if (requests.count("asm")) if (requests.count("asm"))
@ -503,10 +502,10 @@ void CommandLineInterface::handleCombinedJSON()
ostringstream unused; ostringstream unused;
contractData["asm"] = m_compiler->streamAssembly(unused, contractName, m_sourceCodes, true); contractData["asm"] = m_compiler->streamAssembly(unused, contractName, m_sourceCodes, true);
} }
if (requests.count("natspec-dev")) if (requests.count("devdoc"))
contractData["natspec-dev"] = m_compiler->getMetadata(contractName, DocumentationType::NatspecDev); contractData["devdoc"] = m_compiler->getMetadata(contractName, DocumentationType::NatspecDev);
if (requests.count("natspec-user")) if (requests.count("userdoc"))
contractData["natspec-user"] = m_compiler->getMetadata(contractName, DocumentationType::NatspecUser); contractData["userdoc"] = m_compiler->getMetadata(contractName, DocumentationType::NatspecUser);
output["contracts"][contractName] = contractData; output["contracts"][contractName] = contractData;
} }
@ -552,6 +551,7 @@ void CommandLineInterface::handleAst(string const& _argStr)
for (auto const& sourceCode: m_sourceCodes) for (auto const& sourceCode: m_sourceCodes)
{ {
stringstream data; stringstream data;
string postfix = "";
if (_argStr == g_argAstStr) if (_argStr == g_argAstStr)
{ {
ASTPrinter printer(m_compiler->getAST(sourceCode.first), sourceCode.second); ASTPrinter printer(m_compiler->getAST(sourceCode.first), sourceCode.second);
@ -561,8 +561,9 @@ void CommandLineInterface::handleAst(string const& _argStr)
{ {
ASTJsonConverter converter(m_compiler->getAST(sourceCode.first)); ASTJsonConverter converter(m_compiler->getAST(sourceCode.first));
converter.print(data); converter.print(data);
postfix += "_json";
} }
createFile(sourceCode.first + ".ast", data.str()); createFile(sourceCode.first + postfix + ".ast", data.str());
} }
} }
else else