aboutsummaryrefslogtreecommitdiffstats
path: root/CommandLineInterface.cpp
diff options
context:
space:
mode:
authorChristian <c@ethdev.com>2015-01-29 08:29:43 +0800
committerChristian <c@ethdev.com>2015-01-29 08:29:43 +0800
commitf4b52ebac1be0235b3ea54ad47fc8ed9d93c457f (patch)
tree8e459819388a1c4aa659be54a1c112c3a977c0d0 /CommandLineInterface.cpp
parenta07b3f1da8238686e15456e809522a4097b3fa01 (diff)
downloaddexon-solidity-f4b52ebac1be0235b3ea54ad47fc8ed9d93c457f.tar
dexon-solidity-f4b52ebac1be0235b3ea54ad47fc8ed9d93c457f.tar.gz
dexon-solidity-f4b52ebac1be0235b3ea54ad47fc8ed9d93c457f.tar.bz2
dexon-solidity-f4b52ebac1be0235b3ea54ad47fc8ed9d93c457f.tar.lz
dexon-solidity-f4b52ebac1be0235b3ea54ad47fc8ed9d93c457f.tar.xz
dexon-solidity-f4b52ebac1be0235b3ea54ad47fc8ed9d93c457f.tar.zst
dexon-solidity-f4b52ebac1be0235b3ea54ad47fc8ed9d93c457f.zip
Exclude standard contracts by default.
Diffstat (limited to 'CommandLineInterface.cpp')
-rw-r--r--CommandLineInterface.cpp41
1 files changed, 22 insertions, 19 deletions
diff --git a/CommandLineInterface.cpp b/CommandLineInterface.cpp
index 87edb24b..aa651eb4 100644
--- a/CommandLineInterface.cpp
+++ b/CommandLineInterface.cpp
@@ -61,6 +61,7 @@ static string const g_argBinaryStr = "binary";
static string const g_argOpcodesStr = "opcodes";
static string const g_argNatspecDevStr = "natspec-dev";
static string const g_argNatspecUserStr = "natspec-user";
+static string const g_argAddStandard = "add-std";
static void version()
{
@@ -116,13 +117,13 @@ void CommandLineInterface::handleBinary(string const& _contract)
if (outputToStdout(choice))
{
cout << "Binary: " << endl;
- cout << toHex(m_compiler.getBytecode(_contract)) << endl;
+ cout << toHex(m_compiler->getBytecode(_contract)) << endl;
}
if (outputToFile(choice))
{
ofstream outFile(_contract + ".binary");
- outFile << toHex(m_compiler.getBytecode(_contract));
+ outFile << toHex(m_compiler->getBytecode(_contract));
outFile.close();
}
}
@@ -133,14 +134,14 @@ void CommandLineInterface::handleOpcode(string const& _contract)
if (outputToStdout(choice))
{
cout << "Opcodes: " << endl;
- cout << eth::disassemble(m_compiler.getBytecode(_contract));
+ cout << eth::disassemble(m_compiler->getBytecode(_contract));
cout << endl;
}
if (outputToFile(choice))
{
ofstream outFile(_contract + ".opcode");
- outFile << eth::disassemble(m_compiler.getBytecode(_contract));
+ outFile << eth::disassemble(m_compiler->getBytecode(_contract));
outFile.close();
}
}
@@ -191,13 +192,13 @@ void CommandLineInterface::handleMeta(DocumentationType _type, string const& _co
if (outputToStdout(choice))
{
cout << title << endl;
- cout << m_compiler.getMetadata(_contract, _type) << endl;
+ cout << m_compiler->getMetadata(_contract, _type) << endl;
}
if (outputToFile(choice))
{
ofstream outFile(_contract + suffix);
- outFile << m_compiler.getMetadata(_contract, _type);
+ outFile << m_compiler->getMetadata(_contract, _type);
outFile.close();
}
}
@@ -211,6 +212,7 @@ bool CommandLineInterface::parseArguments(int argc, char** argv)
("help", "Show help message and exit")
("version", "Show version and exit")
("optimize", po::value<bool>()->default_value(false), "Optimize bytecode for size")
+ ("add-std", po::value<bool>()->default_value(false), "Add standard contracts")
("input-file", po::value<vector<string>>(), "input file")
(g_argAstStr.c_str(), po::value<OutputType>()->value_name("stdout|file|both"),
"Request to output the AST of the contract.")
@@ -292,31 +294,32 @@ bool CommandLineInterface::processInput()
m_sourceCodes[infile] = asString(dev::contents(infile));
}
+ m_compiler.reset(new CompilerStack(m_args["add-std"].as<bool>()));
try
{
for (auto const& sourceCode: m_sourceCodes)
- m_compiler.addSource(sourceCode.first, sourceCode.second);
+ m_compiler->addSource(sourceCode.first, sourceCode.second);
// TODO: Perhaps we should not compile unless requested
- m_compiler.compile(m_args["optimize"].as<bool>());
+ m_compiler->compile(m_args["optimize"].as<bool>());
}
catch (ParserError const& _exception)
{
- SourceReferenceFormatter::printExceptionInformation(cerr, _exception, "Parser error", m_compiler);
+ SourceReferenceFormatter::printExceptionInformation(cerr, _exception, "Parser error", *m_compiler);
return false;
}
catch (DeclarationError const& _exception)
{
- SourceReferenceFormatter::printExceptionInformation(cerr, _exception, "Declaration error", m_compiler);
+ SourceReferenceFormatter::printExceptionInformation(cerr, _exception, "Declaration error", *m_compiler);
return false;
}
catch (TypeError const& _exception)
{
- SourceReferenceFormatter::printExceptionInformation(cerr, _exception, "Type error", m_compiler);
+ SourceReferenceFormatter::printExceptionInformation(cerr, _exception, "Type error", *m_compiler);
return false;
}
catch (CompilerError const& _exception)
{
- SourceReferenceFormatter::printExceptionInformation(cerr, _exception, "Compiler error", m_compiler);
+ SourceReferenceFormatter::printExceptionInformation(cerr, _exception, "Compiler error", *m_compiler);
return false;
}
catch (InternalCompilerError const& _exception)
@@ -369,12 +372,12 @@ void CommandLineInterface::handleAst(string const& _argStr)
cout << endl << "======= " << sourceCode.first << " =======" << endl;
if (_argStr == g_argAstStr)
{
- ASTPrinter printer(m_compiler.getAST(sourceCode.first), sourceCode.second);
+ ASTPrinter printer(m_compiler->getAST(sourceCode.first), sourceCode.second);
printer.print(cout);
}
else
{
- ASTJsonConverter converter(m_compiler.getAST(sourceCode.first));
+ ASTJsonConverter converter(m_compiler->getAST(sourceCode.first));
converter.print(cout);
}
}
@@ -388,12 +391,12 @@ void CommandLineInterface::handleAst(string const& _argStr)
ofstream outFile(p.stem().string() + ".ast");
if (_argStr == g_argAstStr)
{
- ASTPrinter printer(m_compiler.getAST(sourceCode.first), sourceCode.second);
+ ASTPrinter printer(m_compiler->getAST(sourceCode.first), sourceCode.second);
printer.print(outFile);
}
else
{
- ASTJsonConverter converter(m_compiler.getAST(sourceCode.first));
+ ASTJsonConverter converter(m_compiler->getAST(sourceCode.first));
converter.print(outFile);
}
outFile.close();
@@ -408,7 +411,7 @@ void CommandLineInterface::actOnInput()
handleAst(g_argAstStr);
handleAst(g_argAstJson);
- vector<string> contracts = m_compiler.getContractNames();
+ vector<string> contracts = m_compiler->getContractNames();
for (string const& contract: contracts)
{
if (needStdout(m_args))
@@ -421,13 +424,13 @@ void CommandLineInterface::actOnInput()
if (outputToStdout(choice))
{
cout << "EVM assembly:" << endl;
- m_compiler.streamAssembly(cout, contract);
+ m_compiler->streamAssembly(cout, contract);
}
if (outputToFile(choice))
{
ofstream outFile(contract + ".evm");
- m_compiler.streamAssembly(outFile, contract);
+ m_compiler->streamAssembly(outFile, contract);
outFile.close();
}
}