diff options
author | Christian <c@ethdev.com> | 2014-11-05 21:20:56 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2014-11-05 22:01:24 +0800 |
commit | 8c384232eb6c729021a5bd89bd2eccea7c2af34c (patch) | |
tree | 4599da98b15a2ee0ff0e46cf37c3373b10e3eb2c | |
parent | 245efb0280cecaa703cd6f3166a6d935a4cae773 (diff) | |
download | dexon-solidity-8c384232eb6c729021a5bd89bd2eccea7c2af34c.tar dexon-solidity-8c384232eb6c729021a5bd89bd2eccea7c2af34c.tar.gz dexon-solidity-8c384232eb6c729021a5bd89bd2eccea7c2af34c.tar.bz2 dexon-solidity-8c384232eb6c729021a5bd89bd2eccea7c2af34c.tar.lz dexon-solidity-8c384232eb6c729021a5bd89bd2eccea7c2af34c.tar.xz dexon-solidity-8c384232eb6c729021a5bd89bd2eccea7c2af34c.tar.zst dexon-solidity-8c384232eb6c729021a5bd89bd2eccea7c2af34c.zip |
Converted all asserts to exceptions.
-rw-r--r-- | main.cpp | 45 |
1 files changed, 27 insertions, 18 deletions
@@ -84,21 +84,27 @@ int main(int argc, char** argv) ASTPointer<ContractDefinition> ast; shared_ptr<Scanner> scanner = make_shared<Scanner>(CharStream(sourceCode)); Parser parser; + bytes instructions; + Compiler compiler; try { 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) { SourceReferenceFormatter::printExceptionInformation(cerr, exception, "Parser error", *scanner); return -1; } - - NameAndTypeResolver resolver; - try - { - resolver.resolveNamesAndTypes(*ast.get()); - } catch (DeclarationError const& exception) { SourceReferenceFormatter::printExceptionInformation(cerr, exception, "Declaration error", *scanner); @@ -109,23 +115,26 @@ int main(int argc, char** argv) SourceReferenceFormatter::printExceptionInformation(cerr, exception, "Type error", *scanner); 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) { SourceReferenceFormatter::printExceptionInformation(cerr, exception, "Compiler error", *scanner); 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; compiler.streamAssembly(cout); |