mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Converted all asserts to exceptions.
This commit is contained in:
parent
245efb0280
commit
8c384232eb
45
main.cpp
45
main.cpp
@ -84,21 +84,27 @@ int main(int argc, char** argv)
|
|||||||
ASTPointer<ContractDefinition> ast;
|
ASTPointer<ContractDefinition> ast;
|
||||||
shared_ptr<Scanner> scanner = make_shared<Scanner>(CharStream(sourceCode));
|
shared_ptr<Scanner> scanner = make_shared<Scanner>(CharStream(sourceCode));
|
||||||
Parser parser;
|
Parser parser;
|
||||||
|
bytes instructions;
|
||||||
|
Compiler compiler;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ast = parser.parse(scanner);
|
ast = parser.parse(scanner);
|
||||||
|
|
||||||
|
NameAndTypeResolver resolver;
|
||||||
|
resolver.resolveNamesAndTypes(*ast.get());
|
||||||
|
|
||||||
|
cout << "Syntax tree for the contract:" << endl;
|
||||||
|
dev::solidity::ASTPrinter printer(ast, sourceCode);
|
||||||
|
printer.print(cout);
|
||||||
|
|
||||||
|
compiler.compileContract(*ast);
|
||||||
|
instructions = compiler.getAssembledBytecode();
|
||||||
}
|
}
|
||||||
catch (ParserError const& exception)
|
catch (ParserError const& exception)
|
||||||
{
|
{
|
||||||
SourceReferenceFormatter::printExceptionInformation(cerr, exception, "Parser error", *scanner);
|
SourceReferenceFormatter::printExceptionInformation(cerr, exception, "Parser error", *scanner);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
NameAndTypeResolver resolver;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
resolver.resolveNamesAndTypes(*ast.get());
|
|
||||||
}
|
|
||||||
catch (DeclarationError const& exception)
|
catch (DeclarationError const& exception)
|
||||||
{
|
{
|
||||||
SourceReferenceFormatter::printExceptionInformation(cerr, exception, "Declaration error", *scanner);
|
SourceReferenceFormatter::printExceptionInformation(cerr, exception, "Declaration error", *scanner);
|
||||||
@ -109,23 +115,26 @@ int main(int argc, char** argv)
|
|||||||
SourceReferenceFormatter::printExceptionInformation(cerr, exception, "Type error", *scanner);
|
SourceReferenceFormatter::printExceptionInformation(cerr, exception, "Type error", *scanner);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << "Syntax tree for the contract:" << endl;
|
|
||||||
dev::solidity::ASTPrinter printer(ast, sourceCode);
|
|
||||||
printer.print(cout);
|
|
||||||
|
|
||||||
bytes instructions;
|
|
||||||
Compiler compiler;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
compiler.compileContract(*ast);
|
|
||||||
instructions = compiler.getAssembledBytecode();
|
|
||||||
}
|
|
||||||
catch (CompilerError const& exception)
|
catch (CompilerError const& exception)
|
||||||
{
|
{
|
||||||
SourceReferenceFormatter::printExceptionInformation(cerr, exception, "Compiler error", *scanner);
|
SourceReferenceFormatter::printExceptionInformation(cerr, exception, "Compiler error", *scanner);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
catch (InternalCompilerError const& exception)
|
||||||
|
{
|
||||||
|
cerr << "Internal compiler error: " << boost::diagnostic_information(exception) << endl;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
catch (Exception const& exception)
|
||||||
|
{
|
||||||
|
cerr << "Exception during compilation: " << boost::diagnostic_information(exception) << endl;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
cerr << "Unknown exception during compilation." << endl;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
cout << "EVM assembly:" << endl;
|
cout << "EVM assembly:" << endl;
|
||||||
compiler.streamAssembly(cout);
|
compiler.streamAssembly(cout);
|
||||||
|
Loading…
Reference in New Issue
Block a user