Update of /cvsroot/cpptool/rfta/src/rfta
In directory sc8-pr-cvs1:/tmp/cvs-serv1101/src/rfta
Modified Files:
IdentifierScope.h IdentifierScope.cpp
Log Message:
-- qualified identifier lookup added
Index: IdentifierScope.h
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/IdentifierScope.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** IdentifierScope.h 15 May 2003 16:25:40 -0000 1.1
--- IdentifierScope.h 6 Sep 2003 21:49:28 -0000 1.2
***************
*** 45,53 ****
IdentifierScopeWeakPtr getParentScope() const;
IdentifierScopeWeakPtr getRootScope() const;
bool hasSubScope( std::string scopeName ) const;
IdentifierScopePtr getSubScope(std::string scopeName) const;
! void addIdentifierDeclaration( std::string qualifiedName, ASTNodePtr declaration);
ASTNodePtr getIdentifierDeclaration( std::string qualifiedName ) const;
--- 45,57 ----
IdentifierScopeWeakPtr getParentScope() const;
IdentifierScopeWeakPtr getRootScope() const;
+
+ IdentifierScopePtr getQualifiedScope( std::string qualifiedName ) const;
bool hasSubScope( std::string scopeName ) const;
IdentifierScopePtr getSubScope(std::string scopeName) const;
! // TODO-1: define sub ranges for variables/types/classes/unions
! // TODO-2: add function to register "identifier uses"
! void addIdentifierDeclaration( std::string qualifiedName, ASTNodePtr declaration);
ASTNodePtr getIdentifierDeclaration( std::string qualifiedName ) const;
Index: IdentifierScope.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/IdentifierScope.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** IdentifierScope.cpp 15 May 2003 16:25:40 -0000 1.1
--- IdentifierScope.cpp 6 Sep 2003 21:49:28 -0000 1.2
***************
*** 163,165 ****
--- 163,203 ----
}
+ IdentifierScopePtr IdentifierScope::getQualifiedScope( std::string qualifiedName ) const
+ {
+ IdentifierScopePtr scopePtr = boost::make_shared( getRootScope() );
+ int pos;
+ do {
+ pos = qualifiedName.find(':');
+ std::string subScopeName;
+
+ if ( pos != std::string::npos )
+ {
+ // check validity of the name:
+ if ( pos == qualifiedName.length()-1 ||
+ qualifiedName[pos+1] != ':' )
+ throw IdentifierScopeException(IdentifierScopeException::InvalidIdentifierName);
+
+ if (pos==0)
+ { // skip root scope specification
+ qualifiedName = qualifiedName.substr(pos+2);
+ continue;
+ }
+
+ // find out sub scope:
+ subScopeName = qualifiedName.substr(0,pos);
+ qualifiedName = qualifiedName.substr(pos+2);
+
+ } else
+ subScopeName = qualifiedName;
+
+ if (!scopePtr->hasSubScope( subScopeName ))
+ throw IdentifierScopeException(IdentifierScopeException::WrongQualifiedIdentifier);
+
+ // move ptr to sub scope
+ scopePtr = scopePtr->getSubScope( subScopeName );
+
+ } while (pos != std::string::npos);
+ return scopePtr;
+ }
+
} // namespace Refactoring
|