From d71cd3aa2b235f877b7928b57c94159e2c16865c Mon Sep 17 00:00:00 2001 From: chriseth Date: Sun, 22 Nov 2015 20:39:10 +0100 Subject: Added the `using x for y` directive. --- libsolidity/analysis/NameAndTypeResolver.h | 4 ++-- libsolidity/analysis/TypeChecker.cpp | 11 ++++++++++- libsolidity/analysis/TypeChecker.h | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) (limited to 'libsolidity/analysis') diff --git a/libsolidity/analysis/NameAndTypeResolver.h b/libsolidity/analysis/NameAndTypeResolver.h index 0d9b2477..1547a274 100644 --- a/libsolidity/analysis/NameAndTypeResolver.h +++ b/libsolidity/analysis/NameAndTypeResolver.h @@ -160,8 +160,8 @@ private: void fatalDeclarationError(SourceLocation _sourceLocation, std::string const& _description); std::map& m_scopes; - Declaration const* m_currentScope; - VariableScope* m_currentFunction; + Declaration const* m_currentScope = nullptr; + VariableScope* m_currentFunction = nullptr; ErrorList& m_errors; }; diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 1d2d0258..22fb1e96 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -356,7 +356,16 @@ void TypeChecker::endVisit(InheritanceSpecifier const& _inheritance) " to " + parameterTypes[i]->toString() + " requested." - ); + ); +} + +void TypeChecker::endVisit(UsingForDirective const& _usingFor) +{ + ContractDefinition const* library = dynamic_cast( + _usingFor.libraryName().annotation().referencedDeclaration + ); + if (!library || !library->isLibrary()) + typeError(_usingFor.libraryName().location(), "Library name expected."); } bool TypeChecker::visit(StructDefinition const& _struct) diff --git a/libsolidity/analysis/TypeChecker.h b/libsolidity/analysis/TypeChecker.h index 9563d4a9..7829a23d 100644 --- a/libsolidity/analysis/TypeChecker.h +++ b/libsolidity/analysis/TypeChecker.h @@ -76,6 +76,7 @@ private: void checkLibraryRequirements(ContractDefinition const& _contract); virtual void endVisit(InheritanceSpecifier const& _inheritance) override; + virtual void endVisit(UsingForDirective const& _usingFor) override; virtual bool visit(StructDefinition const& _struct) override; virtual bool visit(FunctionDefinition const& _function) override; virtual bool visit(VariableDeclaration const& _variable) override; -- cgit