mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge branch 'develop' into build_enhancement
This commit is contained in:
commit
5dc6d1112a
59
main.cpp
59
main.cpp
@ -59,7 +59,7 @@ void version()
|
|||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
string infile;
|
vector<string> infiles;
|
||||||
bool optimize = false;
|
bool optimize = false;
|
||||||
for (int i = 1; i < argc; ++i)
|
for (int i = 1; i < argc; ++i)
|
||||||
{
|
{
|
||||||
@ -71,49 +71,52 @@ int main(int argc, char** argv)
|
|||||||
else if (arg == "-V" || arg == "--version")
|
else if (arg == "-V" || arg == "--version")
|
||||||
version();
|
version();
|
||||||
else
|
else
|
||||||
infile = argv[i];
|
infiles.push_back(argv[i]);
|
||||||
}
|
}
|
||||||
string sourceCode;
|
map<string, string> sourceCodes;
|
||||||
if (infile.empty())
|
if (infiles.empty())
|
||||||
{
|
{
|
||||||
string s;
|
string s;
|
||||||
while (!cin.eof())
|
while (!cin.eof())
|
||||||
{
|
{
|
||||||
getline(cin, s);
|
getline(cin, s);
|
||||||
sourceCode.append(s);
|
sourceCodes["<stdin>"].append(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
sourceCode = asString(dev::contents(infile));
|
for (string const& infile: infiles)
|
||||||
|
sourceCodes[infile] = asString(dev::contents(infile));
|
||||||
|
|
||||||
CompilerStack compiler;
|
CompilerStack compiler;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
compiler.compile(sourceCode, optimize);
|
for (auto const& sourceCode: sourceCodes)
|
||||||
|
compiler.addSource(sourceCode.first, sourceCode.second);
|
||||||
|
compiler.compile(optimize);
|
||||||
}
|
}
|
||||||
catch (ParserError const& exception)
|
catch (ParserError const& exception)
|
||||||
{
|
{
|
||||||
SourceReferenceFormatter::printExceptionInformation(cerr, exception, "Parser error", compiler.getScanner());
|
SourceReferenceFormatter::printExceptionInformation(cerr, exception, "Parser error", compiler);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
catch (DeclarationError const& exception)
|
catch (DeclarationError const& exception)
|
||||||
{
|
{
|
||||||
SourceReferenceFormatter::printExceptionInformation(cerr, exception, "Declaration error", compiler.getScanner());
|
SourceReferenceFormatter::printExceptionInformation(cerr, exception, "Declaration error", compiler);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
catch (TypeError const& exception)
|
catch (TypeError const& exception)
|
||||||
{
|
{
|
||||||
SourceReferenceFormatter::printExceptionInformation(cerr, exception, "Type error", compiler.getScanner());
|
SourceReferenceFormatter::printExceptionInformation(cerr, exception, "Type error", compiler);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
catch (CompilerError const& exception)
|
catch (CompilerError const& exception)
|
||||||
{
|
{
|
||||||
SourceReferenceFormatter::printExceptionInformation(cerr, exception, "Compiler error", compiler.getScanner());
|
SourceReferenceFormatter::printExceptionInformation(cerr, exception, "Compiler error", compiler);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
catch (InternalCompilerError const& exception)
|
catch (InternalCompilerError const& exception)
|
||||||
{
|
{
|
||||||
SourceReferenceFormatter::printExceptionInformation(cerr, exception, "Internal compiler error", compiler.getScanner());
|
SourceReferenceFormatter::printExceptionInformation(cerr, exception, "Internal compiler error", compiler);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
catch (Exception const& exception)
|
catch (Exception const& exception)
|
||||||
@ -127,17 +130,27 @@ int main(int argc, char** argv)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << "Syntax tree for the contract:" << endl;
|
cout << "Syntax trees:" << endl << endl;
|
||||||
ASTPrinter printer(compiler.getAST(), sourceCode);
|
for (auto const& sourceCode: sourceCodes)
|
||||||
printer.print(cout);
|
{
|
||||||
cout << "EVM assembly:" << endl;
|
cout << endl << "======= " << sourceCode.first << " =======" << endl;
|
||||||
compiler.streamAssembly(cout);
|
ASTPrinter printer(compiler.getAST(sourceCode.first), sourceCode.second);
|
||||||
cout << "Opcodes:" << endl;
|
printer.print(cout);
|
||||||
cout << eth::disassemble(compiler.getBytecode()) << endl;
|
}
|
||||||
cout << "Binary: " << toHex(compiler.getBytecode()) << endl;
|
vector<string> contracts = compiler.getContractNames();
|
||||||
cout << "Interface specification: " << compiler.getJsonDocumentation(DocumentationType::ABI_INTERFACE) << endl;
|
cout << endl << "Contracts:" << endl;
|
||||||
cout << "Natspec user documentation: " << compiler.getJsonDocumentation(DocumentationType::NATSPEC_USER) << endl;
|
for (string const& contract: contracts)
|
||||||
cout << "Natspec developer documentation: " << compiler.getJsonDocumentation(DocumentationType::NATSPEC_DEV) << endl;
|
{
|
||||||
|
cout << endl << "======= " << contract << " =======" << endl
|
||||||
|
<< "EVM assembly:" << endl;
|
||||||
|
compiler.streamAssembly(cout, contract);
|
||||||
|
cout << "Opcodes:" << endl
|
||||||
|
<< eth::disassemble(compiler.getBytecode(contract)) << endl
|
||||||
|
<< "Binary: " << toHex(compiler.getBytecode(contract)) << endl
|
||||||
|
<< "Interface specification: " << compiler.getJsonDocumentation(contract, DocumentationType::ABI_INTERFACE) << endl
|
||||||
|
<< "Natspec user documentation: " << compiler.getJsonDocumentation(contract, DocumentationType::NATSPEC_USER) << endl
|
||||||
|
<< "Natspec developer documentation: " << compiler.getJsonDocumentation(contract, DocumentationType::NATSPEC_DEV) << endl;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user