You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(37) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(15) |
Feb
(26) |
Mar
(97) |
Apr
(224) |
May
(226) |
Jun
|
Jul
(3) |
Aug
(22) |
Sep
(48) |
Oct
|
Nov
|
Dec
(38) |
2004 |
Jan
(28) |
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
(37) |
Jul
|
Aug
(73) |
Sep
|
Oct
|
Nov
|
Dec
|
From: <net...@us...> - 2003-12-16 13:21:12
|
Update of /cvsroot/cpptool/rfta/include/rfta/parser In directory sc8-pr-cvs1:/tmp/cvs-serv24442/rfta/include/rfta/parser Modified Files: ASTNodes.h Log Message: -- additional ast nodes for symbols. Index: ASTNodes.h =================================================================== RCS file: /cvsroot/cpptool/rfta/include/rfta/parser/ASTNodes.h,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** ASTNodes.h 6 Sep 2003 21:46:20 -0000 1.23 --- ASTNodes.h 16 Dec 2003 13:21:08 -0000 1.24 *************** *** 246,250 **** static const ASTNodeProperty enumBodyProperty; static const ASTNodeProperty classBodyProperty; ! static const ASTNodeProperty classNameProperty; static const ASTNodeProperty macroIdentifier; --- 246,250 ---- static const ASTNodeProperty enumBodyProperty; static const ASTNodeProperty classBodyProperty; ! static const ASTNodeProperty compositeNameProperty; static const ASTNodeProperty macroIdentifier; |
From: <net...@us...> - 2003-12-16 13:20:38
|
Update of /cvsroot/cpptool/rfta/doc In directory sc8-pr-cvs1:/tmp/cvs-serv24364/rfta/doc Modified Files: AbstractSyntaxSTreeStructure.txt Log Message: -- described additional ast nodes for symbols. Index: AbstractSyntaxSTreeStructure.txt =================================================================== RCS file: /cvsroot/cpptool/rfta/doc/AbstractSyntaxSTreeStructure.txt,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** AbstractSyntaxSTreeStructure.txt 3 May 2003 21:52:14 -0000 1.10 --- AbstractSyntaxSTreeStructure.txt 16 Dec 2003 13:20:35 -0000 1.11 *************** *** 74,91 **** declarator-property => [unparsed-declarator] , [declarator] - [unparsed-declarator] - variable-name-property => [#variable-identifier-expression] - #mutate: declarator - - [declarator] - variable-name-property => [#variable-identifier-expression] - ?sub-declarator-property => [declarator] // declarators are organized hierarchical - declarator-type-property => - [function-declarator], // ... (...) - [array-declarator] // ... [...] - [#braces] // (...) - [ptr-declarator] // * ... - [#declarator-identifier] // user::x - {declaration-specifier} [#simple-type-specifier] // "simple-type-specifier" (char, wchar_t, bool, etc.) also "cv-qualifier" ---> see C++ Spec. --- 74,77 ---- *************** *** 94,100 **** [elaborated-type-specifier] // something like "class xxx", "struct y" or simply "UserTypePtr" [enum-specifier] enumeration-body-property => [enum-body] ! ... ? // some other stuffs ? [enum-body] --- 80,90 ---- [elaborated-type-specifier] // something like "class xxx", "struct y" or simply "UserTypePtr" + [class-specifier] + class-body-property => [unparsed-declaration-list] + compositeNameProperty => [local-scope-identifier] + [enum-specifier] enumeration-body-property => [enum-body] ! compositeNameProperty => [local-scope-identifier] [enum-body] *************** *** 102,107 **** [enum-constant] ! variable-name-property => [#variable-identifier-expression] ?variable-initializer-property => [assign-variable-initializer] [ptr-declarator] --- 92,112 ---- [enum-constant] ! variable-name-property => [#local-Scope-identifier] ?variable-initializer-property => [assign-variable-initializer] + + + [unparsed-declarator] + variable-name-property => [#variable-identifier-expression] + #mutate: declarator + + [declarator] + declarator-type-property => /* not yet implemented */ + [function-declarator], // ...(...) + [array-declarator] // ...[...] + [#braces] // (...) <-- is this needed ??? + [ptr-declarator] // * ... + [#declarator-identifier] // user::x + ?sub-declarator-property => [declarator] /* not yet implemented: declarators are organized hierarchical */ + [local-scope-identifier] // identifier of declarator [ptr-declarator] |
From: <net...@us...> - 2003-09-25 12:57:42
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv18860/rfta Modified Files: GlobalIdentifierResolver.h GlobalIdentifierResolver.cpp Log Message: -- extended global resolver for enumeration type Index: GlobalIdentifierResolver.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/GlobalIdentifierResolver.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** GlobalIdentifierResolver.h 6 Sep 2003 21:45:57 -0000 1.1 --- GlobalIdentifierResolver.h 24 Sep 2003 20:38:15 -0000 1.2 *************** *** 38,41 **** --- 38,45 ---- private: IdentifierResolverStrategy &context_; + + void visitClassSpecifier( const ASTNodePtr &node ); + void visitEnumSpecifier ( const ASTNodePtr &node ); + }; Index: GlobalIdentifierResolver.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/GlobalIdentifierResolver.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** GlobalIdentifierResolver.cpp 15 Sep 2003 09:18:23 -0000 1.2 --- GlobalIdentifierResolver.cpp 24 Sep 2003 20:38:15 -0000 1.3 *************** *** 14,41 **** void GlobalIdentifierResolver::visitNode( const ASTNodePtr &node ) { - // actions before visiting properties and childs if (node->getType() == ASTNodeTypes::classSpecifier) { ! // add namespace ! if (node->hasProperty(ASTNodeProperties::classNameProperty)) ! { // named classes ! ASTNodePtr classIdent = node->getProperty(ASTNodeProperties::classNameProperty); ! ASTNodePtr classBody = node->getProperty(ASTNodeProperties::classBodyProperty); ! // add class definition reference... ! context_.declareIdentifier(classIdent,IdentifierAttributes::ClassIdentifier); ! ! std::string ident = classIdent->getBlankedText(); ! context_.enterNamedSubScope(ident); ! ASTNodeAndPropertyVisitor::visitProperty(ASTNodeProperties::classBodyProperty,classBody); ! context_.leaveNamedSubScope(); ! } else ! { // unnamed classes: ! context_.enterUnnamedSubScope(); ! ASTNodeAndPropertyVisitor::visitNode(node); ! context_.leaveNamedSubScope(); ! } } else { --- 14,68 ---- void + GlobalIdentifierResolver::visitClassSpecifier( const ASTNodePtr &node ) + { + // add namespace + if (node->hasProperty(ASTNodeProperties::compositeNameProperty)) + { // named classes + ASTNodePtr classIdent = node->getProperty(ASTNodeProperties::compositeNameProperty); + ASTNodePtr classBody = node->getProperty(ASTNodeProperties::classBodyProperty); + // add class definition reference... + context_.declareIdentifier(classIdent,IdentifierAttributes::ClassIdentifier); + + std::string ident = classIdent->getBlankedText(); + context_.enterNamedSubScope(ident); + ASTNodeAndPropertyVisitor::visitProperty(ASTNodeProperties::classBodyProperty,classBody); + context_.leaveNamedSubScope(); + } else + { // unnamed classes: + context_.enterUnnamedSubScope(); + ASTNodeAndPropertyVisitor::visitNode(node); + context_.leaveNamedSubScope(); + } + } + + void + GlobalIdentifierResolver::visitEnumSpecifier( const ASTNodePtr &node ) + { + // check for enumeration name: + if (node->hasProperty(ASTNodeProperties::compositeNameProperty)) + { + ASTNodePtr enumIdent = node->getProperty(ASTNodeProperties::compositeNameProperty); + + // add enum definition reference... + context_.declareIdentifier(enumIdent,IdentifierAttributes::EnumIdentifier); + } + + // visit enumeration body: + ASTNodePtr enumBody = node->getProperty(ASTNodeProperties::enumBodyProperty); + ASTNodeAndPropertyVisitor::visitNode(enumBody); + + } + + void GlobalIdentifierResolver::visitNode( const ASTNodePtr &node ) { if (node->getType() == ASTNodeTypes::classSpecifier) { ! visitClassSpecifier( node ); } + else if (node->getType() == ASTNodeTypes::enumSpecifier) + { + visitEnumSpecifier( node ); + } else { |
From: <net...@us...> - 2003-09-25 02:47:24
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv19088/rftaparser Modified Files: DeclarationDetailsParser.h DeclarationDetailsParser.cpp Log Message: -- corrections for parsing composite types Index: DeclarationDetailsParser.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/DeclarationDetailsParser.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** DeclarationDetailsParser.h 6 Sep 2003 21:43:43 -0000 1.8 --- DeclarationDetailsParser.h 24 Sep 2003 20:39:27 -0000 1.9 *************** *** 53,69 **** const ASTNodePtr &specifierList ); ! void addAnonymousClassNodeAndReadBody( int specifierStart, const ASTNodePtr &specifierList, const std::string &specifierIdent ); ! void addNamedClassNodeAndReadBody( int specifierStart, ! int nameIdentStart, ! const ASTNodePtr &specifierList, ! const std::string &specifierIdent ); ! ! void addNestedNameClassNodeAndReadBody( int specifierStart, ! const ASTNodePtr &specifierList, ! const std::string &specifierIdent, ! const std::string &baseName ); --- 53,69 ---- const ASTNodePtr &specifierList ); ! void addAnonymousCompositeTypeAndReadBody( int specifierStart, ! const ASTNodePtr &specifierList, ! const std::string &specifierIdent ); ! ! void addNamedCompositeTypeAndReadBody( int specifierStart, ! int nameIdentStart, const ASTNodePtr &specifierList, const std::string &specifierIdent ); ! void addNestedNameClassNode( int specifierStart, ! const ASTNodePtr &specifierList, ! const std::string &specifierIdent, ! const std::string &baseName ); Index: DeclarationDetailsParser.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/DeclarationDetailsParser.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** DeclarationDetailsParser.cpp 6 Sep 2003 21:43:43 -0000 1.13 --- DeclarationDetailsParser.cpp 24 Sep 2003 20:39:27 -0000 1.14 *************** *** 228,232 **** { if (!tryNextIs(':')) ! throwFailure( "A class name can not start with a single ':'. Expected a double colon => '::'." ); readElaboratedTypeName( specifierStart, specifierList ); --- 228,232 ---- { if (!tryNextIs(':')) ! throwFailure( "Expected an identifier. Can not start with a single colon. Expected a double colon => '::'." ); readElaboratedTypeName( specifierStart, specifierList ); *************** *** 249,256 **** Xtl::CStringView thirdIdent; // in the case of export macro: class RFTA_API SourceRange {}; if ( tryReadNextIdentifier( thirdIdent ) ) { skipSpaces(); ! secondIdent = thirdIdent; // @todo ignore export macro for now, will need to store it. } --- 249,292 ---- Xtl::CStringView thirdIdent; // in the case of export macro: class RFTA_API SourceRange {}; + const char* sav_cur = current_; + if ( tryReadNextIdentifier( thirdIdent ) ) { skipSpaces(); ! if (tryNextIs('{')) ! { ! current_--; ! secondIdent = thirdIdent; // @todo ignore export macro for now, will need to store it. ! } else if (tryNextIs(';')) ! { ! // is not a type-use with variable "e.g. class WINAPI X;" ! current_--; ! } else ! { ! // restore current pointer since third identifier is a variable e.g. "enum X y;" ! current_ = sav_cur; ! backtrackSkippingSpaces(); ! ! // add the specifier node ! ASTNodePtr specifier = ! createASTNode( ! ASTNodeTypes::elaboratedTypeSpecifier, ! specifierList, ! specifierStart, ! getCurrentIndex()-specifierStart ! ); ! specifierList->addChild(specifier); ! ! ASTNodePtr nameNode = ! createASTNode( ! ASTNodeTypes::localScopeIdentifier, ! specifier, ! nameIdentStart,secondIdent.getLength()); ! specifier->setPropertyNode( ASTNodeProperties::compositeNameProperty , nameNode ); ! ! // set real length after completed parsing ! specifier->setLength(getCurrentIndex()-specifierStart); ! return; ! } } *************** *** 258,269 **** if ( secondIdent.isEmpty() ) { ! addAnonymousClassNodeAndReadBody( specifierStart, specifierList, specifierIdent ); return; } ! // check only a single colon follows (which means inheritance information e.g. "class x: public y ") if (!tryReadNext("::")) { ! addNamedClassNodeAndReadBody( specifierStart, nameIdentStart, specifierList, specifierIdent ); return; } --- 294,305 ---- if ( secondIdent.isEmpty() ) { ! addAnonymousCompositeTypeAndReadBody( specifierStart, specifierList, specifierIdent ); return; } ! // check if no composite type start if (!tryReadNext("::")) { ! addNamedCompositeTypeAndReadBody( specifierStart, nameIdentStart, specifierList, specifierIdent ); return; } *************** *** 271,284 **** // HERE we come only in case of a double colon after the identifier which means: // an elaborated type is specified: e.g. "class x::y" ! addNestedNameClassNodeAndReadBody( specifierStart, specifierList, specifierIdent, secondIdent.str() ); } void ! DeclarationDetailsParser::addNestedNameClassNodeAndReadBody( int specifierStart, const ASTNodePtr &specifierList, const std::string &specifierIdent, const std::string &baseName ) { std::string secondIdent = baseName; skipSpaces(); --- 307,321 ---- // HERE we come only in case of a double colon after the identifier which means: // an elaborated type is specified: e.g. "class x::y" ! addNestedNameClassNode( specifierStart, specifierList, specifierIdent, secondIdent.str() ); } void ! DeclarationDetailsParser::addNestedNameClassNode( int specifierStart, const ASTNodePtr &specifierList, const std::string &specifierIdent, const std::string &baseName ) { + int identStart = getCurrentIndex()-baseName.length(); std::string secondIdent = baseName; skipSpaces(); *************** *** 287,290 **** --- 324,328 ---- secondIdent.append("::"); readNestedName(secondIdent); + int identLen = getCurrentIndex()-identStart; // add the specifier node *************** *** 299,302 **** --- 337,347 ---- // set real length after completed parsing specifier->setLength(getCurrentIndex()-specifierStart); + + ASTNodePtr nameNode = + createASTNode( + ASTNodeTypes::localScopeIdentifier, + specifier, + identStart,identLen); + specifier->setPropertyNode( ASTNodeProperties::compositeNameProperty , nameNode ); } *************** *** 321,325 **** void ! DeclarationDetailsParser::addAnonymousClassNodeAndReadBody( int specifierStart, const ASTNodePtr &specifierList, const std::string &specifierIdent ) --- 366,370 ---- void ! DeclarationDetailsParser::addAnonymousCompositeTypeAndReadBody( int specifierStart, const ASTNodePtr &specifierList, const std::string &specifierIdent ) *************** *** 344,348 **** void ! DeclarationDetailsParser::addNamedClassNodeAndReadBody( int specifierStart, int secondIdentStart, const ASTNodePtr &specifierList, --- 389,393 ---- void ! DeclarationDetailsParser::addNamedCompositeTypeAndReadBody( int specifierStart, int secondIdentStart, const ASTNodePtr &specifierList, *************** *** 366,378 **** getCurrentIndex()-secondIdentStart ); ! specifier->setPropertyNode( ASTNodeProperties::classNameProperty , ident ); skipSpaces(); // check if this is a forward declaration "class x::y;" ! if ( !tryNextIs(';') ) { // read the complete specifier: readClassOrEnumSpecifier( specifier, specifierIdent ); } --- 411,427 ---- getCurrentIndex()-secondIdentStart ); ! specifier->setPropertyNode( ASTNodeProperties::compositeNameProperty , ident ); skipSpaces(); // check if this is a forward declaration "class x::y;" ! if ( !tryNextIs(';') ) { // read the complete specifier: readClassOrEnumSpecifier( specifier, specifierIdent ); + } else + { + current_--; + backtrackSkippingSpaces(); } |
From: <net...@us...> - 2003-09-25 01:02:33
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv19491/rftaparser Modified Files: ASTNodes.cpp Log Message: -- compositeName for enum/struct/class etc. Index: ASTNodes.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/ASTNodes.cpp,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** ASTNodes.cpp 15 Sep 2003 09:17:05 -0000 1.27 --- ASTNodes.cpp 24 Sep 2003 20:40:53 -0000 1.28 *************** *** 124,128 **** const ASTNodeProperty ASTNodeProperties::enumBodyProperty ( "enumeration-body-property" ); const ASTNodeProperty ASTNodeProperties::classBodyProperty( "class-body-property" ); ! const ASTNodeProperty ASTNodeProperties::classNameProperty( "class-name-property" ); const ASTNodeProperty ASTNodeProperties::macroIdentifier( "macro-identifier-property" ); const ASTNodeProperty ASTNodeProperties::macroParameters( "macro-parameters-property" ); --- 124,128 ---- const ASTNodeProperty ASTNodeProperties::enumBodyProperty ( "enumeration-body-property" ); const ASTNodeProperty ASTNodeProperties::classBodyProperty( "class-body-property" ); ! const ASTNodeProperty ASTNodeProperties::compositeNameProperty( "composite-name-property" ); const ASTNodeProperty ASTNodeProperties::macroIdentifier( "macro-identifier-property" ); const ASTNodeProperty ASTNodeProperties::macroParameters( "macro-parameters-property" ); |
From: <net...@us...> - 2003-09-24 20:34:40
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv16829/rfta Modified Files: IdentifierResolverTest.h IdentifierResolverTest.cpp Log Message: -- added enum-test Index: IdentifierResolverTest.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/IdentifierResolverTest.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** IdentifierResolverTest.h 6 Sep 2003 21:50:51 -0000 1.6 --- IdentifierResolverTest.h 24 Sep 2003 20:34:37 -0000 1.7 *************** *** 29,32 **** --- 29,33 ---- CPPUNIT_TEST( testSwitchScope ); CPPUNIT_TEST( testClassScope ); + CPPUNIT_TEST( testEnumIdentifiers ); CPPUNIT_TEST( testBug1 ); CPPUNIT_TEST_SUITE_END(); *************** *** 49,54 **** void testSwitchScope(); void testClassScope(); - void testBug1(); private: --- 50,55 ---- void testSwitchScope(); void testClassScope(); void testBug1(); + void testEnumIdentifiers(); private: Index: IdentifierResolverTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/IdentifierResolverTest.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** IdentifierResolverTest.cpp 15 Sep 2003 09:22:05 -0000 1.9 --- IdentifierResolverTest.cpp 24 Sep 2003 20:34:37 -0000 1.10 *************** *** 332,335 **** --- 332,365 ---- } + void IdentifierResolverTest::testEnumIdentifiers() + { + builder_->addKeyingMid( "enum ", "en", " {", "en.0" ); + builder_->addKeyingMid( "", "key1", "=0,", "key1.0" ); + builder_->addKeyingMid( "", "key2", ",", "key2.0" ); + builder_->addKeyingMid( "", "key3", "=1,", "key3.0" ); + builder_->add( "};" ); + builder_->addKeyingMid( "enum ", "en", " " , "en.1" ); + builder_->addKeyingMid( "", "var", "=" , "var.0" ); + builder_->addKeyingMid( "", "key1", ";" , "key1.1" ); + + parse((DeclarationListParser*)0); + + strategy_->setRecordMode(); + strategy_->declareIdentifier( getIdentifierNode( "en.0" ), IdentifierAttributes::EnumIdentifier ); + + //TODO: add identifiers for enumeration elements: + //strategy_->declareIdentifier( getIdentifierNode( "key1.0" ), IdentifierAttributes::NoAttribute ); + //strategy_->declareIdentifier( getIdentifierNode( "key2.0" ), IdentifierAttributes::NoAttribute ); + //strategy_->declareIdentifier( getIdentifierNode( "key3.0" ), IdentifierAttributes::NoAttribute ); + + // TODO: change resolver strategy for elaborated-type-specifier + //strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "en.1" )); + strategy_->declareIdentifier( getIdentifierNode( "var.0" ), IdentifierAttributes::NoAttribute ); + + // TODO: change resolver strategy for assignment in declarator + //strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "key1.1" )); + + checkResolution(); + } } // namespace Refactoring |
From: <net...@us...> - 2003-09-24 20:30:16
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv15370/rftaparser Modified Files: UnparsedDeclarationMutatorTest.h UnparsedDeclarationMutatorTest.cpp Log Message: -- corrected some tests -- added enum-test Index: UnparsedDeclarationMutatorTest.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/UnparsedDeclarationMutatorTest.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** UnparsedDeclarationMutatorTest.h 6 Sep 2003 21:35:59 -0000 1.10 --- UnparsedDeclarationMutatorTest.h 24 Sep 2003 20:29:59 -0000 1.11 *************** *** 27,30 **** --- 27,31 ---- CPPUNIT_TEST( testEnumDeclaration ); CPPUNIT_TEST( testUnamedEnumDeclaration ); + CPPUNIT_TEST( testEnumTypeUse ); CPPUNIT_TEST( testPointerDecl ); CPPUNIT_TEST( testFctPointer ); *************** *** 75,78 **** --- 76,80 ---- void testEnumDeclaration(); void testUnamedEnumDeclaration(); + void testEnumTypeUse(); void testPointerDecl(); void testFctPointer(); Index: UnparsedDeclarationMutatorTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/UnparsedDeclarationMutatorTest.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** UnparsedDeclarationMutatorTest.cpp 6 Sep 2003 21:35:59 -0000 1.15 --- UnparsedDeclarationMutatorTest.cpp 24 Sep 2003 20:29:59 -0000 1.16 *************** *** 231,235 **** // CHECK CLASS NAME PROPERTY: RFTA_ASSERT_NODE_PROPERTY_HAS( specifier, ! ASTNodeProperties::classNameProperty, ASTNodeTypes::localScopeIdentifier, source.getKeyedIndex("CLASS-NAME",0), --- 231,235 ---- // CHECK CLASS NAME PROPERTY: RFTA_ASSERT_NODE_PROPERTY_HAS( specifier, ! ASTNodeProperties::compositeNameProperty, ASTNodeTypes::localScopeIdentifier, source.getKeyedIndex("CLASS-NAME",0), *************** *** 273,277 **** // CHECK CLASS NAME PROPERTY: RFTA_ASSERT_NODE_PROPERTY_HAS( specifier, ! ASTNodeProperties::classNameProperty, ASTNodeTypes::localScopeIdentifier, source.getKeyedIndex("CLASS-NAME",0), --- 273,277 ---- // CHECK CLASS NAME PROPERTY: RFTA_ASSERT_NODE_PROPERTY_HAS( specifier, ! ASTNodeProperties::compositeNameProperty, ASTNodeTypes::localScopeIdentifier, source.getKeyedIndex("CLASS-NAME",0), *************** *** 315,319 **** { Testing::KeyedString source; ! source.addKeyed(SPECIFIER , "class RFTA_API SourceRange;" ); SourceASTNodePtr sourceNode = RFTA_ASSERT_DECLARATION_MUTATOR_PASS( source ); --- 315,319 ---- { Testing::KeyedString source; ! source.addKeyed(SPECIFIER , "class RFTA_API SourceRange" ) << ";"; SourceASTNodePtr sourceNode = RFTA_ASSERT_DECLARATION_MUTATOR_PASS( source ); *************** *** 333,337 **** { Testing::KeyedString source; ! source.addKeyed(SPECIFIER , "enum x { a = 0, b, c }" ) << ";"; SourceASTNodePtr sourceAST = RFTA_ASSERT_DECLARATION_MUTATOR_PASS( source ); --- 333,339 ---- { Testing::KeyedString source; ! source.setKeyStart(SPECIFIER) << "enum "; ! source.addKeyed("ENUM-NAME" , "x") << " { a = 0, b, c }"; ! source.setKeyEnd(SPECIFIER) << ";"; SourceASTNodePtr sourceAST = RFTA_ASSERT_DECLARATION_MUTATOR_PASS( source ); *************** *** 343,347 **** // check specifier types: ASTNodePtr specifierList = node->getProperty( ASTNodeProperties::declarationSpecifiersProperty ); ! RFTA_ASSERT_NODE_TYPE( specifierList->getChildAt(0), ASTNodeTypes::enumSpecifier, "enum-specifier" ); } --- 345,357 ---- // check specifier types: ASTNodePtr specifierList = node->getProperty( ASTNodeProperties::declarationSpecifiersProperty ); ! ASTNodePtr specifier = specifierList->getChildAt(0); ! RFTA_ASSERT_NODE_TYPE( specifier, ASTNodeTypes::enumSpecifier, "enum-specifier" ); ! ! RFTA_ASSERT_NODE_PROPERTY_HAS( specifier, ! ASTNodeProperties::compositeNameProperty, ! ASTNodeTypes::localScopeIdentifier, ! source.getKeyedIndex("ENUM-NAME",0), ! source.getKeyedLen("ENUM-NAME",0) ! ); } *************** *** 365,368 **** --- 375,416 ---- source.getKeyedIndex(SPECIFIER,0), source.getKeyedLen(SPECIFIER,0) ); + } + + void + UnparsedDeclarationMutatorTest::testEnumTypeUse() + { + Testing::KeyedString source; + source.setKeyStart(SPECIFIERLIST); + source.setKeyStart(SPECIFIER) << "enum "; + source.addKeyed("ENUM-NAME", "X"); + source.setKeyEnd(SPECIFIER); + source.setKeyEnd(SPECIFIERLIST) << " "; + source.addKeyed("DECLARATOR","Y=0" ) << ";"; + + + SourceASTNodePtr sourceAST = RFTA_ASSERT_DECLARATION_MUTATOR_PASS( source ); + ASTNodePtr node = sourceAST->getChildAt(0); + + // check AST: + RFTA_ASSERT_DECLARATION( source, sourceAST ); + + // check specifier types: + ASTNodePtr specifierList = node->getProperty( ASTNodeProperties::declarationSpecifiersProperty ); + ASTNodePtr enumSpecifier = specifierList->getChildAt(0); + RFTA_ASSERT_NODE_HAS( enumSpecifier, ASTNodeTypes::elaboratedTypeSpecifier, + source.getKeyedIndex(SPECIFIER,0), + source.getKeyedLen(SPECIFIER,0) ); + + RFTA_ASSERT_NODE_PROPERTY_HAS( enumSpecifier, + ASTNodeProperties::compositeNameProperty, + ASTNodeTypes::localScopeIdentifier, + source.getKeyedIndex("ENUM-NAME",0), + source.getKeyedLen("ENUM-NAME",0) + ); + // check declarator: + RFTA_ASSERT_NODE_HAS( node->getChildAt(0), ASTNodeTypes::unparsedDeclarator, + source.getKeyedIndex("DECLARATOR",0), + source.getKeyedLen("DECLARATOR",0) + ); } |
From: <net...@us...> - 2003-09-15 09:22:54
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv7407/rfta Modified Files: MockIdentifierResolverStrategy.h MockIdentifierResolverStrategy.cpp Log Message: -- changed interface for variable declaration -- additional declare/resolve calls for class & function declarations Index: MockIdentifierResolverStrategy.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/MockIdentifierResolverStrategy.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MockIdentifierResolverStrategy.h 6 Sep 2003 21:48:01 -0000 1.2 --- MockIdentifierResolverStrategy.h 15 Sep 2003 09:22:51 -0000 1.3 *************** *** 32,36 **** void leaveUnnamedSubScope(); ! void declareLocalVariable( const ASTNodePtr &localVariableDeclNode ); void resolveUnqualifiedIdentifier( const ASTNodePtr &identifierNode ); --- 32,36 ---- void leaveUnnamedSubScope(); ! void declareIdentifier( const ASTNodePtr &identifierDeclNode, const IdentifierAttributes::type attr ); void resolveUnqualifiedIdentifier( const ASTNodePtr &identifierNode ); *************** *** 45,49 **** private: ! const std::string nodeToString( const ASTNodePtr &node ); }; --- 45,50 ---- private: ! static const std::string nodeToString( const ASTNodePtr &node ); ! static const std::string attributeToString( const IdentifierAttributes::type attr ); }; Index: MockIdentifierResolverStrategy.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/MockIdentifierResolverStrategy.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MockIdentifierResolverStrategy.cpp 6 Sep 2003 21:48:01 -0000 1.2 --- MockIdentifierResolverStrategy.cpp 15 Sep 2003 09:22:51 -0000 1.3 *************** *** 6,9 **** --- 6,10 ---- #include "stdafx.h" #include "MockIdentifierResolverStrategy.h" + #include <boost/format.hpp> *************** *** 38,46 **** void ! MockIdentifierResolverStrategy::declareLocalVariable( ! const ASTNodePtr &localVariableDeclNode ) { ! addCall( "MockIdentifierResolverStrategy::declareLocalVariable( " ! + nodeToString( localVariableDeclNode ) + ")" ); } --- 39,48 ---- void ! MockIdentifierResolverStrategy::declareIdentifier( ! const ASTNodePtr &identifierDeclNode, ! const IdentifierAttributes::type attr) { ! addCall( "MockIdentifierResolverStrategy::declareIdentifier( " ! + nodeToString( identifierDeclNode ) + "," + attributeToString(attr) + ")" ); } *************** *** 79,82 **** --- 81,108 ---- addCall( "MockIdentifierResolverStrategy::removeScopeLookup( " + qualifiedName + ")" ); + } + + const std::string + MockIdentifierResolverStrategy::attributeToString( const IdentifierAttributes::type attr ) + { + switch (attr) + { + case IdentifierAttributes::NoAttribute: + return "NoAttribute"; + case IdentifierAttributes::ClassIdentifier: + return "ClassIdentifier"; + case IdentifierAttributes::EnumIdentifier: + return "EnumIdentifier"; + case IdentifierAttributes::UnionIdentifier: + return "UnionIdentifier"; + case IdentifierAttributes::StructIdentifier: + return "StructIdentifier"; + case IdentifierAttributes::NamespaceIdentifier: + return "NamespaceIdentifier"; + default: + int i = (int)attr; + boost::format frmt( "IdentifierAttributes::value=%1%"); + return (frmt % i).str(); + } } |
From: <net...@us...> - 2003-09-15 09:22:38
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv7348/rfta Modified Files: IdentifierScope.h Log Message: -- identifier attributes seperated Index: IdentifierScope.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/IdentifierScope.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** IdentifierScope.h 8 Sep 2003 19:12:07 -0000 1.4 --- IdentifierScope.h 15 Sep 2003 09:22:35 -0000 1.5 *************** *** 7,10 **** --- 7,11 ---- #include <rfta/parser/SourceASTNode.h> + #include "IdentifierAttributes.h" namespace Refactoring *************** *** 30,44 **** private: ExceptionType reason_; - }; - - class IdentifierAttributes { - public: - enum type { - NoAttribute = 0, - ClassIdentifier = 1, - EnumIdentifier = 2, - UnionIdentifier = 3, - StructIdentifier = 4 - }; }; --- 31,34 ---- |
From: <net...@us...> - 2003-09-15 09:22:09
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv7251/rfta Modified Files: IdentifierResolverTest.cpp Log Message: -- changed interface for variable declaration Index: IdentifierResolverTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/IdentifierResolverTest.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** IdentifierResolverTest.cpp 6 Sep 2003 21:50:51 -0000 1.8 --- IdentifierResolverTest.cpp 15 Sep 2003 09:22:05 -0000 1.9 *************** *** 79,85 **** strategy_->setRecordMode(); strategy_->enterUnnamedSubScope(); ! strategy_->declareLocalVariable( getVariableNode( "x.0" ) ); ! strategy_->declareLocalVariable( getVariableNode( "y.0" ) ); ! strategy_->declareLocalVariable( getVariableNode( "z.0" ) ); strategy_->leaveUnnamedSubScope(); --- 79,85 ---- strategy_->setRecordMode(); strategy_->enterUnnamedSubScope(); ! strategy_->declareIdentifier( getVariableNode( "x.0" ), IdentifierAttributes::NoAttribute ); ! strategy_->declareIdentifier( getVariableNode( "y.0" ), IdentifierAttributes::NoAttribute ); ! strategy_->declareIdentifier( getVariableNode( "z.0" ), IdentifierAttributes::NoAttribute ); strategy_->leaveUnnamedSubScope(); *************** *** 98,103 **** strategy_->setRecordMode(); strategy_->enterUnnamedSubScope(); ! strategy_->declareLocalVariable( getVariableNode( "x.0" ) ); ! strategy_->declareLocalVariable( getVariableNode( "y.0" ) ); strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "x.1" ) ); strategy_->leaveUnnamedSubScope(); --- 98,103 ---- strategy_->setRecordMode(); strategy_->enterUnnamedSubScope(); ! strategy_->declareIdentifier( getVariableNode( "x.0" ), IdentifierAttributes::NoAttribute ); ! strategy_->declareIdentifier( getVariableNode( "y.0" ), IdentifierAttributes::NoAttribute ); strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "x.1" ) ); strategy_->leaveUnnamedSubScope(); *************** *** 138,145 **** strategy_->enterUnnamedSubScope(); strategy_->enterUnnamedSubScope(); ! strategy_->declareLocalVariable( getVariableNode( "x.0" ) ); strategy_->enterUnnamedSubScope(); ! strategy_->declareLocalVariable( getVariableNode( "y.0" ) ); strategy_->leaveUnnamedSubScope(); --- 138,145 ---- strategy_->enterUnnamedSubScope(); strategy_->enterUnnamedSubScope(); ! strategy_->declareIdentifier( getVariableNode( "x.0" ), IdentifierAttributes::NoAttribute ); strategy_->enterUnnamedSubScope(); ! strategy_->declareIdentifier( getVariableNode( "y.0" ), IdentifierAttributes::NoAttribute ); strategy_->leaveUnnamedSubScope(); *************** *** 163,174 **** strategy_->enterUnnamedSubScope(); strategy_->enterUnnamedSubScope(); ! strategy_->declareLocalVariable( getVariableNode( "x.0" ) ); strategy_->enterUnnamedSubScope(); ! strategy_->declareLocalVariable( getVariableNode( "y.0" ) ); strategy_->leaveUnnamedSubScope(); strategy_->enterUnnamedSubScope(); ! strategy_->declareLocalVariable( getVariableNode( "z.0" ) ); strategy_->leaveUnnamedSubScope(); --- 163,174 ---- strategy_->enterUnnamedSubScope(); strategy_->enterUnnamedSubScope(); ! strategy_->declareIdentifier( getVariableNode( "x.0" ), IdentifierAttributes::NoAttribute ); strategy_->enterUnnamedSubScope(); ! strategy_->declareIdentifier( getVariableNode( "y.0" ), IdentifierAttributes::NoAttribute ); strategy_->leaveUnnamedSubScope(); strategy_->enterUnnamedSubScope(); ! strategy_->declareIdentifier( getVariableNode( "z.0" ), IdentifierAttributes::NoAttribute ); strategy_->leaveUnnamedSubScope(); *************** *** 190,197 **** strategy_->enterUnnamedSubScope(); strategy_->enterUnnamedSubScope(); ! strategy_->declareLocalVariable( getVariableNode( "c.0" ) ); strategy_->enterUnnamedSubScope(); ! strategy_->declareLocalVariable( getVariableNode( "y.0" ) ); strategy_->leaveUnnamedSubScope(); --- 190,197 ---- strategy_->enterUnnamedSubScope(); strategy_->enterUnnamedSubScope(); ! strategy_->declareIdentifier( getVariableNode( "c.0" ), IdentifierAttributes::NoAttribute ); strategy_->enterUnnamedSubScope(); ! strategy_->declareIdentifier( getVariableNode( "y.0" ), IdentifierAttributes::NoAttribute ); strategy_->leaveUnnamedSubScope(); *************** *** 215,224 **** strategy_->enterUnnamedSubScope(); strategy_->enterUnnamedSubScope(); ! strategy_->declareLocalVariable( getVariableNode( "index.0" ) ); strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "index.1" ) ); strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "index.2" ) ); strategy_->enterUnnamedSubScope(); ! strategy_->declareLocalVariable( getVariableNode( "x.0" ) ); strategy_->leaveUnnamedSubScope(); --- 215,224 ---- strategy_->enterUnnamedSubScope(); strategy_->enterUnnamedSubScope(); ! strategy_->declareIdentifier( getVariableNode( "index.0" ), IdentifierAttributes::NoAttribute ); strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "index.1" ) ); strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "index.2" ) ); strategy_->enterUnnamedSubScope(); ! strategy_->declareIdentifier( getVariableNode( "x.0" ), IdentifierAttributes::NoAttribute ); strategy_->leaveUnnamedSubScope(); *************** *** 244,248 **** strategy_->enterUnnamedSubScope(); strategy_->enterUnnamedSubScope(); ! strategy_->declareLocalVariable( getVariableNode( "c.0" ) ); strategy_->enterUnnamedSubScope(); --- 244,248 ---- strategy_->enterUnnamedSubScope(); strategy_->enterUnnamedSubScope(); ! strategy_->declareIdentifier( getVariableNode( "c.0" ), IdentifierAttributes::NoAttribute ); strategy_->enterUnnamedSubScope(); *************** *** 261,288 **** IdentifierResolverTest::testClassScope() { ! builder_->addKeyingMid( "class ", "CL_X", " {", "x.0" ); ! builder_->addKeyingMid( "static int ", "c", ";", "c.0" ); ! builder_->addKeyingMid( "static int ", "f", "()", "f.0" ); ! builder_->addKeyingMid( " { ","c"," = 0; }", "c.2" ); builder_->add( "};" ); ! builder_->addKeyingMid( "int ", "X::c", "=0;", "c.1" ); parse((DeclarationListParser*)0); ! strategy_->setRecordMode(); ! ASTNodePtr classSpecifier = boost::make_shared(getIdentifierNode( "x.0" )->getParentNode()); ! strategy_->declareClass( classSpecifier ); strategy_->enterNamedSubScope("CL_X"); ! strategy_->declareLocalVariable( getIdentifierNode( "c.0" ) ); ! // TODO: function identifiers not yet implemented ! // strategy_->declareFunctionIdentifier( getIdentifierNode( "f.0" ) ); strategy_->enterUnnamedSubScope(); ! strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "c.2" ) ); strategy_->leaveUnnamedSubScope(); - strategy_->leaveNamedSubScope(); - // TODO: global resolver has to check redeclarations ! - strategy_->declareLocalVariable( getIdentifierNode( "c.1" ) ); ! checkResolution(); } --- 261,299 ---- IdentifierResolverTest::testClassScope() { ! builder_->addKeyingMid( "class ", "CL_X", " {", "CLX.0" ); // 0 11 ! builder_->addKeyingMid( "static int ", "sc", ";", "sc.0" ); // 12 25 ! builder_->addKeyingMid( "int ", "c", ";", "c.0" ); // 26 32 ! builder_->addKeyingMid( "int ", "f", "()", "f.0" ); ! builder_->addKeyingMid( " { ","c"," = 0; }", "c.1" ); ! builder_->addKeyingMid( "int ","f2","();", "f2.0" ); builder_->add( "};" ); ! builder_->addKeyingMid( "int ", "CL_X", "" , "CLX.1" ); ! builder_->addKeyingMid( "::" , "sc", "=0;", "sc.1"); ! builder_->addKeyingMid( "int ", "CL_X", "" , "CLX.2" ); ! builder_->addKeyingMid( "::" , "f2", "()", "f2.1"); ! builder_->addKeyingMid( " {" , "c", "=2; }", "c.2"); parse((DeclarationListParser*)0); ! strategy_->setRecordMode(); ! strategy_->declareIdentifier( getIdentifierNode( "CLX.0" ), IdentifierAttributes::ClassIdentifier ); strategy_->enterNamedSubScope("CL_X"); ! strategy_->declareIdentifier( getIdentifierNode( "sc.0" ), IdentifierAttributes::NoAttribute ); ! strategy_->declareIdentifier( getIdentifierNode( "c.0" ), IdentifierAttributes::NoAttribute ); ! strategy_->declareIdentifier( getIdentifierNode( "f.0" ), IdentifierAttributes::NoAttribute ); strategy_->enterUnnamedSubScope(); ! strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "c.1" ) ); ! strategy_->leaveUnnamedSubScope(); ! strategy_->declareIdentifier( getIdentifierNode( "f2.0" ), IdentifierAttributes::NoAttribute ); ! strategy_->leaveNamedSubScope(); ! strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "CLX.1" )); ! strategy_->declareIdentifier( getIdentifierNode( "sc.1" ), IdentifierAttributes::NoAttribute ); ! strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "CLX.2" )); ! strategy_->declareIdentifier( getIdentifierNode( "f2.1" ), IdentifierAttributes::NoAttribute ); ! strategy_->enterUnnamedSubScope(); ! strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "c.2" ) ); strategy_->leaveUnnamedSubScope(); ! checkResolution(); } *************** *** 307,311 **** strategy_->setRecordMode(); strategy_->enterUnnamedSubScope(); ! strategy_->declareLocalVariable( getVariableNode( "bigBuffer.0" ) ); strategy_->enterUnnamedSubScope(); --- 318,322 ---- strategy_->setRecordMode(); strategy_->enterUnnamedSubScope(); ! strategy_->declareIdentifier( getVariableNode( "bigBuffer.0" ), IdentifierAttributes::NoAttribute ); strategy_->enterUnnamedSubScope(); |
From: <net...@us...> - 2003-09-15 09:21:54
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv7031/rfta Modified Files: IdentifierResolverStrategy.h Log Message: -- changed interface for variable declaration Index: IdentifierResolverStrategy.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/IdentifierResolverStrategy.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IdentifierResolverStrategy.h 6 Sep 2003 21:51:22 -0000 1.3 --- IdentifierResolverStrategy.h 15 Sep 2003 09:21:40 -0000 1.4 *************** *** 8,11 **** --- 8,12 ---- #include <rfta/refactoring/Config.h> #include <rfta/parser/ASTNode.h> + #include "IdentifierAttributes.h" namespace Refactoring *************** *** 29,33 **** virtual void removeScopeLookup(std::string name) =0; ! virtual void declareLocalVariable( const ASTNodePtr &localVariableDeclNode ) =0; // store composed type 'class' and 'struct' --- 30,35 ---- virtual void removeScopeLookup(std::string name) =0; ! //virtual void declareLocalVariable( const ASTNodePtr &localVariableDeclNode ) =0; ! virtual void declareIdentifier( const ASTNodePtr &identifierDeclNode, const IdentifierAttributes::type attr ) = 0; // store composed type 'class' and 'struct' |
From: <net...@us...> - 2003-09-15 09:21:18
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv6931/rfta Modified Files: IdentifierResolverContextTest.cpp Log Message: -- changed interface for variable declaration -- additional declare/resolve calls for class & function declarations Index: IdentifierResolverContextTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/IdentifierResolverContextTest.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** IdentifierResolverContextTest.cpp 6 Sep 2003 21:52:46 -0000 1.7 --- IdentifierResolverContextTest.cpp 15 Sep 2003 09:21:15 -0000 1.8 *************** *** 58,62 **** ASTNodePtr x1 = getIdentifierNode( "x.1" ); context_->enterUnnamedSubScope(); ! context_->declareLocalVariable( x0 ); context_->resolveUnqualifiedIdentifier( x1 ); context_->leaveUnnamedSubScope(); --- 58,62 ---- ASTNodePtr x1 = getIdentifierNode( "x.1" ); context_->enterUnnamedSubScope(); ! context_->declareIdentifier( x0, IdentifierAttributes::NoAttribute ); context_->resolveUnqualifiedIdentifier( x1 ); context_->leaveUnnamedSubScope(); *************** *** 96,105 **** ASTNodePtr xb1 = getIdentifierNode( "x.b.1" ); context_->enterUnnamedSubScope(); ! context_->declareLocalVariable( x0 ); context_->resolveUnqualifiedIdentifier( x1 ); ! context_->declareLocalVariable( y0 ); context_->enterUnnamedSubScope(); ! context_->declareLocalVariable( xb0 ); context_->resolveUnqualifiedIdentifier( xb1 ); context_->resolveUnqualifiedIdentifier( y1 ); --- 96,105 ---- ASTNodePtr xb1 = getIdentifierNode( "x.b.1" ); context_->enterUnnamedSubScope(); ! context_->declareIdentifier( x0, IdentifierAttributes::NoAttribute ); context_->resolveUnqualifiedIdentifier( x1 ); ! context_->declareIdentifier( y0, IdentifierAttributes::NoAttribute ); context_->enterUnnamedSubScope(); ! context_->declareIdentifier( xb0, IdentifierAttributes::NoAttribute ); context_->resolveUnqualifiedIdentifier( xb1 ); context_->resolveUnqualifiedIdentifier( y1 ); *************** *** 146,153 **** ASTNodePtr y0 = getVariableNode( "y.0" ); context_->enterUnnamedSubScope(); ! context_->declareLocalVariable( x0 ); context_->enterUnnamedSubScope(); ! context_->declareLocalVariable( y0 ); context_->leaveUnnamedSubScope(); --- 146,153 ---- ASTNodePtr y0 = getVariableNode( "y.0" ); context_->enterUnnamedSubScope(); ! context_->declareIdentifier( x0, IdentifierAttributes::NoAttribute ); context_->enterUnnamedSubScope(); ! context_->declareIdentifier( y0, IdentifierAttributes::NoAttribute ); context_->leaveUnnamedSubScope(); *************** *** 180,184 **** context_->enterUnnamedSubScope(); ! context_->declareLocalVariable( x0 ); context_->leaveUnnamedSubScope(); --- 180,184 ---- context_->enterUnnamedSubScope(); ! context_->declareIdentifier( x0, IdentifierAttributes::NoAttribute ); context_->leaveUnnamedSubScope(); |
From: <net...@us...> - 2003-09-15 09:19:39
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv6600/rfta Modified Files: IdentifierResolverContext.h IdentifierResolverContext.cpp Log Message: -- changed interface for variable declaration Index: IdentifierResolverContext.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/IdentifierResolverContext.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** IdentifierResolverContext.h 7 Sep 2003 13:29:39 -0000 1.7 --- IdentifierResolverContext.h 15 Sep 2003 09:19:35 -0000 1.8 *************** *** 8,11 **** --- 8,12 ---- #include "IdentifierResolverStrategy.h" #include "IdentifierScope.h" + #include "IdentifierAttributes.h" #include <boost/utility.hpp> #include <rfta/parser/SourceASTNode.h> *************** *** 53,64 **** void leaveUnnamedSubScope(); ! void declareLocalVariable( const ASTNodePtr &localVariableDeclNode ); void resolveUnqualifiedIdentifier( const ASTNodePtr &identifierNode ); void enterNamedSubScope(std::string name); ! void leaveNamedSubScope(); ! ! void declareClass( const ASTNodePtr &specifierNode); void addScopeLookup(std::string qualifiedName); --- 54,64 ---- void leaveUnnamedSubScope(); ! //void declareLocalVariable( const ASTNodePtr &localVariableDeclNode ); ! void declareIdentifier( const ASTNodePtr &identifierDeclNode, const IdentifierAttributes::type attr ); void resolveUnqualifiedIdentifier( const ASTNodePtr &identifierNode ); void enterNamedSubScope(std::string name); ! void leaveNamedSubScope(); void addScopeLookup(std::string qualifiedName); Index: IdentifierResolverContext.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/IdentifierResolverContext.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** IdentifierResolverContext.cpp 8 Sep 2003 19:12:07 -0000 1.11 --- IdentifierResolverContext.cpp 15 Sep 2003 09:19:35 -0000 1.12 *************** *** 49,60 **** void ! IdentifierResolverContext::declareLocalVariable( ! const ASTNodePtr &localVariableDeclNode ) { ! const std::string name = getLocalVariableName( localVariableDeclNode ); ! identifierCurrentScope_->registerIdentifier(name, localVariableDeclNode); ! ASTNodePtr variableNameNode = getLocalVariableNameNode( localVariableDeclNode ); ! resolvedIdentifiers_[ variableNameNode ] = localVariableDeclNode; } --- 49,61 ---- void ! IdentifierResolverContext::declareIdentifier( ! const ASTNodePtr &identifierDeclNode, ! const IdentifierAttributes::type attr ) { ! const std::string name = getLocalVariableName( identifierDeclNode ); ! identifierCurrentScope_->registerAttributedIdentifier(name, attr, identifierDeclNode); ! ASTNodePtr variableNameNode = getLocalVariableNameNode( identifierDeclNode ); ! resolvedIdentifiers_[ variableNameNode ] = identifierDeclNode; } *************** *** 150,159 **** it--; } - } - - void - IdentifierResolverContext::declareClass( const ASTNodePtr &specifierNode) - { - //TODO: Implement this... } --- 151,154 ---- |
From: <net...@us...> - 2003-09-15 09:19:17
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv6410/rfta Modified Files: IdentifierResolver.cpp Log Message: -- changed interface for variable declaration Index: IdentifierResolver.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/IdentifierResolver.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** IdentifierResolver.cpp 6 Sep 2003 21:53:16 -0000 1.12 --- IdentifierResolver.cpp 15 Sep 2003 09:19:06 -0000 1.13 *************** *** 71,75 **** IdentifierResolver::visitLocaleVariableDeclaration( const ASTNodePtr &node ) { ! context_.declareLocalVariable( node ); tryVisitNodeProperty( node, ASTNodeProperties::variableInitializerProperty ); --- 71,75 ---- IdentifierResolver::visitLocaleVariableDeclaration( const ASTNodePtr &node ) { ! context_.declareIdentifier( node, IdentifierAttributes::NoAttribute ); tryVisitNodeProperty( node, ASTNodeProperties::variableInitializerProperty ); |
From: <net...@us...> - 2003-09-15 09:18:28
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv6176/rfta Modified Files: GlobalIdentifierResolver.cpp Log Message: -- fixed node visiting (use node attributes now) Index: GlobalIdentifierResolver.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/GlobalIdentifierResolver.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** GlobalIdentifierResolver.cpp 6 Sep 2003 21:45:57 -0000 1.1 --- GlobalIdentifierResolver.cpp 15 Sep 2003 09:18:23 -0000 1.2 *************** *** 18,31 **** // actions before visiting properties and childs if (node->getType() == ASTNodeTypes::classSpecifier) ! { ! // add class definition reference... ! context_.declareClass(node); // add namespace if (node->hasProperty(ASTNodeProperties::classNameProperty)) { // named classes ASTNodePtr classIdent = node->getProperty(ASTNodeProperties::classNameProperty); std::string ident = classIdent->getBlankedText(); context_.enterNamedSubScope(ident); ! ASTNodeAndPropertyVisitor::visitNode(node); context_.leaveNamedSubScope(); } else --- 18,33 ---- // actions before visiting properties and childs if (node->getType() == ASTNodeTypes::classSpecifier) ! { // add namespace if (node->hasProperty(ASTNodeProperties::classNameProperty)) { // named classes ASTNodePtr classIdent = node->getProperty(ASTNodeProperties::classNameProperty); + ASTNodePtr classBody = node->getProperty(ASTNodeProperties::classBodyProperty); + // add class definition reference... + context_.declareIdentifier(classIdent,IdentifierAttributes::ClassIdentifier); + std::string ident = classIdent->getBlankedText(); context_.enterNamedSubScope(ident); ! ASTNodeAndPropertyVisitor::visitProperty(ASTNodeProperties::classBodyProperty,classBody); context_.leaveNamedSubScope(); } else *************** *** 35,39 **** context_.leaveNamedSubScope(); } ! } else { // visit properties and childs: --- 37,42 ---- context_.leaveNamedSubScope(); } ! } ! else { // visit properties and childs: *************** *** 50,54 **** bool GlobalIdentifierResolver::canSkipNode(const ASTNodePtr& node) const ! { return false; } --- 53,57 ---- bool GlobalIdentifierResolver::canSkipNode(const ASTNodePtr& node) const ! { return false; } *************** *** 58,65 **** GlobalIdentifierResolver::needsToVisitProperties(const ASTNodePtr& node ) const { ! if (node->getType() == ASTNodeTypes::compoundStatement) return false; ! ! return true; } --- 61,69 ---- GlobalIdentifierResolver::needsToVisitProperties(const ASTNodePtr& node ) const { ! const ASTNodeType &type = node->getType(); ! if ( type == ASTNodeTypes::compoundStatement ) return false; ! ! return type.hasAllFeatureOf( ASTNodeTypeFeatures::mayHaveLocalScopeIdentifierProperties ); } *************** *** 68,75 **** GlobalIdentifierResolver::needsToVisitChildren(const ASTNodePtr& node ) const { ! if (node->getType() == ASTNodeTypes::compoundStatement) return false; ! return true; } --- 72,82 ---- GlobalIdentifierResolver::needsToVisitChildren(const ASTNodePtr& node ) const { ! const ASTNodeType &type = node->getType(); ! ! if (type == ASTNodeTypes::compoundStatement) return false; ! return type.hasAllFeatureOf( ASTNodeTypeFeatures::mayHaveLocalScopeIdentifierChildren ); ! } *************** *** 92,100 **** return; } ! if (node->getType() == ASTNodeTypes::declarator) { ! // get the identifier node ! ASTNodePtr ident = node->getChildAt(0); ! context_.declareLocalVariable(ident); } } --- 99,115 ---- return; } ! if (node->getType() == ASTNodeTypes::localScopeIdentifier) { ! ASTNodePtr parent = boost::make_shared(node->getParentNode()); ! if ( !parent ) return; ! ASTNodePtr lastChild = parent->getChildAt( parent->getChildCount()-1 ); ! ! // resolving for declarator childs has special behaviour ! if ( parent->getType() != ASTNodeTypes::declarator || ! node == lastChild ) ! { ! context_.declareIdentifier(node, IdentifierAttributes::NoAttribute); ! } else ! context_.resolveUnqualifiedIdentifier( node ); } } |
From: <net...@us...> - 2003-09-15 09:17:38
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv6014/rftaparser Modified Files: DeclarationParserTest.cpp DeclarationParser.cpp Log Message: -- unparsed function header is now also "unparsed declaration" Index: DeclarationParserTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/DeclarationParserTest.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** DeclarationParserTest.cpp 6 Sep 2003 21:41:12 -0000 1.9 --- DeclarationParserTest.cpp 15 Sep 2003 09:17:34 -0000 1.10 *************** *** 213,217 **** fct, ASTNodeProperties::functionHeaderProperty, ! ASTNodeTypes::unparsedFunctionHeader, 0, 28); --- 213,217 ---- fct, ASTNodeProperties::functionHeaderProperty, ! ASTNodeTypes::unparsedDeclaration, 0, 28); Index: DeclarationParser.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/DeclarationParser.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** DeclarationParser.cpp 1 May 2003 21:09:59 -0000 1.8 --- DeclarationParser.cpp 15 Sep 2003 09:17:35 -0000 1.9 *************** *** 93,97 **** ASTNodePtr function_head = ! createASTNode( ASTNodeTypes::unparsedFunctionHeader, declarationNode, getStartIndex(), bodystartIdx - getStartIndex() ); --- 93,97 ---- ASTNodePtr function_head = ! createASTNode( ASTNodeTypes::unparsedDeclaration, declarationNode, getStartIndex(), bodystartIdx - getStartIndex() ); |
From: <net...@us...> - 2003-09-15 09:17:09
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv5934/rftaparser Modified Files: ASTNodes.cpp Log Message: -- unparsed function header is now also "unparsed declaration" Index: ASTNodes.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/ASTNodes.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** ASTNodes.cpp 6 Sep 2003 21:44:53 -0000 1.26 --- ASTNodes.cpp 15 Sep 2003 09:17:05 -0000 1.27 *************** *** 11,15 **** { ! const ASTNodeType ASTNodeTypes::source( "source-file", isCompositeStatement | mayHaveFunctionImplChildren ); const ASTNodeType ASTNodeTypes::unknownConstruct ( "unknown-construct" , 0 ); --- 11,15 ---- { ! const ASTNodeType ASTNodeTypes::source( "source-file", mayHaveLocalScopeIdentifierChildren | mayHaveVariableDeclChildren | mayHaveFunctionImplChildren ); const ASTNodeType ASTNodeTypes::unknownConstruct ( "unknown-construct" , 0 ); *************** *** 24,28 **** const ASTNodeType ASTNodeTypes::unparsedDeclarationList ( "unparsed-declaration-list", mayHaveLocalScopeIdentifierChildren ); const ASTNodeType ASTNodeTypes::unparsedDeclaration ( "unparsed-declaration", mayHaveLocalScopeIdentifierChildren ); ! const ASTNodeType ASTNodeTypes::unparsedFunctionHeader ( "unparsed-function-header", mayHaveLocalScopeIdentifierChildren ); const ASTNodeType ASTNodeTypes::unparsedTemplateHeader ( "unparsed-template-header", mayHaveLocalScopeIdentifierChildren ); --- 24,28 ---- const ASTNodeType ASTNodeTypes::unparsedDeclarationList ( "unparsed-declaration-list", mayHaveLocalScopeIdentifierChildren ); const ASTNodeType ASTNodeTypes::unparsedDeclaration ( "unparsed-declaration", mayHaveLocalScopeIdentifierChildren ); ! //const ASTNodeType ASTNodeTypes::unparsedFunctionHeader ( "unparsed-function-header", mayHaveLocalScopeIdentifierChildren ); const ASTNodeType ASTNodeTypes::unparsedTemplateHeader ( "unparsed-template-header", mayHaveLocalScopeIdentifierChildren ); |
From: <net...@us...> - 2003-09-15 09:15:59
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv5556/rfta Added Files: IdentifierAttributes.h Log Message: -- identifier attributes seperated --- NEW FILE: IdentifierAttributes.h --- // ////////////////////////////////////////////////////////////////////////// // (c)Copyright 2003, Andre Baresel. // Created: 2003/09/15 // ////////////////////////////////////////////////////////////////////////// #ifndef RFTA_IDENTIFIERATTRIBUTES_H #define RFTA_IDENTIFIERATTRIBUTES_H namespace Refactoring { class IdentifierAttributes { public: enum type { NoAttribute = 0, ClassIdentifier = 1, EnumIdentifier = 2, UnionIdentifier = 3, StructIdentifier = 4, NamespaceIdentifier = 5 }; private: IdentifierAttributes(); }; } #endif |
From: <net...@us...> - 2003-09-15 09:14:46
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv5285/rfta/src/rfta Modified Files: rfta.dsp Log Message: -- identifier attributes seperated Index: rfta.dsp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/rfta.dsp,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** rfta.dsp 6 Sep 2003 21:47:10 -0000 1.52 --- rfta.dsp 15 Sep 2003 09:14:42 -0000 1.53 *************** *** 155,158 **** --- 155,162 ---- # Begin Source File + SOURCE=.\IdentifierAttributes.h + # End Source File + # Begin Source File + SOURCE=.\IdentifierResolver.cpp # End Source File |
From: <net...@us...> - 2003-09-15 09:14:04
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv5144/rfta/src/rftaparser Modified Files: UnparsedDeclaratorMutator.cpp Log Message: -- declarator mutator splits scope identifier Index: UnparsedDeclaratorMutator.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/UnparsedDeclaratorMutator.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** UnparsedDeclaratorMutator.cpp 6 Sep 2003 21:34:00 -0000 1.1 --- UnparsedDeclaratorMutator.cpp 15 Sep 2003 09:14:01 -0000 1.2 *************** *** 43,80 **** if (!isalpha(*current) && *current!=':') { current++; continue; } ! if (*current==':' && *(current+1) != ':') { current++; continue; } ! ! // read the identifier: Xtl::CStringEnumerator en( Xtl::CStringView( start, end ) ); ! en.setCurrent( current ); ! int identStartOfs = en.getCurrentIndex(); ParserTools::skip(en,ParserTools::SkipScopeOperatorPolicy()); while (current!=end) ! { Xtl::CStringView identifier; ParserTools::tryReadIdentifier( en, identifier ); current=en.getCurrentPos(); ! // check scope operator: ! if (*current==':') ! { ! if (*(current+1)==':') ! { ! ParserTools::skip(en,ParserTools::SkipScopeOperatorPolicy()); ! continue; ! } ! } ! break; ! } ! identifierNode = ASTNode::create( ASTNodeTypes::localScopeIdentifier, node, node->getStartIndex() + identStartOfs, (current-start)-identStartOfs, sourceNode); identFound = true; ! } ! node->addChild(identifierNode); node->mutateType(ASTNodeTypes::declarator); } --- 43,84 ---- if (!isalpha(*current) && *current!=':') { current++; continue; } ! if (*current==':' && *(current+1) != ':') { current++; continue; } ! ! // setup enumerator for identifier reading: Xtl::CStringEnumerator en( Xtl::CStringView( start, end ) ); ! en.setCurrent( current ); + // skip possible "root" scope operator ParserTools::skip(en,ParserTools::SkipScopeOperatorPolicy()); while (current!=end) ! { ! int identStartOfs = en.getCurrentIndex(); Xtl::CStringView identifier; ParserTools::tryReadIdentifier( en, identifier ); current=en.getCurrentPos(); ! if ( identStartOfs == en.getCurrentIndex() ) ! break; ! ! identifierNode = ASTNode::create( ASTNodeTypes::localScopeIdentifier, node, node->getStartIndex() + identStartOfs, (current-start)-identStartOfs, sourceNode); + node->addChild(identifierNode); + + // skip white spaces: + ParserTools::skipSpaces(en); + + // check for scope-operator: + const char * identend = en.getCurrentPos(); + ParserTools::skip(en,ParserTools::SkipScopeOperatorPolicy()); + if ( identend == en.getCurrentPos() ) + break; // no scope resolution found ... + } + identFound = true; ! } node->mutateType(ASTNodeTypes::declarator); } |
From: <net...@us...> - 2003-09-15 09:13:41
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv5073/rfta/src/rftaparser Modified Files: UnparsedDeclaratorMutatorTest.cpp Log Message: -- declarator mutator splits scope identifier Index: UnparsedDeclaratorMutatorTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/UnparsedDeclaratorMutatorTest.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** UnparsedDeclaratorMutatorTest.cpp 6 Sep 2003 21:34:00 -0000 1.1 --- UnparsedDeclaratorMutatorTest.cpp 15 Sep 2003 09:13:31 -0000 1.2 *************** *** 123,128 **** { Testing::KeyedString source; ! source << "((*"; ! source.addKeyed("IDENT","::hello") << ") const = 0"; SourceASTNodePtr sourceAST = RFTA_ASSERT_DECLARATOR_MUTATOR_PASS( source ); --- 123,128 ---- { Testing::KeyedString source; ! source << "((* ::"; ! source.addKeyed("IDENT","hello") << ") const = 0"; SourceASTNodePtr sourceAST = RFTA_ASSERT_DECLARATOR_MUTATOR_PASS( source ); *************** *** 146,150 **** Testing::KeyedString source; source << "((*"; ! source.addKeyed("IDENT","hello::hello2::hello3") << ") const = 0"; SourceASTNodePtr sourceAST = RFTA_ASSERT_DECLARATOR_MUTATOR_PASS( source ); --- 146,153 ---- Testing::KeyedString source; source << "((*"; ! // declaration: "hello::hello2::hello3" (three identifiers will be registered !) ! source.addKeyed("IDENT1","hello") << "::"; ! source.addKeyed("IDENT2","hello2") << "::"; ! source.addKeyed("IDENT3","hello3") << ") const = 0"; SourceASTNodePtr sourceAST = RFTA_ASSERT_DECLARATOR_MUTATOR_PASS( source ); *************** *** 155,164 **** 0, source.length() ); ! RFTA_ASSERT_EQUAL( 1, node->getChildCount() ); RFTA_ASSERT_NODE_HAS( node->getChildAt(0), ASTNodeTypes::localScopeIdentifier, ! source.getKeyedIndex("IDENT",0), ! source.getKeyedLen ("IDENT",0) ); } --- 158,175 ---- 0, source.length() ); ! RFTA_ASSERT_EQUAL( 3, node->getChildCount() ); RFTA_ASSERT_NODE_HAS( node->getChildAt(0), ASTNodeTypes::localScopeIdentifier, ! source.getKeyedIndex("IDENT1",0), ! source.getKeyedLen ("IDENT1",0) ); ! RFTA_ASSERT_NODE_HAS( node->getChildAt(1), ! ASTNodeTypes::localScopeIdentifier, ! source.getKeyedIndex("IDENT2",0), ! source.getKeyedLen ("IDENT2",0) ); ! RFTA_ASSERT_NODE_HAS( node->getChildAt(2), ! ASTNodeTypes::localScopeIdentifier, ! source.getKeyedIndex("IDENT3",0), ! source.getKeyedLen ("IDENT3",0) ); } |
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv11715/rfta/src/rfta Modified Files: IdentifierScopeTest.h IdentifierScopeTest.cpp IdentifierScope.h IdentifierScope.cpp IdentifierResolverContext.cpp Log Message: -- extended identifier scope by "attributed" identifiers, see tests for usage Index: IdentifierScopeTest.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/IdentifierScopeTest.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** IdentifierScopeTest.h 6 Sep 2003 21:48:55 -0000 1.2 --- IdentifierScopeTest.h 8 Sep 2003 19:12:07 -0000 1.3 *************** *** 19,22 **** --- 19,23 ---- CPPUNIT_TEST( testIdentifierResolutionInOneScope ); CPPUNIT_TEST( testQualifiedScopeLookup ); + CPPUNIT_TEST( testAttributedIdentifier ); CPPUNIT_TEST_SUITE_END(); *************** *** 34,37 **** --- 35,39 ---- void testIdentifierResolutionInOneScope(); void testQualifiedScopeLookup(); + void testAttributedIdentifier(); }; Index: IdentifierScopeTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/IdentifierScopeTest.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IdentifierScopeTest.cpp 7 Sep 2003 13:28:02 -0000 1.3 --- IdentifierScopeTest.cpp 8 Sep 2003 19:12:07 -0000 1.4 *************** *** 50,74 **** ASTNodePtr nodeC = ASTNode::create(ASTNodeTypes::variableIdentifier,ASTNodeWeakPtr(),0,0,SourceASTNodeWeakPtr()); ! rootScope->addIdentifierDeclaration("C",nodeC); ! scopeA ->addIdentifierDeclaration("B",nodeB); try { ! ASTNodePtr decl = rootScope->getIdentifierDeclaration("C"); CPPUNIT_ASSERT_MESSAGE( "Expected a AST node.", bool(decl) ); CPPUNIT_ASSERT_EQUAL_MESSAGE ( "Expect a different AST node. (memory adress)", nodeC , decl ); ! decl = scopeA->getIdentifierDeclaration("::C"); CPPUNIT_ASSERT_MESSAGE( "Expected a AST node.", bool(decl) ); CPPUNIT_ASSERT_EQUAL_MESSAGE ( "Expect a different AST node. (memory adress)", nodeC , decl ); ! decl = scopeA->getIdentifierDeclaration("B"); CPPUNIT_ASSERT_MESSAGE( "Expected a AST node.", bool(decl) ); CPPUNIT_ASSERT_EQUAL_MESSAGE ( "Expect a different AST node. (memory adress)", nodeB , decl ); ! decl = rootScope->getIdentifierDeclaration("A::B"); CPPUNIT_ASSERT_MESSAGE( "Expected a AST node.", bool(decl) ); CPPUNIT_ASSERT_EQUAL_MESSAGE ( "Expect a different AST node. (memory adress)", nodeB , decl ); ! decl = scopeA->getIdentifierDeclaration("::A::B"); CPPUNIT_ASSERT_MESSAGE( "Expected a AST node.", bool(decl) ); CPPUNIT_ASSERT_EQUAL_MESSAGE ( "Expect a different AST node. (memory adress)", nodeB , decl ); --- 50,74 ---- ASTNodePtr nodeC = ASTNode::create(ASTNodeTypes::variableIdentifier,ASTNodeWeakPtr(),0,0,SourceASTNodeWeakPtr()); ! rootScope->registerIdentifier("C",nodeC); ! scopeA ->registerIdentifier("B",nodeB); try { ! ASTNodePtr decl = rootScope->findIdentifier("C"); CPPUNIT_ASSERT_MESSAGE( "Expected a AST node.", bool(decl) ); CPPUNIT_ASSERT_EQUAL_MESSAGE ( "Expect a different AST node. (memory adress)", nodeC , decl ); ! decl = scopeA->findIdentifier("::C"); CPPUNIT_ASSERT_MESSAGE( "Expected a AST node.", bool(decl) ); CPPUNIT_ASSERT_EQUAL_MESSAGE ( "Expect a different AST node. (memory adress)", nodeC , decl ); ! decl = scopeA->findIdentifier("B"); CPPUNIT_ASSERT_MESSAGE( "Expected a AST node.", bool(decl) ); CPPUNIT_ASSERT_EQUAL_MESSAGE ( "Expect a different AST node. (memory adress)", nodeB , decl ); ! decl = rootScope->findIdentifier("A::B"); CPPUNIT_ASSERT_MESSAGE( "Expected a AST node.", bool(decl) ); CPPUNIT_ASSERT_EQUAL_MESSAGE ( "Expect a different AST node. (memory adress)", nodeB , decl ); ! decl = scopeA->findIdentifier("::A::B"); CPPUNIT_ASSERT_MESSAGE( "Expected a AST node.", bool(decl) ); CPPUNIT_ASSERT_EQUAL_MESSAGE ( "Expect a different AST node. (memory adress)", nodeB , decl ); *************** *** 92,95 **** --- 92,120 ---- CPPUNIT_ASSERT_EQUAL_MESSAGE( "Expected a different scope pointer.", scopeD, scopeC->getQualifiedScope("A::B::D") ); CPPUNIT_ASSERT_EQUAL_MESSAGE( "Expected a different scope pointer.", scopeC, scopeD->getQualifiedScope("::C") ); + } + + void + IdentifierScopeTest::testAttributedIdentifier() + { + IdentifierScopePtr rootScope = IdentifierScope::createScope(IdentifierScopeWeakPtr(),"ROOT"); + IdentifierScopePtr scopeA = IdentifierScope::createSubScope(rootScope,"A"); + + ASTNodePtr nodeB = ASTNode::create(ASTNodeTypes::variableIdentifier,ASTNodeWeakPtr(),0,0,SourceASTNodeWeakPtr()); + ASTNodePtr nodeC = ASTNode::create(ASTNodeTypes::classSpecifier,ASTNodeWeakPtr(),0,0,SourceASTNodeWeakPtr()); + ASTNodePtr nodeD = ASTNode::create(ASTNodeTypes::classSpecifier,ASTNodeWeakPtr(),0,0,SourceASTNodeWeakPtr()); + + scopeA ->registerIdentifier("B",nodeB); + scopeA ->registerAttributedIdentifier("B",IdentifierAttributes::ClassIdentifier, nodeC); + scopeA ->registerAttributedIdentifier("C",IdentifierAttributes::ClassIdentifier, nodeD); + + ASTNodePtr decl; + decl = scopeA->findIdentifier("B"); + CPPUNIT_ASSERT_EQUAL_MESSAGE ( "Expect a different AST node.", nodeB , decl ); + + decl = scopeA->findAttributedIdentifier("B",IdentifierAttributes::ClassIdentifier); + CPPUNIT_ASSERT_EQUAL_MESSAGE ( "Expect a different AST node.", nodeC , decl ); + + decl = scopeA->findAttributedIdentifier("C",IdentifierAttributes::ClassIdentifier); + CPPUNIT_ASSERT_EQUAL_MESSAGE ( "Expect a different AST node.", nodeD , decl ); } Index: IdentifierScope.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/IdentifierScope.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IdentifierScope.h 7 Sep 2003 13:28:58 -0000 1.3 --- IdentifierScope.h 8 Sep 2003 19:12:07 -0000 1.4 *************** *** 32,35 **** --- 32,46 ---- }; + class IdentifierAttributes { + public: + enum type { + NoAttribute = 0, + ClassIdentifier = 1, + EnumIdentifier = 2, + UnionIdentifier = 3, + StructIdentifier = 4 + }; + }; + /// objects of this class store identifier scopes and sub scopes /// (identifier visibility, top level is file scope). *************** *** 37,40 **** --- 48,52 ---- { public: + static IdentifierScopePtr createScope(IdentifierScopeWeakPtr parent, std::string scopeName); static IdentifierScopePtr createSubScope(IdentifierScopeWeakPtr parent, std::string scopeName); *************** *** 55,64 **** */ bool removeSubScope( IdentifierScopePtr child ); ! // 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); ! void addIdentifierUse( std::string qualifiedName, ASTNodePtr declaration); ! ASTNodePtr getIdentifierDeclaration( std::string qualifiedName ) const; protected: --- 67,88 ---- */ bool removeSubScope( IdentifierScopePtr child ); + + /** + * register identifier with no attributes: + */ + void registerIdentifier( std::string qualifiedName, ASTNodePtr declaration); + /** + * find identifier 'not-attributed' have higher priority + */ + ASTNodePtr findIdentifier( std::string qualifiedName ) const; ! /** ! * register identifier with attribute ! */ ! void registerAttributedIdentifier( std::string qualifiedName, IdentifierAttributes::type attr, ASTNodePtr declaration); ! /** ! * find identifier with attribute ! */ ! ASTNodePtr findAttributedIdentifier( std::string qualifiedName, IdentifierAttributes::type attr ) const; protected: *************** *** 67,80 **** IdentifierScope(IdentifierScopeWeakPtr parent, std::string name); private: ! void registerSubScope(std::string scopeName, IdentifierScopePtr& subScope ); ! void addLocalIdentifier( std::string localName, ASTNodePtr declaration); ! ASTNodePtr getLocalIdentifier( std::string localName ); ! bool isLocalIdentifier( std::string localName ); ! typedef std::map<std::string, IdentifierScopePtr> SubScopeMap; ! typedef std::map<std::string, ASTNodePtr> IdentifierDeclarationMap; ! SubScopeMap subScopes_; //< sub scopes can be defined by types and namespaces ! IdentifierDeclarationMap identifierDeclaration_; //< stores declaration of this scope ! IdentifierScopeWeakPtr parent_; --- 91,102 ---- IdentifierScope(IdentifierScopeWeakPtr parent, std::string name); private: ! void registerSubScope(std::string scopeName, IdentifierScopePtr& subScope ); ! typedef std::map<std::string, IdentifierScopePtr> SubScopeMap; ! typedef std::map<IdentifierAttributes::type, ASTNodePtr> AttributedIdentifier; ! typedef std::map<std::string, AttributedIdentifier> IdentifierMap; ! SubScopeMap subScopes_; //< sub scopes can be defined by types and namespaces ! IdentifierMap identifierDeclaration_; //< stores declaration of this scope ! IdentifierScopeWeakPtr parent_; Index: IdentifierScope.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/IdentifierScope.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IdentifierScope.cpp 7 Sep 2003 13:28:58 -0000 1.3 --- IdentifierScope.cpp 8 Sep 2003 19:12:07 -0000 1.4 *************** *** 75,166 **** void ! IdentifierScope::addIdentifierDeclaration( std::string qualifiedName, ASTNodePtr declaration) ! { ! int pos = qualifiedName.find(':'); ! if ( pos != std::string::npos ) ! { ! // check validity of the name: ! if ( pos == qualifiedName.length()-1 || ! qualifiedName[pos+1] != ':' ) ! throw IdentifierScopeException(IdentifierScopeException::InvalidIdentifierName); ! ! // check if qualified name references 'root-scope' ! if ( pos == 0 ) ! boost::make_shared(root_)->addIdentifierDeclaration(qualifiedName.substr(2),declaration); ! ! // find out sub scope: ! std::string subScopeName = qualifiedName.substr(0,pos-1); ! if (!hasSubScope( subScopeName )) ! throw IdentifierScopeException(IdentifierScopeException::WrongQualifiedIdentifier); ! ! // call registration routine of sub scope ! getSubScope( subScopeName ) ->addIdentifierDeclaration(qualifiedName.substr(pos+2),declaration); ! ! } else ! { ! // identifier of this scope. ! IdentifierDeclarationMap::iterator it = identifierDeclaration_.find( qualifiedName ); ! if ( it != identifierDeclaration_.end() ) ! throw IdentifierScopeException(IdentifierScopeException::IdentifierDeclaredTwice); ! identifierDeclaration_[qualifiedName] = declaration; ! } ! } ! ! ASTNodePtr ! IdentifierScope::getIdentifierDeclaration( std::string qualifiedName ) const ! { ! int pos = qualifiedName.find(':'); ! if ( pos != std::string::npos ) ! { ! // check validity of the name: ! if ( pos == qualifiedName.length()-1 || ! qualifiedName[pos+1] != ':' ) ! throw IdentifierScopeException(IdentifierScopeException::InvalidIdentifierName); ! ! // check if qualified name references 'root-scope' ! if ( pos == 0 ) ! return boost::make_shared(root_)->getIdentifierDeclaration(qualifiedName.substr(2)); ! ! // find out sub scope: ! std::string subScopeName = qualifiedName.substr(0,pos); ! if (!hasSubScope( subScopeName )) ! throw IdentifierScopeException(IdentifierScopeException::WrongQualifiedIdentifier); ! ! // call registration routine of sub scope ! return getSubScope( subScopeName ) ->getIdentifierDeclaration(qualifiedName.substr(pos+2)); ! ! } else ! { ! // identifier of this scope. ! IdentifierDeclarationMap::const_iterator it = identifierDeclaration_.find( qualifiedName ); ! if ( it == identifierDeclaration_.end() ) ! { ! if (name_.empty() && !getParentScope().expired()) ! return boost::make_shared(getParentScope())->getIdentifierDeclaration(qualifiedName); ! else ! return ASTNodePtr (); ! } ! else ! return it->second; ! } ! } ! ! void ! IdentifierScope::addLocalIdentifier( std::string localName, ASTNodePtr declaration) { } ASTNodePtr ! IdentifierScope::getLocalIdentifier( std::string localName ) ! { ! return ASTNodePtr (); ! } ! ! bool IdentifierScope::isLocalIdentifier( std::string localName ) { ! return false; } - const char * IdentifierScopeException::what() const --- 75,89 ---- void ! IdentifierScope::registerIdentifier( std::string qualifiedName, ASTNodePtr declaration) { + registerAttributedIdentifier( qualifiedName, IdentifierAttributes::NoAttribute, declaration); } ASTNodePtr ! IdentifierScope::findIdentifier( std::string qualifiedName ) const { ! return findAttributedIdentifier( qualifiedName, IdentifierAttributes::NoAttribute ); } const char * IdentifierScopeException::what() const *************** *** 221,224 **** --- 144,247 ---- } while (pos != std::string::npos); return scopePtr; + } + + void + IdentifierScope::registerAttributedIdentifier( + std::string qualifiedName, + IdentifierAttributes::type attr, + ASTNodePtr declaration + ) + { + int pos = qualifiedName.find(':'); + if ( pos != std::string::npos ) + { + // check validity of the name: + if ( pos == qualifiedName.length()-1 || + qualifiedName[pos+1] != ':' ) + throw IdentifierScopeException(IdentifierScopeException::InvalidIdentifierName); + + // check if qualified name references 'root-scope' + if ( pos == 0 ) + boost::make_shared(root_)->registerAttributedIdentifier(qualifiedName.substr(2),attr,declaration); + + // find out sub scope: + std::string subScopeName = qualifiedName.substr(0,pos-1); + if (!hasSubScope( subScopeName )) + throw IdentifierScopeException(IdentifierScopeException::WrongQualifiedIdentifier); + + // call registration routine of sub scope + getSubScope( subScopeName ) ->registerAttributedIdentifier(qualifiedName.substr(pos+2),attr,declaration); + + } else + { + // identifier of this scope. + IdentifierMap::iterator it = identifierDeclaration_.find( qualifiedName ); + + if ( it == identifierDeclaration_.end() ) + { + // first identifier with this name + AttributedIdentifier attributeMap; + attributeMap[attr] = declaration; + identifierDeclaration_[qualifiedName] = attributeMap; + } else + { + // this identifier was declared allready, check if only attributed + AttributedIdentifier& attributeMap = it->second; + if (attributeMap.find(attr) != attributeMap.end()) + throw IdentifierScopeException(IdentifierScopeException::IdentifierDeclaredTwice); + attributeMap[attr] = declaration; + } + } + } + + ASTNodePtr + IdentifierScope::findAttributedIdentifier( std::string qualifiedName, IdentifierAttributes::type attr ) const + { + int pos = qualifiedName.find(':'); + if ( pos != std::string::npos ) + { + // check validity of the name: + if ( pos == qualifiedName.length()-1 || + qualifiedName[pos+1] != ':' ) + throw IdentifierScopeException(IdentifierScopeException::InvalidIdentifierName); + + // check if qualified name references 'root-scope' + if ( pos == 0 ) + return boost::make_shared(root_)->findIdentifier(qualifiedName.substr(2)); + + // find out sub scope: + std::string subScopeName = qualifiedName.substr(0,pos); + if (!hasSubScope( subScopeName )) + throw IdentifierScopeException(IdentifierScopeException::WrongQualifiedIdentifier); + + // call registration routine of sub scope + return getSubScope( subScopeName ) ->findIdentifier(qualifiedName.substr(pos+2)); + + } else + { + // identifier of this scope. + IdentifierMap::const_iterator it = identifierDeclaration_.find( qualifiedName ); + if ( it == identifierDeclaration_.end() ) + { + if (name_.empty() && !getParentScope().expired()) + return boost::make_shared(getParentScope())->findIdentifier(qualifiedName); + else + return ASTNodePtr (); + } + else + { + const AttributedIdentifier& mapAttributes = it->second; + AttributedIdentifier::const_iterator jt = mapAttributes.find(attr); + if (jt != mapAttributes.end()) + return jt->second; + else + { + if (attr != IdentifierAttributes::NoAttribute) + return ASTNodePtr (); + else + return mapAttributes.begin()->second; + } + } + } } Index: IdentifierResolverContext.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/IdentifierResolverContext.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** IdentifierResolverContext.cpp 7 Sep 2003 13:29:39 -0000 1.10 --- IdentifierResolverContext.cpp 8 Sep 2003 19:12:07 -0000 1.11 *************** *** 53,57 **** { const std::string name = getLocalVariableName( localVariableDeclNode ); ! identifierCurrentScope_->addIdentifierDeclaration(name, localVariableDeclNode); ASTNodePtr variableNameNode = getLocalVariableNameNode( localVariableDeclNode ); --- 53,57 ---- { const std::string name = getLocalVariableName( localVariableDeclNode ); ! identifierCurrentScope_->registerIdentifier(name, localVariableDeclNode); ASTNodePtr variableNameNode = getLocalVariableNameNode( localVariableDeclNode ); *************** *** 66,70 **** const std::string name = getIdentifierName( identifierNode ); ! ASTNodePtr declNode = identifierCurrentScope_->getIdentifierDeclaration(name); if (!declNode) // no declaration found ... { --- 66,70 ---- const std::string name = getIdentifierName( identifierNode ); ! ASTNodePtr declNode = identifierCurrentScope_->findIdentifier(name); if (!declNode) // no declaration found ... { |
From: <net...@us...> - 2003-09-07 13:29:42
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv28972/rfta/src/rfta Modified Files: IdentifierResolverContext.h IdentifierResolverContext.cpp Log Message: -- does use now identifierscope class for complete identifier resolving Index: IdentifierResolverContext.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/IdentifierResolverContext.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** IdentifierResolverContext.h 6 Sep 2003 21:52:46 -0000 1.6 --- IdentifierResolverContext.h 7 Sep 2003 13:29:39 -0000 1.7 *************** *** 70,80 **** std::string getIdentifierName( const ASTNodePtr &identifierNode ) const; - typedef std::deque<ASTNodePtr> LocalVariables; - typedef std::deque<LocalVariables> ScopeLocalVariables; - ScopeLocalVariables scopeLocalVariables_; - - typedef std::map<std::string, LocalVariables> VisibleLocalVariables; - VisibleLocalVariables visibleLocalVariables_; - typedef std::map<ASTNodePtr,ASTNodePtr> ResolvedUnqualifiedIdentifiers; ResolvedUnqualifiedIdentifiers resolvedIdentifiers_; --- 70,73 ---- Index: IdentifierResolverContext.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/IdentifierResolverContext.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** IdentifierResolverContext.cpp 6 Sep 2003 21:52:46 -0000 1.9 --- IdentifierResolverContext.cpp 7 Sep 2003 13:29:39 -0000 1.10 *************** *** 15,19 **** IdentifierResolverContext::IdentifierResolverContext() { ! identifierRootScope_ = IdentifierScope::createScope(IdentifierScopeWeakPtr()); identifierCurrentScope_ = identifierRootScope_; } --- 15,19 ---- IdentifierResolverContext::IdentifierResolverContext() { ! identifierRootScope_ = IdentifierScope::createScope(IdentifierScopeWeakPtr(), "ROOT"); identifierCurrentScope_ = identifierRootScope_; } *************** *** 31,35 **** --- 31,38 ---- IdentifierResolverContext::enterUnnamedSubScope() { + identifierCurrentScope_ = IdentifierScope::createSubScope(identifierCurrentScope_,""); + /* scopeLocalVariables_.push_back( LocalVariables() ); + */ } *************** *** 38,66 **** IdentifierResolverContext::leaveUnnamedSubScope() { ! if ( scopeLocalVariables_.empty() ) ! throw std::logic_error( "IdentifierResolverContext::leaveUnnamedSubScope(): " ! "no matching enterUnnamedSubScope()." ); ! ! LocalVariables &variables = scopeLocalVariables_.back(); ! LocalVariables::iterator it = variables.begin(); ! LocalVariables::iterator itEnd = variables.end(); ! while ( it != itEnd ) ! { ! const ASTNodePtr &node = *it++; ! VisibleLocalVariables::iterator itName = ! visibleLocalVariables_.find( getLocalVariableName(node) ); ! if ( itName == visibleLocalVariables_.end() ) ! { ! throw std::logic_error( "IdentifierResolverContext::leaveUnnamedSubScope(): " ! "inconsitent state, variable declared but not in visible variable list." ); ! } ! ! if ( itName->second.size() == 1 ) ! visibleLocalVariables_.erase( itName ); ! else ! itName->second.pop_front(); ! } - scopeLocalVariables_.pop_back(); } --- 41,48 ---- IdentifierResolverContext::leaveUnnamedSubScope() { ! IdentifierScopePtr next = boost::make_shared( identifierCurrentScope_->getParentScope() ); ! next->removeSubScope( identifierCurrentScope_ ); ! identifierCurrentScope_ = next; } *************** *** 71,81 **** { const std::string name = getLocalVariableName( localVariableDeclNode ); ! visibleLocalVariables_[ name ].push_front( localVariableDeclNode ); ! ! LocalVariables &variables = scopeLocalVariables_.back(); ! variables.push_back( localVariableDeclNode ); ASTNodePtr variableNameNode = getLocalVariableNameNode( localVariableDeclNode ); ! resolvedIdentifiers_[ variableNameNode ] = localVariableDeclNode; } --- 53,60 ---- { const std::string name = getLocalVariableName( localVariableDeclNode ); ! identifierCurrentScope_->addIdentifierDeclaration(name, localVariableDeclNode); ASTNodePtr variableNameNode = getLocalVariableNameNode( localVariableDeclNode ); ! resolvedIdentifiers_[ variableNameNode ] = localVariableDeclNode; } *************** *** 87,103 **** const std::string name = getIdentifierName( identifierNode ); ! VisibleLocalVariables::iterator it = visibleLocalVariables_.find( name ); ! if ( it == visibleLocalVariables_.end() ) ! return; ! ! if ( it->second.empty() ) { ! throw std::logic_error( "IdentifierResolverContext::resolveUnqualifiedIdentifier( " + ! identifierNode->getBlankedText() + "): variable found in " ! "list of visible variable, but no declaration found!" ); } ! ! const ASTNodePtr &localVariableDeclNode = it->second.front(); ! resolvedIdentifiers_[ identifierNode ] = localVariableDeclNode; } --- 66,75 ---- const std::string name = getIdentifierName( identifierNode ); ! ASTNodePtr declNode = identifierCurrentScope_->getIdentifierDeclaration(name); ! if (!declNode) // no declaration found ... { ! return; } ! resolvedIdentifiers_[ identifierNode ] = declNode; } |
From: <net...@us...> - 2003-09-07 13:29:06
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv28823/rfta/src/rfta Modified Files: IdentifierScope.h IdentifierScope.cpp Log Message: -- scopes store their names now -- remove scopes -- lookup within unnamed scopes does also search in parent scope Index: IdentifierScope.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/IdentifierScope.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** IdentifierScope.h 6 Sep 2003 21:49:28 -0000 1.2 --- IdentifierScope.h 7 Sep 2003 13:28:58 -0000 1.3 *************** *** 37,41 **** { public: ! static IdentifierScopePtr createScope(IdentifierScopeWeakPtr parent); static IdentifierScopePtr createSubScope(IdentifierScopeWeakPtr parent, std::string scopeName); --- 37,41 ---- { public: ! static IdentifierScopePtr createScope(IdentifierScopeWeakPtr parent, std::string scopeName); static IdentifierScopePtr createSubScope(IdentifierScopeWeakPtr parent, std::string scopeName); *************** *** 50,57 **** --- 50,63 ---- bool hasSubScope( std::string scopeName ) const; IdentifierScopePtr getSubScope(std::string scopeName) const; + + /** + * removes the specified child scope, returns success of operation + */ + bool removeSubScope( IdentifierScopePtr child ); // 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); + void addIdentifierUse( std::string qualifiedName, ASTNodePtr declaration); ASTNodePtr getIdentifierDeclaration( std::string qualifiedName ) const; *************** *** 59,63 **** /*! protects direct creation. use static 'createScope/createSubScope' */ ! IdentifierScope(IdentifierScopeWeakPtr parent); private: void registerSubScope(std::string scopeName, IdentifierScopePtr& subScope ); --- 65,69 ---- /*! protects direct creation. use static 'createScope/createSubScope' */ ! IdentifierScope(IdentifierScopeWeakPtr parent, std::string name); private: void registerSubScope(std::string scopeName, IdentifierScopePtr& subScope ); *************** *** 68,71 **** --- 74,78 ---- typedef std::map<std::string, IdentifierScopePtr> SubScopeMap; typedef std::map<std::string, ASTNodePtr> IdentifierDeclarationMap; + SubScopeMap subScopes_; //< sub scopes can be defined by types and namespaces IdentifierDeclarationMap identifierDeclaration_; //< stores declaration of this scope ! *************** *** 73,76 **** --- 80,85 ---- IdentifierScopeWeakPtr parent_; IdentifierScopeWeakPtr root_; // the file scope + + std::string name_; //< name of the scope }; *************** *** 95,101 **** } ! inline IdentifierScopePtr IdentifierScope::createScope(IdentifierScopeWeakPtr parent) { ! IdentifierScopePtr scope( new IdentifierScope(parent) ); if ( ! boost::make_shared(parent) ) scope->root_ = scope; --- 104,110 ---- } ! inline IdentifierScopePtr IdentifierScope::createScope(IdentifierScopeWeakPtr parent, std::string scopeName) { ! IdentifierScopePtr scope( new IdentifierScope(parent, scopeName) ); if ( ! boost::make_shared(parent) ) scope->root_ = scope; Index: IdentifierScope.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/IdentifierScope.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** IdentifierScope.cpp 6 Sep 2003 21:49:28 -0000 1.2 --- IdentifierScope.cpp 7 Sep 2003 13:28:58 -0000 1.3 *************** *** 11,17 **** // constructor, sets parent and root node information ! IdentifierScope::IdentifierScope(IdentifierScopeWeakPtr parent) { parent_ = parent; IdentifierScopePtr tmp = boost::make_shared(parent_); --- 11,18 ---- // constructor, sets parent and root node information ! IdentifierScope::IdentifierScope(IdentifierScopeWeakPtr parent, std::string name) { parent_ = parent; + name_ = name; IdentifierScopePtr tmp = boost::make_shared(parent_); *************** *** 27,31 **** throw IdentifierScopeException(IdentifierScopeException::InvalidScope); ! IdentifierScopePtr subScope = IdentifierScope::createScope(parent); shrd_p->registerSubScope(scopeName, subScope); --- 28,32 ---- throw IdentifierScopeException(IdentifierScopeException::InvalidScope); ! IdentifierScopePtr subScope = IdentifierScope::createScope(parent, scopeName); shrd_p->registerSubScope(scopeName, subScope); *************** *** 57,60 **** --- 58,77 ---- } + bool + IdentifierScope::removeSubScope( IdentifierScopePtr child ) + { + SubScopeMap::iterator it; + for( it = subScopes_.begin(); it != subScopes_.end() && it->second != child; ) + it++; + + if ( it != subScopes_.end() ) + { + subScopes_.erase(it); + return true; + } else + return false; + + } + void IdentifierScope::addIdentifierDeclaration( std::string qualifiedName, ASTNodePtr declaration) *************** *** 118,122 **** IdentifierDeclarationMap::const_iterator it = identifierDeclaration_.find( qualifiedName ); if ( it == identifierDeclaration_.end() ) ! return ASTNodePtr (); else return it->second; --- 135,144 ---- IdentifierDeclarationMap::const_iterator it = identifierDeclaration_.find( qualifiedName ); if ( it == identifierDeclaration_.end() ) ! { ! if (name_.empty() && !getParentScope().expired()) ! return boost::make_shared(getParentScope())->getIdentifierDeclaration(qualifiedName); ! else ! return ASTNodePtr (); ! } else return it->second; |
From: <net...@us...> - 2003-09-07 13:28:09
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv28642/rfta/src/rfta Modified Files: IdentifierScopeTest.cpp Log Message: -- scopes store their names now Index: IdentifierScopeTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/IdentifierScopeTest.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** IdentifierScopeTest.cpp 6 Sep 2003 21:48:55 -0000 1.2 --- IdentifierScopeTest.cpp 7 Sep 2003 13:28:02 -0000 1.3 *************** *** 40,44 **** IdentifierScopeTest::testIdentifierResolutionInOneScope() { ! IdentifierScopePtr rootScope = IdentifierScope::createScope(IdentifierScopeWeakPtr()); IdentifierScopePtr scopeA = IdentifierScope::createSubScope(rootScope,"A"); --- 40,44 ---- IdentifierScopeTest::testIdentifierResolutionInOneScope() { ! IdentifierScopePtr rootScope = IdentifierScope::createScope(IdentifierScopeWeakPtr(),"ROOT"); IdentifierScopePtr scopeA = IdentifierScope::createSubScope(rootScope,"A"); *************** *** 84,88 **** IdentifierScopeTest::testQualifiedScopeLookup() { ! IdentifierScopePtr rootScope = IdentifierScope::createScope(IdentifierScopeWeakPtr()); IdentifierScopePtr scopeA = IdentifierScope::createSubScope(rootScope,"A"); // "::A" IdentifierScopePtr scopeB = IdentifierScope::createSubScope(scopeA ,"B"); // "::A::B" --- 84,88 ---- IdentifierScopeTest::testQualifiedScopeLookup() { ! IdentifierScopePtr rootScope = IdentifierScope::createScope(IdentifierScopeWeakPtr(), "ROOT"); IdentifierScopePtr scopeA = IdentifierScope::createSubScope(rootScope,"A"); // "::A" IdentifierScopePtr scopeB = IdentifierScope::createSubScope(scopeA ,"B"); // "::A::B" |