From 445ba10d3b9fc41591b9fb7a52e0fe862a10e7e7 Mon Sep 17 00:00:00 2001 From: Christian Date: Wed, 3 Dec 2014 17:45:12 +0100 Subject: Multi-source and multi-contract compiler. --- solidityCompiler.cpp | 3 ++- solidityExpressionCompiler.cpp | 3 ++- solidityNameAndTypeResolution.cpp | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/solidityCompiler.cpp b/solidityCompiler.cpp index 883cecf2..9862cba8 100644 --- a/solidityCompiler.cpp +++ b/solidityCompiler.cpp @@ -48,10 +48,11 @@ bytes compileContract(const string& _sourceCode) Parser parser; ASTPointer sourceUnit; BOOST_REQUIRE_NO_THROW(sourceUnit = parser.parse(make_shared(CharStream(_sourceCode)))); + NameAndTypeResolver resolver({}); + resolver.registerDeclarations(*sourceUnit); for (ASTPointer const& node: sourceUnit->getNodes()) if (ContractDefinition* contract = dynamic_cast(node.get())) { - NameAndTypeResolver resolver({}); BOOST_REQUIRE_NO_THROW(resolver.resolveNamesAndTypes(*contract)); Compiler compiler; diff --git a/solidityExpressionCompiler.cpp b/solidityExpressionCompiler.cpp index b077e262..cb22d512 100644 --- a/solidityExpressionCompiler.cpp +++ b/solidityExpressionCompiler.cpp @@ -88,10 +88,11 @@ bytes compileFirstExpression(const string& _sourceCode, vector> _ Parser parser; ASTPointer sourceUnit; BOOST_REQUIRE_NO_THROW(sourceUnit = parser.parse(make_shared(CharStream(_sourceCode)))); + NameAndTypeResolver resolver({}); + resolver.registerDeclarations(*sourceUnit); for (ASTPointer const& node: sourceUnit->getNodes()) if (ContractDefinition* contract = dynamic_cast(node.get())) { - NameAndTypeResolver resolver({}); BOOST_REQUIRE_NO_THROW(resolver.resolveNamesAndTypes(*contract)); FirstExpressionExtractor extractor(*contract); BOOST_REQUIRE(extractor.getExpression() != nullptr); diff --git a/solidityNameAndTypeResolution.cpp b/solidityNameAndTypeResolution.cpp index 219fa259..74af19b8 100644 --- a/solidityNameAndTypeResolution.cpp +++ b/solidityNameAndTypeResolution.cpp @@ -42,10 +42,11 @@ void parseTextAndResolveNames(std::string const& _source) { Parser parser; ASTPointer sourceUnit = parser.parse(std::make_shared(CharStream(_source))); + NameAndTypeResolver resolver({}); + resolver.registerDeclarations(*sourceUnit); for (ASTPointer const& node: sourceUnit->getNodes()) if (ContractDefinition* contract = dynamic_cast(node.get())) { - NameAndTypeResolver resolver({}); resolver.resolveNamesAndTypes(*contract); } } -- cgit v1.2.3