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: <bl...@us...> - 2003-09-07 08:49:20
|
Update of /cvsroot/cpptool/rfta/src/pyrfta In directory sc8-pr-cvs1:/tmp/cvs-serv23108 Modified Files: pyrfta.dsp Log Message: * removed TextDocument.idl dependency Index: pyrfta.dsp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/pyrfta/pyrfta.dsp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** pyrfta.dsp 29 May 2003 17:00:12 -0000 1.10 --- pyrfta.dsp 7 Sep 2003 08:49:17 -0000 1.11 *************** *** 106,117 **** # End Source File # End Group - # Begin Group "com" - - # PROP Default_Filter "" - # Begin Source File - - SOURCE=.\com\TextDocument.idl - # End Source File - # End Group # Begin Source File --- 106,109 ---- |
From: <bl...@us...> - 2003-09-07 08:40:17
|
Update of /cvsroot/cpptool/rfta/src/pyrfta/com In directory sc8-pr-cvs1:/tmp/cvs-serv22089 Added Files: TextDocument.idl Log Message: * added --- NEW FILE: TextDocument.idl --- [ uuid(8AFF68E1-82FB-4b79-A3A6-B043B17B6034), version(1.0), helpstring ("RFTAVC6ADDIN Developer Studio Add-in") ] library RFTATextDocument { importlib("stdole32.tlb"); [uuid(9FFB287B-DA04-45ce-BB7C-85E045A84C0F), oleautomation, dual ] interface ITextDocument : IDispatch { [id(1)] HRESULT GetAllText( [out,retval] BSTR* content ); [id(2)] HRESULT GetSelection( [out,retval] BSTR* selection ); [id(3)] HRESULT ReplaceSelection( [in] BSTR text ); [id(4)] HRESULT GetSelectionRange( [out] int *selectionStart, [out] int *selectionEnd ); [id(5)] HRESULT SetSelectionRange( [in] int selectionStart, [in] int selectionEnd ); }; [uuid(6F1E3540-FC3A-4ec1-84E9-8DAADBEFF959), oleautomation, dual ] interface ILineBasedTextDocument : IDispatch { [id(1)] HRESULT GetAllText( [out,retval] BSTR* content ); [id(2)] HRESULT GetSelection( [out,retval] BSTR* selection ); [id(3)] HRESULT ReplaceSelection( [in] BSTR text ); [id(4)] HRESULT GetSelectionRange( [out] int *lineStart, [out] int *colStart, [out] int *lineEnd, [out] int *colEnd ); [id(5)] HRESULT SetSelectionRange( [in] int lineStart, [in] int colStart, [in] int lineEnd, [in] int colEnd ); }; }; |
From: <bl...@us...> - 2003-09-07 08:38:45
|
Update of /cvsroot/cpptool/rfta/src/pyrfta/com In directory sc8-pr-cvs1:/tmp/cvs-serv21838/com Log Message: Directory /cvsroot/cpptool/rfta/src/pyrfta/com added to the repository |
From: <net...@us...> - 2003-09-06 21:53:24
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv1852/src/rfta Modified Files: IdentifierResolver.cpp Log Message: -- preparations for global identifier resolver (global do not work yet) Index: IdentifierResolver.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/IdentifierResolver.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** IdentifierResolver.cpp 21 Dec 2002 14:39:53 -0000 1.11 --- IdentifierResolver.cpp 6 Sep 2003 21:53:16 -0000 1.12 *************** *** 28,37 **** IdentifierResolver::visitConditionStatement( const ASTNodePtr &node ) { ! context_.enterNewLocalVariableScope(); visitCondition( node ); visitSubStatements( node ); ! context_.exitLocalVariableScope(); } --- 28,37 ---- IdentifierResolver::visitConditionStatement( const ASTNodePtr &node ) { ! context_.enterUnnamedSubScope(); visitCondition( node ); visitSubStatements( node ); ! context_.leaveUnnamedSubScope(); } *************** *** 40,46 **** IdentifierResolver::visitSubStatement( const ASTNodePtr &subStatementNode ) { ! context_.enterNewLocalVariableScope(); visitNode( subStatementNode ); ! context_.exitLocalVariableScope(); } --- 40,46 ---- IdentifierResolver::visitSubStatement( const ASTNodePtr &subStatementNode ) { ! context_.enterUnnamedSubScope(); visitNode( subStatementNode ); ! context_.leaveUnnamedSubScope(); } *************** *** 49,53 **** IdentifierResolver::visitForStatement( const ASTNodePtr &node ) { ! context_.enterNewLocalVariableScope(); ASTNodePtr iterationExpression = node->getProperty(ASTNodeProperties::iterationProperty); --- 49,53 ---- IdentifierResolver::visitForStatement( const ASTNodePtr &node ) { ! context_.enterUnnamedSubScope(); ASTNodePtr iterationExpression = node->getProperty(ASTNodeProperties::iterationProperty); *************** *** 55,59 **** visitSubStatements( node ); ! context_.exitLocalVariableScope(); } --- 55,59 ---- visitSubStatements( node ); ! context_.leaveUnnamedSubScope(); } *************** *** 62,68 **** IdentifierResolver::visitCompoundStatement( const ASTNodePtr &node ) { ! context_.enterNewLocalVariableScope(); node->visitChildNodes( *this ); ! context_.exitLocalVariableScope(); } --- 62,68 ---- IdentifierResolver::visitCompoundStatement( const ASTNodePtr &node ) { ! context_.enterUnnamedSubScope(); node->visitChildNodes( *this ); ! context_.leaveUnnamedSubScope(); } |
From: <net...@us...> - 2003-09-06 21:52:51
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv1754/src/rfta Modified Files: IdentifierResolverContextTest.cpp IdentifierResolverContext.h IdentifierResolverContext.cpp Log Message: -- preparations for global identifier resolver (global do not work yet) Index: IdentifierResolverContextTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/IdentifierResolverContextTest.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** IdentifierResolverContextTest.cpp 15 May 2003 16:29:13 -0000 1.6 --- IdentifierResolverContextTest.cpp 6 Sep 2003 21:52:46 -0000 1.7 *************** *** 57,64 **** ASTNodePtr x0 = getVariableNode( "x.0" ); ASTNodePtr x1 = getIdentifierNode( "x.1" ); ! context_->enterNewLocalVariableScope(); context_->declareLocalVariable( x0 ); context_->resolveUnqualifiedIdentifier( x1 ); ! context_->exitLocalVariableScope(); CPPUNIT_ASSERT( context_->isLocalVariableIdentifier( x1 ) ); --- 57,64 ---- ASTNodePtr x0 = getVariableNode( "x.0" ); ASTNodePtr x1 = getIdentifierNode( "x.1" ); ! context_->enterUnnamedSubScope(); context_->declareLocalVariable( x0 ); context_->resolveUnqualifiedIdentifier( x1 ); ! context_->leaveUnnamedSubScope(); CPPUNIT_ASSERT( context_->isLocalVariableIdentifier( x1 ) ); *************** *** 95,112 **** ASTNodePtr xb0 = getVariableNode( "x.b.0" ); ASTNodePtr xb1 = getIdentifierNode( "x.b.1" ); ! context_->enterNewLocalVariableScope(); context_->declareLocalVariable( x0 ); context_->resolveUnqualifiedIdentifier( x1 ); context_->declareLocalVariable( y0 ); ! context_->enterNewLocalVariableScope(); context_->declareLocalVariable( xb0 ); context_->resolveUnqualifiedIdentifier( xb1 ); context_->resolveUnqualifiedIdentifier( y1 ); ! context_->exitLocalVariableScope(); context_->resolveUnqualifiedIdentifier( y2 ); context_->resolveUnqualifiedIdentifier( x2 ); ! context_->exitLocalVariableScope(); CPPUNIT_ASSERT( context_->isLocalVariableIdentifier( x1 ) ); --- 95,112 ---- ASTNodePtr xb0 = getVariableNode( "x.b.0" ); 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 ); ! context_->leaveUnnamedSubScope(); context_->resolveUnqualifiedIdentifier( y2 ); context_->resolveUnqualifiedIdentifier( x2 ); ! context_->leaveUnnamedSubScope(); CPPUNIT_ASSERT( context_->isLocalVariableIdentifier( x1 ) ); *************** *** 145,156 **** ASTNodePtr x0 = getVariableNode( "x.0" ); ASTNodePtr y0 = getVariableNode( "y.0" ); ! context_->enterNewLocalVariableScope(); context_->declareLocalVariable( x0 ); ! context_->enterNewLocalVariableScope(); context_->declareLocalVariable( y0 ); ! context_->exitLocalVariableScope(); ! context_->exitLocalVariableScope(); CPPUNIT_ASSERT( context_->isLocalVariableIdentifier( getIdentifierNode( "x.0" ) ) ); --- 145,156 ---- ASTNodePtr x0 = getVariableNode( "x.0" ); ASTNodePtr y0 = getVariableNode( "y.0" ); ! context_->enterUnnamedSubScope(); context_->declareLocalVariable( x0 ); ! context_->enterUnnamedSubScope(); context_->declareLocalVariable( y0 ); ! context_->leaveUnnamedSubScope(); ! context_->leaveUnnamedSubScope(); CPPUNIT_ASSERT( context_->isLocalVariableIdentifier( getIdentifierNode( "x.0" ) ) ); *************** *** 177,188 **** ASTNodePtr x0 = getVariableNode( "x.0" ); ASTNodePtr x1 = getIdentifierNode( "x.1" ); ! context_->enterNewLocalVariableScope(); ! context_->enterNewLocalVariableScope(); context_->declareLocalVariable( x0 ); ! context_->exitLocalVariableScope(); context_->resolveUnqualifiedIdentifier( x1 ); ! context_->exitLocalVariableScope(); CPPUNIT_ASSERT( context_->isLocalVariableIdentifier( getIdentifierNode( "x.0" ) ) ); --- 177,188 ---- ASTNodePtr x0 = getVariableNode( "x.0" ); ASTNodePtr x1 = getIdentifierNode( "x.1" ); ! context_->enterUnnamedSubScope(); ! context_->enterUnnamedSubScope(); context_->declareLocalVariable( x0 ); ! context_->leaveUnnamedSubScope(); context_->resolveUnqualifiedIdentifier( x1 ); ! context_->leaveUnnamedSubScope(); CPPUNIT_ASSERT( context_->isLocalVariableIdentifier( getIdentifierNode( "x.0" ) ) ); Index: IdentifierResolverContext.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/IdentifierResolverContext.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** IdentifierResolverContext.h 27 Apr 2003 22:02:02 -0000 1.5 --- IdentifierResolverContext.h 6 Sep 2003 21:52:46 -0000 1.6 *************** *** 7,10 **** --- 7,11 ---- #include "IdentifierResolverStrategy.h" + #include "IdentifierScope.h" #include <boost/utility.hpp> #include <rfta/parser/SourceASTNode.h> *************** *** 49,59 **** public: // overriden from IdentifierResolverStrategy ! void enterNewLocalVariableScope(); ! void exitLocalVariableScope(); ! void declareLocalVariable( const ASTNodePtr &localVariableDeclNode ); void resolveUnqualifiedIdentifier( const ASTNodePtr &identifierNode ); private: ASTNodePtr getLocalVariableNameNode( const ASTNodePtr &localVariableDeclNode ) const; --- 50,68 ---- public: // overriden from IdentifierResolverStrategy ! void enterUnnamedSubScope(); ! 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); + void removeScopeLookup(std::string qualifiedName); + private: ASTNodePtr getLocalVariableNameNode( const ASTNodePtr &localVariableDeclNode ) const; *************** *** 70,73 **** --- 79,87 ---- typedef std::map<ASTNodePtr,ASTNodePtr> ResolvedUnqualifiedIdentifiers; ResolvedUnqualifiedIdentifiers resolvedIdentifiers_; + + //> information on persistent identifier scopes (classes / namespaces) + IdentifierScopePtr identifierRootScope_; + IdentifierScopePtr identifierCurrentScope_; + std::vector<IdentifierScopePtr> scopeLookups_; }; Index: IdentifierResolverContext.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/IdentifierResolverContext.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** IdentifierResolverContext.cpp 10 May 2003 10:55:14 -0000 1.8 --- IdentifierResolverContext.cpp 6 Sep 2003 21:52:46 -0000 1.9 *************** *** 15,18 **** --- 15,20 ---- IdentifierResolverContext::IdentifierResolverContext() { + identifierRootScope_ = IdentifierScope::createScope(IdentifierScopeWeakPtr()); + identifierCurrentScope_ = identifierRootScope_; } *************** *** 20,28 **** IdentifierResolverContext::~IdentifierResolverContext() { } void ! IdentifierResolverContext::enterNewLocalVariableScope() { scopeLocalVariables_.push_back( LocalVariables() ); --- 22,33 ---- IdentifierResolverContext::~IdentifierResolverContext() { + scopeLookups_.erase(scopeLookups_.begin(),scopeLookups_.end()); + identifierCurrentScope_.reset(); + identifierRootScope_.reset(); } void ! IdentifierResolverContext::enterUnnamedSubScope() { scopeLocalVariables_.push_back( LocalVariables() ); *************** *** 31,39 **** void ! IdentifierResolverContext::exitLocalVariableScope() { if ( scopeLocalVariables_.empty() ) ! throw std::logic_error( "IdentifierResolverContext::exitLocalVariableScope(): " ! "no matching enterNewLocalVariableScope()." ); LocalVariables &variables = scopeLocalVariables_.back(); --- 36,44 ---- void ! IdentifierResolverContext::leaveUnnamedSubScope() { if ( scopeLocalVariables_.empty() ) ! throw std::logic_error( "IdentifierResolverContext::leaveUnnamedSubScope(): " ! "no matching enterUnnamedSubScope()." ); LocalVariables &variables = scopeLocalVariables_.back(); *************** *** 47,51 **** if ( itName == visibleLocalVariables_.end() ) { ! throw std::logic_error( "IdentifierResolverContext::exitLocalVariableScope(): " "inconsitent state, variable declared but not in visible variable list." ); } --- 52,56 ---- if ( itName == visibleLocalVariables_.end() ) { ! throw std::logic_error( "IdentifierResolverContext::leaveUnnamedSubScope(): " "inconsitent state, variable declared but not in visible variable list." ); } *************** *** 140,143 **** --- 145,187 ---- { return identifierNode->getBlankedText(); + } + + void + IdentifierResolverContext::enterNamedSubScope(std::string name) + { + identifierCurrentScope_ = IdentifierScope::createSubScope(identifierCurrentScope_,name); + } + + void + IdentifierResolverContext::leaveNamedSubScope() + { + identifierCurrentScope_ = boost::make_shared( identifierCurrentScope_->getParentScope() ); + } + + void + IdentifierResolverContext::addScopeLookup(std::string qualifiedName) + { + IdentifierScopePtr specifiedScope = identifierCurrentScope_->getQualifiedScope( qualifiedName ); + scopeLookups_.push_back( specifiedScope ); + } + + void + IdentifierResolverContext::removeScopeLookup(std::string qualifiedName) + { + IdentifierScopePtr specifiedScope = identifierCurrentScope_->getQualifiedScope( qualifiedName ); + + std::vector<IdentifierScopePtr>::iterator it; + for (it = scopeLookups_.begin(); it != scopeLookups_.end(); it++) + if (*it == specifiedScope) + { + scopeLookups_.erase(it); + it--; + } + } + + void + IdentifierResolverContext::declareClass( const ASTNodePtr &specifierNode) + { + //TODO: Implement this... } |
From: <net...@us...> - 2003-09-06 21:52:00
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv1442/src/rfta Modified Files: IdentifierResolverStrategy.h Log Message: -- extended interface for global identifier handling (not finished yet) Index: IdentifierResolverStrategy.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/IdentifierResolverStrategy.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** IdentifierResolverStrategy.h 15 Dec 2002 19:54:43 -0000 1.2 --- IdentifierResolverStrategy.h 6 Sep 2003 21:51:22 -0000 1.3 *************** *** 20,27 **** virtual ~IdentifierResolverStrategy(); ! virtual void enterNewLocalVariableScope() =0; ! virtual void exitLocalVariableScope() =0; virtual void declareLocalVariable( const ASTNodePtr &localVariableDeclNode ) =0; virtual void resolveUnqualifiedIdentifier( const ASTNodePtr &identifierNode ) =0; --- 20,42 ---- virtual ~IdentifierResolverStrategy(); ! virtual void enterUnnamedSubScope() =0; ! virtual void leaveUnnamedSubScope() =0; ! ! virtual void enterNamedSubScope(std::string name) =0; ! virtual void leaveNamedSubScope() =0; ! ! virtual void addScopeLookup(std::string name) =0; ! virtual void removeScopeLookup(std::string name) =0; virtual void declareLocalVariable( const ASTNodePtr &localVariableDeclNode ) =0; + + // store composed type 'class' and 'struct' + virtual void declareClass( const ASTNodePtr &specifierNode) =0; + // TODO: none local variables (e.g. global, parameter, class variables) + // virtual void declareVariable( const ASTNodePtr &declaratorNode) =0; + // TODO: function header + // virtual void declareFunction( const ASTNodePtr &declaratorNode) =0; + // TODO: typedefs + // virtual void declareType( const ASTNodePtr &declarationNode) =0; virtual void resolveUnqualifiedIdentifier( const ASTNodePtr &identifierNode ) =0; |
From: <net...@us...> - 2003-09-06 21:50:57
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv1310/src/rfta Modified Files: IdentifierResolverTest.h IdentifierResolverTest.cpp Log Message: -- test rework for global identifier resolver -- added test for class body resolving Index: IdentifierResolverTest.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/IdentifierResolverTest.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** IdentifierResolverTest.h 5 Apr 2003 12:12:57 -0000 1.5 --- IdentifierResolverTest.h 6 Sep 2003 21:50:51 -0000 1.6 *************** *** 7,10 **** --- 7,11 ---- #include "IdentifierResolver.h" + #include "GlobalIdentifierResolver.h" #include "MockIdentifierResolverStrategy.h" #include "SourceBasedTestBase.h" *************** *** 27,30 **** --- 28,32 ---- CPPUNIT_TEST( testForScope ); CPPUNIT_TEST( testSwitchScope ); + CPPUNIT_TEST( testClassScope ); CPPUNIT_TEST( testBug1 ); CPPUNIT_TEST_SUITE_END(); *************** *** 46,49 **** --- 48,52 ---- void testForScope(); void testSwitchScope(); + void testClassScope(); void testBug1(); *************** *** 52,56 **** void checkResolution(); ! boost::shared_ptr<IdentifierResolver> resolver_; boost::shared_ptr<MockIdentifierResolverStrategy> strategy_; }; --- 55,60 ---- void checkResolution(); ! //boost::shared_ptr<IdentifierResolver> resolver_; ! boost::shared_ptr<GlobalIdentifierResolver> resolver_; boost::shared_ptr<MockIdentifierResolverStrategy> strategy_; }; Index: IdentifierResolverTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/IdentifierResolverTest.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** IdentifierResolverTest.cpp 15 May 2003 16:29:13 -0000 1.7 --- IdentifierResolverTest.cpp 6 Sep 2003 21:50:51 -0000 1.8 *************** *** 6,9 **** --- 6,10 ---- #include "stdafx.h" #include "IdentifierResolverTest.h" + #include <rfta/Parser/DeclarationListParser.h> #include <rfta/Parser/StatementsParser.h> *************** *** 24,28 **** SourceBasedTestBase::setUp(); strategy_.reset( new MockIdentifierResolverStrategy() ); ! resolver_.reset( new IdentifierResolver( *strategy_ ) ); } --- 25,30 ---- SourceBasedTestBase::setUp(); strategy_.reset( new MockIdentifierResolverStrategy() ); ! //resolver_.reset( new IdentifierResolver( *strategy_ ) ); ! resolver_.reset( new GlobalIdentifierResolver( *strategy_ ) ); } *************** *** 49,63 **** IdentifierResolverTest::testNoLocalVariableDeclaration() { ! builder_->addKeyingMid( "", "x", "3 = ", "x.1" ); builder_->addKeyingMid( "", "tuple", "( 3, 4 );", "tuple.1" ); builder_->addKeyingMid( "", "x", ".project( ", "x.2" ); ! builder_->addKeyingMid( "", "y", " );", "y.1" ); parse((StatementsParser*)0); strategy_->setRecordMode(); strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "x.1" ) ); strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "tuple.1" ) ); strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "x.2" ) ); strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "y.1" ) ); checkResolution(); --- 51,67 ---- IdentifierResolverTest::testNoLocalVariableDeclaration() { ! builder_->addKeyingMid( "{", "x", "3 = ", "x.1" ); builder_->addKeyingMid( "", "tuple", "( 3, 4 );", "tuple.1" ); builder_->addKeyingMid( "", "x", ".project( ", "x.2" ); ! builder_->addKeyingMid( "", "y", " ); }", "y.1" ); parse((StatementsParser*)0); strategy_->setRecordMode(); + strategy_->enterUnnamedSubScope(); strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "x.1" ) ); strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "tuple.1" ) ); strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "x.2" ) ); strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "y.1" ) ); + strategy_->leaveUnnamedSubScope(); checkResolution(); *************** *** 68,80 **** IdentifierResolverTest::testLocaleVariableDeclaration() { ! builder_->addKeyingMid( "int ", "x", " = 3,", "x.0" ); builder_->addKeyingMid( "", "y", " = 4;", "y.0" ); ! builder_->addKeyingMid( "double ", "z", " = 3.14;", "z.0" ); parse((StatementsParser*)0); strategy_->setRecordMode(); strategy_->declareLocalVariable( getVariableNode( "x.0" ) ); strategy_->declareLocalVariable( getVariableNode( "y.0" ) ); strategy_->declareLocalVariable( getVariableNode( "z.0" ) ); checkResolution(); --- 72,86 ---- IdentifierResolverTest::testLocaleVariableDeclaration() { ! builder_->addKeyingMid( "{ int ", "x", " = 3,", "x.0" ); builder_->addKeyingMid( "", "y", " = 4;", "y.0" ); ! builder_->addKeyingMid( "double ", "z", " = 3.14; }", "z.0" ); parse((StatementsParser*)0); strategy_->setRecordMode(); + strategy_->enterUnnamedSubScope(); strategy_->declareLocalVariable( getVariableNode( "x.0" ) ); strategy_->declareLocalVariable( getVariableNode( "y.0" ) ); strategy_->declareLocalVariable( getVariableNode( "z.0" ) ); + strategy_->leaveUnnamedSubScope(); checkResolution(); *************** *** 85,97 **** IdentifierResolverTest::testLocaleVariableDeclarationWithInitializer() { ! builder_->addKeyingMid( "int ", "x", " = 3,", "x.0" ); builder_->addKeyingMid( "int ", "y", " = ", "y.0" ); ! builder_->addKeyingMid( "", "x", ";", "x.1" ); parse((StatementsParser*)0); strategy_->setRecordMode(); strategy_->declareLocalVariable( getVariableNode( "x.0" ) ); strategy_->declareLocalVariable( getVariableNode( "y.0" ) ); strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "x.1" ) ); checkResolution(); --- 91,105 ---- IdentifierResolverTest::testLocaleVariableDeclarationWithInitializer() { ! builder_->addKeyingMid( "{ int ", "x", " = 3,", "x.0" ); builder_->addKeyingMid( "int ", "y", " = ", "y.0" ); ! builder_->addKeyingMid( "", "x", "; }", "x.1" ); parse((StatementsParser*)0); strategy_->setRecordMode(); + strategy_->enterUnnamedSubScope(); strategy_->declareLocalVariable( getVariableNode( "x.0" ) ); strategy_->declareLocalVariable( getVariableNode( "y.0" ) ); strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "x.1" ) ); + strategy_->leaveUnnamedSubScope(); checkResolution(); *************** *** 110,118 **** parse((StatementsParser*)0); strategy_->setRecordMode(); ! strategy_->enterNewLocalVariableScope(); strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "x.1" ) ); strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "tuple.1" ) ); strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "x.2" ) ); ! strategy_->exitLocalVariableScope(); checkResolution(); --- 118,126 ---- parse((StatementsParser*)0); strategy_->setRecordMode(); ! strategy_->enterUnnamedSubScope(); strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "x.1" ) ); strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "tuple.1" ) ); strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "x.2" ) ); ! strategy_->leaveUnnamedSubScope(); checkResolution(); *************** *** 123,139 **** IdentifierResolverTest::testIfThenScope() { ! builder_->addKeyingMid( "if ( int ", "x", " = 3 )", "x.0" ); ! builder_->addKeyingMid( " int ", "y", " = 4;", "y.0" ); parse((StatementsParser*)0); strategy_->setRecordMode(); ! strategy_->enterNewLocalVariableScope(); strategy_->declareLocalVariable( getVariableNode( "x.0" ) ); ! strategy_->enterNewLocalVariableScope(); strategy_->declareLocalVariable( getVariableNode( "y.0" ) ); ! strategy_->exitLocalVariableScope(); ! strategy_->exitLocalVariableScope(); checkResolution(); --- 131,149 ---- IdentifierResolverTest::testIfThenScope() { ! builder_->addKeyingMid( "{ if ( int ", "x", " = 3 )", "x.0" ); ! builder_->addKeyingMid( " int ", "y", " = 4; }", "y.0" ); parse((StatementsParser*)0); strategy_->setRecordMode(); ! strategy_->enterUnnamedSubScope(); ! strategy_->enterUnnamedSubScope(); strategy_->declareLocalVariable( getVariableNode( "x.0" ) ); ! strategy_->enterUnnamedSubScope(); strategy_->declareLocalVariable( getVariableNode( "y.0" ) ); ! strategy_->leaveUnnamedSubScope(); ! strategy_->leaveUnnamedSubScope(); ! strategy_->leaveUnnamedSubScope(); checkResolution(); *************** *** 144,166 **** IdentifierResolverTest::testIfThenElseScope() { ! builder_->addKeyingMid( "if ( int ", "x", " = 3 )", "x.0" ); builder_->addKeyingMid( " int ", "y", " = 4;", "y.0" ); builder_->add( "else" ); ! builder_->addKeyingMid( " int ", "z", " = 1;", "z.0" ); parse((StatementsParser*)0); strategy_->setRecordMode(); ! strategy_->enterNewLocalVariableScope(); strategy_->declareLocalVariable( getVariableNode( "x.0" ) ); ! strategy_->enterNewLocalVariableScope(); strategy_->declareLocalVariable( getVariableNode( "y.0" ) ); ! strategy_->exitLocalVariableScope(); ! strategy_->enterNewLocalVariableScope(); strategy_->declareLocalVariable( getVariableNode( "z.0" ) ); ! strategy_->exitLocalVariableScope(); ! strategy_->exitLocalVariableScope(); checkResolution(); --- 154,178 ---- IdentifierResolverTest::testIfThenElseScope() { ! builder_->addKeyingMid( "{ if ( int ", "x", " = 3 )", "x.0" ); builder_->addKeyingMid( " int ", "y", " = 4;", "y.0" ); builder_->add( "else" ); ! builder_->addKeyingMid( " int ", "z", " = 1; }", "z.0" ); parse((StatementsParser*)0); strategy_->setRecordMode(); ! 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(); ! strategy_->leaveUnnamedSubScope(); ! strategy_->leaveUnnamedSubScope(); checkResolution(); *************** *** 171,187 **** IdentifierResolverTest::testWhileScope() { ! builder_->addKeyingMid( "while ( char ", "c", " = ::next() )", "c.0" ); ! builder_->addKeyingMid( " int ", "y", " = 4;", "y.0" ); parse((StatementsParser*)0); strategy_->setRecordMode(); ! strategy_->enterNewLocalVariableScope(); strategy_->declareLocalVariable( getVariableNode( "c.0" ) ); ! strategy_->enterNewLocalVariableScope(); strategy_->declareLocalVariable( getVariableNode( "y.0" ) ); ! strategy_->exitLocalVariableScope(); ! strategy_->exitLocalVariableScope(); checkResolution(); --- 183,201 ---- IdentifierResolverTest::testWhileScope() { ! builder_->addKeyingMid( "{ while ( char ", "c", " = ::next() )", "c.0" ); ! builder_->addKeyingMid( " int ", "y", " = 4; }", "y.0" ); parse((StatementsParser*)0); strategy_->setRecordMode(); ! strategy_->enterUnnamedSubScope(); ! strategy_->enterUnnamedSubScope(); strategy_->declareLocalVariable( getVariableNode( "c.0" ) ); ! strategy_->enterUnnamedSubScope(); strategy_->declareLocalVariable( getVariableNode( "y.0" ) ); ! strategy_->leaveUnnamedSubScope(); ! strategy_->leaveUnnamedSubScope(); ! strategy_->leaveUnnamedSubScope(); checkResolution(); *************** *** 192,212 **** IdentifierResolverTest::testForScope() { ! builder_->addKeyingMid( "for ( int ", "index", " = 0;", "index.0" ); builder_->addKeyingMid( " ", "index", " < 5;", "index.1" ); builder_->addKeyingMid( " ", "++index", " )", "index.2" ); ! builder_->addKeyingMid( " int ", "x", " = 2;", "x.0" ); parse((StatementsParser*)0); strategy_->setRecordMode(); ! strategy_->enterNewLocalVariableScope(); strategy_->declareLocalVariable( getVariableNode( "index.0" ) ); strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "index.1" ) ); strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "index.2" ) ); ! strategy_->enterNewLocalVariableScope(); strategy_->declareLocalVariable( getVariableNode( "x.0" ) ); ! strategy_->exitLocalVariableScope(); ! strategy_->exitLocalVariableScope(); checkResolution(); --- 206,228 ---- IdentifierResolverTest::testForScope() { ! builder_->addKeyingMid( "{ for ( int ", "index", " = 0;", "index.0" ); builder_->addKeyingMid( " ", "index", " < 5;", "index.1" ); builder_->addKeyingMid( " ", "++index", " )", "index.2" ); ! builder_->addKeyingMid( " int ", "x", " = 2; }", "x.0" ); parse((StatementsParser*)0); strategy_->setRecordMode(); ! 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(); ! strategy_->leaveUnnamedSubScope(); ! strategy_->leaveUnnamedSubScope(); checkResolution(); *************** *** 217,260 **** IdentifierResolverTest::testSwitchScope() { ! builder_->addKeyingMid( "switch ( char ", "c", " = ::next() )", "c.0" ); builder_->add( "{" ); builder_->add( "case ' ':" ); builder_->addKeyingMid( " ", "c", ";", "c.1" ); builder_->add( "default:" ); ! builder_->add( "}" ); parse((StatementsParser*)0); strategy_->setRecordMode(); ! strategy_->enterNewLocalVariableScope(); strategy_->declareLocalVariable( getVariableNode( "c.0" ) ); ! ! strategy_->enterNewLocalVariableScope(); ! strategy_->enterNewLocalVariableScope(); strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "c.1" ) ); ! strategy_->exitLocalVariableScope(); ! strategy_->exitLocalVariableScope(); ! strategy_->exitLocalVariableScope(); checkResolution(); } - void ! IdentifierResolverTest::testBug1() ! { ! /* // The last occurrence bigBuffer is not recognized as a local variable (found using the add-in). ! { ! std::vector<int> bigBuffer; ! { ! KTEST_ASSERT_EQUAL( index, bigBuffer[index] ); ! } } */ ! builder_->addKeyingMid( "std::vector<int> ", "bigBuffer", ";", "bigBuffer.0" ); builder_->add( "{" ); builder_->addKeyingMid( " ","KTEST_ASSERT_EQUAL","( ", "ktest.0" ); --- 233,300 ---- IdentifierResolverTest::testSwitchScope() { ! builder_->addKeyingMid( "{ switch ( char ", "c", " = ::next() )", "c.0" ); builder_->add( "{" ); builder_->add( "case ' ':" ); builder_->addKeyingMid( " ", "c", ";", "c.1" ); builder_->add( "default:" ); ! builder_->add( "} }" ); parse((StatementsParser*)0); strategy_->setRecordMode(); ! strategy_->enterUnnamedSubScope(); ! strategy_->enterUnnamedSubScope(); strategy_->declareLocalVariable( getVariableNode( "c.0" ) ); ! ! strategy_->enterUnnamedSubScope(); ! strategy_->enterUnnamedSubScope(); strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "c.1" ) ); ! strategy_->leaveUnnamedSubScope(); ! strategy_->leaveUnnamedSubScope(); ! strategy_->leaveUnnamedSubScope(); ! strategy_->leaveUnnamedSubScope(); checkResolution(); } void ! 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(); } + + + void + IdentifierResolverTest::testBug1() + { + /* + The last occurrence bigBuffer was not recognized as a local variable */ ! builder_->addKeyingMid( "{ std::vector<int> ", "bigBuffer", ";", "bigBuffer.0" ); builder_->add( "{" ); builder_->addKeyingMid( " ","KTEST_ASSERT_EQUAL","( ", "ktest.0" ); *************** *** 262,277 **** builder_->addKeyingMid( "", "bigBuffer", "", "bigBuffer.1" ); builder_->addKeyingMid( "[", "index", "] );", "index.2" ); ! builder_->add( "}" ); parse((StatementsParser*)0); strategy_->setRecordMode(); strategy_->declareLocalVariable( getVariableNode( "bigBuffer.0" ) ); ! strategy_->enterNewLocalVariableScope(); strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "ktest.0" ) ); strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "index.1" ) ); strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "bigBuffer.1" ) ); strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "index.2" ) ); ! strategy_->exitLocalVariableScope(); checkResolution(); --- 302,320 ---- builder_->addKeyingMid( "", "bigBuffer", "", "bigBuffer.1" ); builder_->addKeyingMid( "[", "index", "] );", "index.2" ); ! builder_->add( "} }" ); parse((StatementsParser*)0); strategy_->setRecordMode(); + strategy_->enterUnnamedSubScope(); strategy_->declareLocalVariable( getVariableNode( "bigBuffer.0" ) ); ! strategy_->enterUnnamedSubScope(); strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "ktest.0" ) ); strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "index.1" ) ); strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "bigBuffer.1" ) ); strategy_->resolveUnqualifiedIdentifier( getIdentifierNode( "index.2" ) ); ! strategy_->leaveUnnamedSubScope(); ! ! strategy_->leaveUnnamedSubScope(); checkResolution(); |
From: <net...@us...> - 2003-09-06 21:49:56
|
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 |
From: <net...@us...> - 2003-09-06 21:49:20
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv984/src/rfta Modified Files: IdentifierScopeTest.h IdentifierScopeTest.cpp Log Message: -- test for qualified identifier lookup added Index: IdentifierScopeTest.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/IdentifierScopeTest.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IdentifierScopeTest.h 15 May 2003 16:25:40 -0000 1.1 --- IdentifierScopeTest.h 6 Sep 2003 21:48:55 -0000 1.2 *************** *** 6,11 **** #define RFTA_IDENTIFIERSCOPETEST_H - #include "IdentifierScope.h" #include "UnitTesting.h" namespace Refactoring --- 6,11 ---- #define RFTA_IDENTIFIERSCOPETEST_H #include "UnitTesting.h" + #include "IdentifierScope.h" namespace Refactoring *************** *** 18,21 **** --- 18,22 ---- CPPUNIT_TEST_SUITE( IdentifierScopeTest ); CPPUNIT_TEST( testIdentifierResolutionInOneScope ); + CPPUNIT_TEST( testQualifiedScopeLookup ); CPPUNIT_TEST_SUITE_END(); *************** *** 32,35 **** --- 33,37 ---- void testIdentifierResolutionInOneScope(); + void testQualifiedScopeLookup(); }; Index: IdentifierScopeTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/IdentifierScopeTest.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IdentifierScopeTest.cpp 15 May 2003 16:25:40 -0000 1.1 --- IdentifierScopeTest.cpp 6 Sep 2003 21:48:55 -0000 1.2 *************** *** 81,85 **** --- 81,96 ---- } + void + IdentifierScopeTest::testQualifiedScopeLookup() + { + IdentifierScopePtr rootScope = IdentifierScope::createScope(IdentifierScopeWeakPtr()); + IdentifierScopePtr scopeA = IdentifierScope::createSubScope(rootScope,"A"); // "::A" + IdentifierScopePtr scopeB = IdentifierScope::createSubScope(scopeA ,"B"); // "::A::B" + IdentifierScopePtr scopeC = IdentifierScope::createSubScope(rootScope,"C"); // "::C" + IdentifierScopePtr scopeD = IdentifierScope::createSubScope(scopeB ,"D"); // "::A::B::D" + 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") ); + } } // namespace Refactoring |
From: <net...@us...> - 2003-09-06 21:48:31
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv828/src/rfta Modified Files: MockIdentifierResolverStrategy.h MockIdentifierResolverStrategy.cpp Log Message: -- extensions for global identifier resolve (does not work yet) Index: MockIdentifierResolverStrategy.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/MockIdentifierResolverStrategy.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MockIdentifierResolverStrategy.h 15 Dec 2002 15:48:30 -0000 1.1 --- MockIdentifierResolverStrategy.h 6 Sep 2003 21:48:01 -0000 1.2 *************** *** 29,38 **** public: // overriden from IdentifierResolverStrategy ! void enterNewLocalVariableScope(); ! void exitLocalVariableScope(); void declareLocalVariable( const ASTNodePtr &localVariableDeclNode ); void resolveUnqualifiedIdentifier( const ASTNodePtr &identifierNode ); private: --- 29,46 ---- public: // overriden from IdentifierResolverStrategy ! void enterUnnamedSubScope(); ! 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); + void removeScopeLookup(std::string qualifiedName); private: Index: MockIdentifierResolverStrategy.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/MockIdentifierResolverStrategy.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MockIdentifierResolverStrategy.cpp 15 Dec 2002 15:48:30 -0000 1.1 --- MockIdentifierResolverStrategy.cpp 6 Sep 2003 21:48:01 -0000 1.2 *************** *** 24,37 **** void ! MockIdentifierResolverStrategy::enterNewLocalVariableScope() { ! addCall( "MockIdentifierResolverStrategy::enterNewLocalVariableScope()" ); } void ! MockIdentifierResolverStrategy::exitLocalVariableScope() { ! addCall( "MockIdentifierResolverStrategy::exitLocalVariableScope()" ); } --- 24,37 ---- void ! MockIdentifierResolverStrategy::enterUnnamedSubScope() { ! addCall( "MockIdentifierResolverStrategy::enterUnnamedSubScope()" ); } void ! MockIdentifierResolverStrategy::leaveUnnamedSubScope() { ! addCall( "MockIdentifierResolverStrategy::leaveUnnamedSubScope()" ); } *************** *** 54,57 **** --- 54,83 ---- } + void + MockIdentifierResolverStrategy::enterNamedSubScope(std::string name) + { + addCall( "MockIdentifierResolverStrategy::enterNamedSubScope( " + + name + ")" ); + } + + void + MockIdentifierResolverStrategy::leaveNamedSubScope() + { + addCall( "MockIdentifierResolverStrategy::leaveNamedSubScope()" ); + } + + void + MockIdentifierResolverStrategy::addScopeLookup(std::string qualifiedName) + { + addCall( "MockIdentifierResolverStrategy::addScopeLookup( " + + qualifiedName + ")" ); + } + + void + MockIdentifierResolverStrategy::removeScopeLookup(std::string qualifiedName) + { + addCall( "MockIdentifierResolverStrategy::removeScopeLookup( " + + qualifiedName + ")" ); + } const std::string *************** *** 62,65 **** --- 88,98 ---- return "ASTNode<type=" + nodeType + "; range=" + nodeRange + ">"; + } + + void + MockIdentifierResolverStrategy::declareClass(const ASTNodePtr &specifierNode ) + { + addCall( "MockIdentifierResolverStrategy::declareClass( " + + nodeToString( specifierNode ) + ")" ); } |
From: <net...@us...> - 2003-09-06 21:47:13
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv668/src/rfta Modified Files: rfta.dsp Log Message: -- additional files in project Index: rfta.dsp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/rfta.dsp,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** rfta.dsp 29 May 2003 09:55:25 -0000 1.51 --- rfta.dsp 6 Sep 2003 21:47:10 -0000 1.52 *************** *** 56,61 **** # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib cppunit_dll.lib /nologo /dll /debug /machine:I386 /out:"..\..\build\rfta\Release/rfta_mdr.ext" /libpath:"../../deplib/cppunit/lib" /libpath:"../../lib" # Begin Special Build Tool ! TargetDir=\prg\vc\Rfta\build\rfta\Release ! TargetPath=\prg\vc\Rfta\build\rfta\Release\rfta_mdr.ext TargetName=rfta_mdr SOURCE="$(InputPath)" --- 56,61 ---- # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib cppunit_dll.lib /nologo /dll /debug /machine:I386 /out:"..\..\build\rfta\Release/rfta_mdr.ext" /libpath:"../../deplib/cppunit/lib" /libpath:"../../lib" # Begin Special Build Tool ! TargetDir=\Projects\Cpptool\rfta\build\rfta\Release ! TargetPath=\Projects\Cpptool\rfta\build\rfta\Release\rfta_mdr.ext TargetName=rfta_mdr SOURCE="$(InputPath)" *************** *** 90,95 **** # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib cppunitd_dll.lib /nologo /dll /debug /machine:I386 /out:"..\..\build\rfta\Debug\rfta_mdd.ext" /pdbtype:sept /libpath:"../../deplib/cppunit/lib" /libpath:"../../lib" # Begin Special Build Tool ! TargetDir=\prg\vc\Rfta\build\rfta\Debug ! TargetPath=\prg\vc\Rfta\build\rfta\Debug\rfta_mdd.ext TargetName=rfta_mdd SOURCE="$(InputPath)" --- 90,95 ---- # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib cppunitd_dll.lib /nologo /dll /debug /machine:I386 /out:"..\..\build\rfta\Debug\rfta_mdd.ext" /pdbtype:sept /libpath:"../../deplib/cppunit/lib" /libpath:"../../lib" # Begin Special Build Tool ! TargetDir=\Projects\Cpptool\rfta\build\rfta\Debug ! TargetPath=\Projects\Cpptool\rfta\build\rfta\Debug\rfta_mdd.ext TargetName=rfta_mdd SOURCE="$(InputPath)" *************** *** 147,150 **** --- 147,158 ---- # Begin Source File + SOURCE=.\GlobalIdentifierResolver.cpp + # End Source File + # Begin Source File + + SOURCE=.\GlobalIdentifierResolver.h + # End Source File + # Begin Source File + SOURCE=.\IdentifierResolver.cpp # End Source File *************** *** 440,444 **** # Begin Source File ! SOURCE=.\MockIdentifierResolverStrategy.cpp !IF "$(CFG)" == "rfta - Win32 Release" --- 448,452 ---- # Begin Source File ! SOURCE=.\MockLineBasedTextDocument.cpp !IF "$(CFG)" == "rfta - Win32 Release" *************** *** 453,457 **** # Begin Source File ! SOURCE=.\MockIdentifierResolverStrategy.h !IF "$(CFG)" == "rfta - Win32 Release" --- 461,465 ---- # Begin Source File ! SOURCE=.\MockLineBasedTextDocument.h !IF "$(CFG)" == "rfta - Win32 Release" *************** *** 466,470 **** # Begin Source File ! SOURCE=.\MockLineBasedTextDocument.cpp !IF "$(CFG)" == "rfta - Win32 Release" --- 474,478 ---- # Begin Source File ! SOURCE=.\MockTextDocument.cpp !IF "$(CFG)" == "rfta - Win32 Release" *************** *** 479,483 **** # Begin Source File ! SOURCE=.\MockLineBasedTextDocument.h !IF "$(CFG)" == "rfta - Win32 Release" --- 487,491 ---- # Begin Source File ! SOURCE=.\MockTextDocument.h !IF "$(CFG)" == "rfta - Win32 Release" *************** *** 492,496 **** # Begin Source File ! SOURCE=.\MockTextDocument.cpp !IF "$(CFG)" == "rfta - Win32 Release" --- 500,504 ---- # Begin Source File ! SOURCE=.\ReplaceTextTransformTest.cpp !IF "$(CFG)" == "rfta - Win32 Release" *************** *** 505,509 **** # Begin Source File ! SOURCE=.\MockTextDocument.h !IF "$(CFG)" == "rfta - Win32 Release" --- 513,517 ---- # Begin Source File ! SOURCE=.\ReplaceTextTransformTest.h !IF "$(CFG)" == "rfta - Win32 Release" *************** *** 518,522 **** # Begin Source File ! SOURCE=.\ReplaceTextTransformTest.cpp !IF "$(CFG)" == "rfta - Win32 Release" --- 526,530 ---- # Begin Source File ! SOURCE=.\TransformListTest.cpp !IF "$(CFG)" == "rfta - Win32 Release" *************** *** 531,535 **** # Begin Source File ! SOURCE=.\ReplaceTextTransformTest.h !IF "$(CFG)" == "rfta - Win32 Release" --- 539,543 ---- # Begin Source File ! SOURCE=.\TransformListTest.h !IF "$(CFG)" == "rfta - Win32 Release" *************** *** 542,548 **** # End Source File # Begin Source File ! SOURCE=.\TransformListTest.cpp !IF "$(CFG)" == "rfta - Win32 Release" --- 550,560 ---- # End Source File + # End Group + # Begin Group "CodeAnalysisTest" + + # PROP Default_Filter "" # Begin Source File ! SOURCE=.\IdentifierResolverContextTest.cpp !IF "$(CFG)" == "rfta - Win32 Release" *************** *** 557,561 **** # Begin Source File ! SOURCE=.\TransformListTest.h !IF "$(CFG)" == "rfta - Win32 Release" --- 569,573 ---- # Begin Source File ! SOURCE=.\IdentifierResolverContextTest.h !IF "$(CFG)" == "rfta - Win32 Release" *************** *** 568,578 **** # End Source File - # End Group - # Begin Group "CodeAnalysisTest" - - # PROP Default_Filter "" # Begin Source File ! SOURCE=.\IdentifierResolverContextTest.cpp !IF "$(CFG)" == "rfta - Win32 Release" --- 580,586 ---- # End Source File # Begin Source File ! SOURCE=.\IdentifierResolverTest.cpp !IF "$(CFG)" == "rfta - Win32 Release" *************** *** 587,591 **** # Begin Source File ! SOURCE=.\IdentifierResolverContextTest.h !IF "$(CFG)" == "rfta - Win32 Release" --- 595,599 ---- # Begin Source File ! SOURCE=.\IdentifierResolverTest.h !IF "$(CFG)" == "rfta - Win32 Release" *************** *** 600,604 **** # Begin Source File ! SOURCE=.\IdentifierResolverTest.cpp !IF "$(CFG)" == "rfta - Win32 Release" --- 608,612 ---- # Begin Source File ! SOURCE=.\IdentifierScopeTest.cpp !IF "$(CFG)" == "rfta - Win32 Release" *************** *** 613,617 **** # Begin Source File ! SOURCE=.\IdentifierResolverTest.h !IF "$(CFG)" == "rfta - Win32 Release" --- 621,625 ---- # Begin Source File ! SOURCE=.\IdentifierScopeTest.h !IF "$(CFG)" == "rfta - Win32 Release" *************** *** 626,630 **** # Begin Source File ! SOURCE=.\IdentifierScopeTest.cpp !IF "$(CFG)" == "rfta - Win32 Release" --- 634,638 ---- # Begin Source File ! SOURCE=.\IdentifierVisitorTest.cpp !IF "$(CFG)" == "rfta - Win32 Release" *************** *** 639,643 **** # Begin Source File ! SOURCE=.\IdentifierScopeTest.h !IF "$(CFG)" == "rfta - Win32 Release" --- 647,651 ---- # Begin Source File ! SOURCE=.\IdentifierVisitorTest.h !IF "$(CFG)" == "rfta - Win32 Release" *************** *** 652,656 **** # Begin Source File ! SOURCE=.\IdentifierVisitorTest.cpp !IF "$(CFG)" == "rfta - Win32 Release" --- 660,664 ---- # Begin Source File ! SOURCE=.\MockIdentifierResolverStrategy.cpp !IF "$(CFG)" == "rfta - Win32 Release" *************** *** 665,669 **** # Begin Source File ! SOURCE=.\IdentifierVisitorTest.h !IF "$(CFG)" == "rfta - Win32 Release" --- 673,677 ---- # Begin Source File ! SOURCE=.\MockIdentifierResolverStrategy.h !IF "$(CFG)" == "rfta - Win32 Release" |
From: <net...@us...> - 2003-09-06 21:46:39
|
Update of /cvsroot/cpptool/rfta/include/rfta/parser In directory sc8-pr-cvs1:/tmp/cvs-serv539/include/rfta/parser Modified Files: ASTNodes.h Log Message: -- fixed flags for identifier resolver -- added nodes and properties Index: ASTNodes.h =================================================================== RCS file: /cvsroot/cpptool/rfta/include/rfta/parser/ASTNodes.h,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** ASTNodes.h 16 May 2003 09:58:42 -0000 1.22 --- ASTNodes.h 6 Sep 2003 21:46:20 -0000 1.23 *************** *** 72,76 **** --- 72,79 ---- static const ASTNodeType elaboratedTypeSpecifier; + // unparsed declarator static const ASTNodeType unparsedDeclarator; + // parsed declarator + static const ASTNodeType declarator; static const ASTNodeType pureSpecifier; *************** *** 243,246 **** --- 246,250 ---- static const ASTNodeProperty enumBodyProperty; static const ASTNodeProperty classBodyProperty; + static const ASTNodeProperty classNameProperty; static const ASTNodeProperty macroIdentifier; |
From: <net...@us...> - 2003-09-06 21:46:11
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv447/src/rfta Added Files: GlobalIdentifierResolver.h GlobalIdentifierResolver.cpp Log Message: -- global identifier resolver (does call IdentifierResolver for local searches) --- NEW FILE: GlobalIdentifierResolver.h --- // ////////////////////////////////////////////////////////////////////////// // (c)Copyright 2003, Andre Baresel. // Created: 2003/08/27 // ////////////////////////////////////////////////////////////////////////// #ifndef RFTA_GlobalIdentifierResolver_H #define RFTA_GlobalIdentifierResolver_H #include <rfta/refactoring/Config.h> #include <rfta/parser/ASTNode.h> #include <rfta/parser/ASTNodeAndPropertyVisitor.h> #include <rfta/parser/ASTNodeVisitor.h> namespace Refactoring { // just abstract: class IdentifierResolverStrategy; /// Explores an AST searching for local scope identifiers. class GlobalIdentifierResolver : public ASTNodeAndPropertyVisitor { public: GlobalIdentifierResolver ( IdentifierResolverStrategy &context ); virtual void visitNode( const ASTNodePtr &node ); protected: bool canSkipNode( const ASTNodePtr& node ) const; bool needsToVisitProperties( const ASTNodePtr& node ) const; bool needsToVisitChildren( const ASTNodePtr& node ) const; bool needsToHandleNode( const ASTNodePtr& node ) const; void handleNode( const ASTNodePtr& node ); private: IdentifierResolverStrategy &context_; }; } // namespace Refactoring #endif // RFTA_GlobalIdentifierResolver_H --- NEW FILE: GlobalIdentifierResolver.cpp --- // ////////////////////////////////////////////////////////////////////////// // (c)Copyright 2003, Andre Baresel // Created: 2003/08/27 // ////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "GlobalIdentifierResolver.h" #include "IdentifierResolver.h" #include "IdentifierResolverStrategy.h" #include <rfta/Parser/ASTNodes.h> namespace Refactoring { void GlobalIdentifierResolver::visitNode( const ASTNodePtr &node ) { // 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 { // unnamed classes: context_.enterUnnamedSubScope(); ASTNodeAndPropertyVisitor::visitNode(node); context_.leaveNamedSubScope(); } } else { // visit properties and childs: ASTNodeAndPropertyVisitor::visitNode(node); } } GlobalIdentifierResolver::GlobalIdentifierResolver ( IdentifierResolverStrategy &context ): context_(context) { } bool GlobalIdentifierResolver::canSkipNode(const ASTNodePtr& node) const { return false; } bool GlobalIdentifierResolver::needsToVisitProperties(const ASTNodePtr& node ) const { if (node->getType() == ASTNodeTypes::compoundStatement) return false; return true; } bool GlobalIdentifierResolver::needsToVisitChildren(const ASTNodePtr& node ) const { if (node->getType() == ASTNodeTypes::compoundStatement) return false; return true; } bool GlobalIdentifierResolver::needsToHandleNode( const ASTNodePtr& node ) const { return true; } void GlobalIdentifierResolver::handleNode( const ASTNodePtr& node ) { if (node->getType() == ASTNodeTypes::compoundStatement) { // make reuse of Old-Identifier-Resolver IdentifierResolver resolve(context_); resolve.visitNode(node); return; } if (node->getType() == ASTNodeTypes::declarator) { // get the identifier node ASTNodePtr ident = node->getChildAt(0); context_.declareLocalVariable(ident); } } } // namespace Refactoring |
From: <net...@us...> - 2003-09-06 21:45:19
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv32733 Modified Files: ASTNodes.cpp Log Message: -- fixed flags for identifier resolver -- added nodes and properties Index: ASTNodes.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/ASTNodes.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** ASTNodes.cpp 16 May 2003 09:58:43 -0000 1.25 --- ASTNodes.cpp 6 Sep 2003 21:44:53 -0000 1.26 *************** *** 21,25 **** const ASTNodeType ASTNodeTypes::namespaceDeclaration ( "namespace-declaration" , mayHaveLocalScopeIdentifierChildren | mayHaveFunctionImplChildren ); const ASTNodeType ASTNodeTypes::declarationList ( "declaration-list" , mayHaveLocalScopeIdentifierChildren | mayHaveFunctionImplChildren ); ! const ASTNodeType ASTNodeTypes::functionImplementation ( "function-implementation" , mayHaveLocalScopeIdentifierChildren ); const ASTNodeType ASTNodeTypes::unparsedDeclarationList ( "unparsed-declaration-list", mayHaveLocalScopeIdentifierChildren ); const ASTNodeType ASTNodeTypes::unparsedDeclaration ( "unparsed-declaration", mayHaveLocalScopeIdentifierChildren ); --- 21,25 ---- const ASTNodeType ASTNodeTypes::namespaceDeclaration ( "namespace-declaration" , mayHaveLocalScopeIdentifierChildren | mayHaveFunctionImplChildren ); const ASTNodeType ASTNodeTypes::declarationList ( "declaration-list" , mayHaveLocalScopeIdentifierChildren | mayHaveFunctionImplChildren ); ! const ASTNodeType ASTNodeTypes::functionImplementation ( "function-implementation" , mayHaveLocalScopeIdentifierProperties ); const ASTNodeType ASTNodeTypes::unparsedDeclarationList ( "unparsed-declaration-list", mayHaveLocalScopeIdentifierChildren ); const ASTNodeType ASTNodeTypes::unparsedDeclaration ( "unparsed-declaration", mayHaveLocalScopeIdentifierChildren ); *************** *** 27,37 **** const ASTNodeType ASTNodeTypes::unparsedTemplateHeader ( "unparsed-template-header", mayHaveLocalScopeIdentifierChildren ); ! const ASTNodeType ASTNodeTypes::declaration ( "declaration" , 0 ); ! const ASTNodeType ASTNodeTypes::declarationSpecifierList ( "declaration-specifier-list" , 0 ); const ASTNodeType ASTNodeTypes::simpleTypeSpecifier ( "simple-type-specifier" , 0 ); ! const ASTNodeType ASTNodeTypes::classSpecifier ( "class-specifier" , 0 ); ! const ASTNodeType ASTNodeTypes::enumSpecifier ( "enum-specifier" , 0 ); const ASTNodeType ASTNodeTypes::elaboratedTypeSpecifier ( "elaborated-type-specifier" , 0 ); const ASTNodeType ASTNodeTypes::unparsedDeclarator ( "unparsed-declarator" , 0 ); const ASTNodeType ASTNodeTypes::enumBody( "enum-body" , 0 ); const ASTNodeType ASTNodeTypes::enumConstant( "enum-constant" , 0 ); --- 27,38 ---- const ASTNodeType ASTNodeTypes::unparsedTemplateHeader ( "unparsed-template-header", mayHaveLocalScopeIdentifierChildren ); ! const ASTNodeType ASTNodeTypes::declaration ( "declaration" , mayHaveLocalScopeIdentifierChildren | mayHaveLocalScopeIdentifierProperties ); // specifier-identifier & declarator-identifier ! const ASTNodeType ASTNodeTypes::declarationSpecifierList ( "declaration-specifier-list" , mayHaveLocalScopeIdentifierChildren ); // specifier-identifier const ASTNodeType ASTNodeTypes::simpleTypeSpecifier ( "simple-type-specifier" , 0 ); ! const ASTNodeType ASTNodeTypes::classSpecifier ( "class-specifier" , mayHaveLocalScopeIdentifierProperties ); ! const ASTNodeType ASTNodeTypes::enumSpecifier ( "enum-specifier" , mayHaveLocalScopeIdentifierProperties ); const ASTNodeType ASTNodeTypes::elaboratedTypeSpecifier ( "elaborated-type-specifier" , 0 ); const ASTNodeType ASTNodeTypes::unparsedDeclarator ( "unparsed-declarator" , 0 ); + const ASTNodeType ASTNodeTypes::declarator ( "declarator", mayHaveLocalScopeIdentifierChildren ); const ASTNodeType ASTNodeTypes::enumBody( "enum-body" , 0 ); const ASTNodeType ASTNodeTypes::enumConstant( "enum-constant" , 0 ); *************** *** 123,126 **** --- 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" ); |
From: <net...@us...> - 2003-09-06 21:45:19
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv32595 Modified Files: DeclarationDetailsParser.h DeclarationDetailsParser.cpp Log Message: -- fixed class parsing Index: DeclarationDetailsParser.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/DeclarationDetailsParser.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** DeclarationDetailsParser.h 16 May 2003 10:00:43 -0000 1.7 --- DeclarationDetailsParser.h 6 Sep 2003 21:43:43 -0000 1.8 *************** *** 58,61 **** --- 58,62 ---- void addNamedClassNodeAndReadBody( int specifierStart, + int nameIdentStart, const ASTNodePtr &specifierList, const std::string &specifierIdent ); Index: DeclarationDetailsParser.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/DeclarationDetailsParser.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** DeclarationDetailsParser.cpp 16 May 2003 10:00:44 -0000 1.12 --- DeclarationDetailsParser.cpp 6 Sep 2003 21:43:43 -0000 1.13 *************** *** 238,243 **** // if no identifier follows, an unnamed type is specifier (e.g. "struct { } x;") Xtl::CStringView secondIdent; ! if ( tryReadNextIdentifier( secondIdent ) ) ! skipSpaces(); Xtl::CStringView thirdIdent; // in the case of export macro: class RFTA_API SourceRange {}; --- 238,250 ---- // if no identifier follows, an unnamed type is specifier (e.g. "struct { } x;") Xtl::CStringView secondIdent; ! int nameIdentStart = -1; ! { ! int save_pos = getCurrentIndex(); ! if ( tryReadNextIdentifier( secondIdent ) ) ! { ! nameIdentStart = save_pos; ! skipSpaces(); ! } ! } Xtl::CStringView thirdIdent; // in the case of export macro: class RFTA_API SourceRange {}; *************** *** 248,253 **** } ! // check if no identifier or the identifier is not followed by a ':' (e.g. "class x {" ! if ( secondIdent.isEmpty() || !tryNextIs(':') ) { addAnonymousClassNodeAndReadBody( specifierStart, specifierList, specifierIdent ); --- 255,260 ---- } ! // check handle anonymouse classes (e.g. "class {" ) ! if ( secondIdent.isEmpty() ) { addAnonymousClassNodeAndReadBody( specifierStart, specifierList, specifierIdent ); *************** *** 255,263 **** } ! // HERE we come only in case where the type is followed by a colon. "e.g. class x:" ! // check if it is only a single colon (which means inheritance information e.g. "class x: public y ") ! if ( !tryNextIs(':') ) { ! addNamedClassNodeAndReadBody( specifierStart, specifierList, specifierIdent ); return; } --- 262,269 ---- } ! // check only a single colon follows (which means inheritance information e.g. "class x: public y ") ! if (!tryReadNext("::")) { ! addNamedClassNodeAndReadBody( specifierStart, nameIdentStart, specifierList, specifierIdent ); return; } *************** *** 323,327 **** specifierList, specifierStart, ! getCurrentIndex()-specifierStart ); specifierList->addChild(specifier); --- 329,333 ---- specifierList, specifierStart, ! 0 ); // length not yet known... specifierList->addChild(specifier); *************** *** 339,357 **** void DeclarationDetailsParser::addNamedClassNodeAndReadBody( int specifierStart, const ASTNodePtr &specifierList, const std::string &specifierIdent ) { - if ( !isClassTypeSpecifier( specifierIdent ) ) - throwFailure( "unknown specifier type: " + specifierIdent ); - // add the specifier node ASTNodePtr specifier = createASTNode( ASTNodeTypes::classSpecifier, specifierList, specifierStart, ! getCurrentIndex()-specifierStart ); specifierList->addChild(specifier); ! // read the complete specifier: ! readClassOrEnumSpecifier( specifier, specifierIdent ); // set real length after completed parsing --- 345,379 ---- void DeclarationDetailsParser::addNamedClassNodeAndReadBody( int specifierStart, + int secondIdentStart, const ASTNodePtr &specifierList, const std::string &specifierIdent ) { // add the specifier node ASTNodePtr specifier = createASTNode( ASTNodeTypes::classSpecifier, specifierList, specifierStart, ! 0 ); specifierList->addChild(specifier); ! // move back to identifier end. ! backtrackSkippingSpaces(); ! ! // create specifier identifier property: ! ASTNodePtr ident ! = createASTNode( ASTNodeTypes::localScopeIdentifier, ! specifier, ! secondIdentStart, ! 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 ); ! } // set real length after completed parsing *************** *** 642,651 **** { if ( isClassTypeSpecifier( keyword ) ) ! { ! ASTNodePtr body = readClassSpecifierBodySkippingInheritance( specifier ); findNextBalanced('{','}'); ! body->setEndIndex( getCurrentIndex() ); // do not count the last '}' } else --- 664,673 ---- { if ( isClassTypeSpecifier( keyword ) ) ! { ! ASTNodePtr body = readClassSpecifierBodySkippingInheritance( specifier ); findNextBalanced('{','}'); ! body->setEndIndex( getCurrentIndex()-1 ); // do not count the last '}' } else *************** *** 659,664 **** DeclarationDetailsParser::readClassSpecifierBodySkippingInheritance( const ASTNodePtr &specifier ) { ! readUntilNextOf("{"); ! current_++; ASTNodePtr body = createASTNode( ASTNodeTypes::unparsedDeclarationList, --- 681,694 ---- DeclarationDetailsParser::readClassSpecifierBodySkippingInheritance( const ASTNodePtr &specifier ) { ! skipSpaces(); ! ! // check if inheritance information does follow... ! if (!tryNextIs('{')) ! { ! // TODO: create node for inheritance-information ! // and add property to specifier-node ! readUntilNextOf("{"); ! current_++; ! } ASTNodePtr body = createASTNode( ASTNodeTypes::unparsedDeclarationList, *************** *** 812,816 **** if ( tryNextIs( '~' ) ) ! { // handle destructor (buggy, need to ensure not followed by const or volatile) skipSpaces(); } --- 842,846 ---- if ( tryNextIs( '~' ) ) ! { // handle destructor (buggy, need to ensure not followed by volatile) skipSpaces(); } |
From: <net...@us...> - 2003-09-06 21:42:01
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv32289 Modified Files: DeclarationDetailsParserTest.cpp Log Message: -- commented Index: DeclarationDetailsParserTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/DeclarationDetailsParserTest.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DeclarationDetailsParserTest.cpp 16 May 2003 10:00:43 -0000 1.4 --- DeclarationDetailsParserTest.cpp 6 Sep 2003 21:41:58 -0000 1.5 *************** *** 117,120 **** --- 117,123 ---- } + /** + * all tests are executed as a "source code" placed within a compound statement. + */ void DeclarationDetailsParserTest::testParserFail() *************** *** 127,133 **** /* from the c++ 'bible' */ ASSERT_DETAILS_PARSER_FAIL( DeclarationDetailsParser, "T(a)->m;" ); ! ASSERT_DETAILS_PARSER_FAIL( DeclarationDetailsParser, "T(a)++;" ); } void DeclarationDetailsParserTest::testParserPass() --- 130,139 ---- /* from the c++ 'bible' */ ASSERT_DETAILS_PARSER_FAIL( DeclarationDetailsParser, "T(a)->m;" ); ! ASSERT_DETAILS_PARSER_FAIL( DeclarationDetailsParser, "T(a)++;" ); } + /** + * all tests are executed as a "source code" placed within a compound statement. + */ void DeclarationDetailsParserTest::testParserPass() *************** *** 141,149 **** ASSERT_DETAILS_PARSER_PASS( DeclarationDetailsParser, "T(a)=4;" ); ASSERT_DETAILS_PARSER_PASS( DeclarationDetailsParser, "T(*b)();" ); ! ASSERT_DETAILS_PARSER_PASS( DeclarationDetailsParser, "T(x),y,z=7;" ); /* ! all of these could be statements, but the standard says, if a ! 'declaration' fits, interprete it as declaration */ } --- 147,155 ---- ASSERT_DETAILS_PARSER_PASS( DeclarationDetailsParser, "T(a)=4;" ); ASSERT_DETAILS_PARSER_PASS( DeclarationDetailsParser, "T(*b)();" ); ! ASSERT_DETAILS_PARSER_PASS( DeclarationDetailsParser, "T(x),y,z=7;" ); /* ! all of these could be statements, but the standard says, if the syntax of a ! declaration fits, interprete it as a declaration */ } |
From: <net...@us...> - 2003-09-06 21:41:15
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv32164 Modified Files: DeclarationParserTest.cpp Log Message: -- corrections in body length (was tested wrong) Index: DeclarationParserTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/DeclarationParserTest.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** DeclarationParserTest.cpp 4 May 2003 06:56:47 -0000 1.8 --- DeclarationParserTest.cpp 6 Sep 2003 21:41:12 -0000 1.9 *************** *** 58,63 **** ASTNodeProperties::namespaceBodyProperty, ASTNodeTypes::unparsedDeclarationList, ! 14, ! 3); } --- 58,63 ---- ASTNodeProperties::namespaceBodyProperty, ASTNodeTypes::unparsedDeclarationList, ! 15, ! 1); } *************** *** 134,139 **** ASTNodeProperties::namespaceBodyProperty, ASTNodeTypes::unparsedDeclarationList, ! 12, ! 3); } --- 134,139 ---- ASTNodeProperties::namespaceBodyProperty, ASTNodeTypes::unparsedDeclarationList, ! 13, ! 1); } |
From: <net...@us...> - 2003-09-06 21:40:11
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv31999 Modified Files: MaxLODMutator.cpp Log Message: -- added new mutators Index: MaxLODMutator.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/MaxLODMutator.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** MaxLODMutator.cpp 29 Apr 2003 09:47:59 -0000 1.11 --- MaxLODMutator.cpp 6 Sep 2003 21:40:07 -0000 1.12 *************** *** 11,14 **** --- 11,15 ---- #include "UnparsedDeclarationListMutator.h" #include "UnparsedDeclarationMutator.h" + #include "UnparsedDeclaratorMutator.h" #include <rfta/parser/ASTNodes.h> #include <rfta/parser/MaxLODMutator.h> *************** *** 79,83 **** *new UnparsedDeclarationListMutator() ); add( ASTNodeTypes::unparsedDeclaration, ! *new UnparsedDeclarationMutator() ); } --- 80,86 ---- *new UnparsedDeclarationListMutator() ); add( ASTNodeTypes::unparsedDeclaration, ! *new UnparsedDeclarationMutator() ); ! add( ASTNodeTypes::unparsedDeclarator, ! *new UnparsedDeclaratorMutator() ); } |
From: <net...@us...> - 2003-09-06 21:39:53
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv31920 Modified Files: NamespaceParser.cpp Log Message: -- fixed namespace body node position/length (now inside) Index: NamespaceParser.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/NamespaceParser.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** NamespaceParser.cpp 30 Apr 2003 19:20:12 -0000 1.4 --- NamespaceParser.cpp 6 Sep 2003 21:39:49 -0000 1.5 *************** *** 103,109 **** { // this is a usual namespace definition: ! // "namespace x { }" ! int bodyStartIndex = getCurrentIndex(); expect('{'); findNextBalanced('{','}'); --- 103,109 ---- { // this is a usual namespace definition: ! // "namespace x { }" expect('{'); + int bodyStartIndex = getCurrentIndex(); findNextBalanced('{','}'); *************** *** 114,118 **** createASTNode( ASTNodeTypes::unparsedDeclarationList, namespaceNode, ! bodyStartIndex, getCurrentIndex() - bodyStartIndex ); context_.addNode(namespaceBody); --- 114,118 ---- createASTNode( ASTNodeTypes::unparsedDeclarationList, namespaceNode, ! bodyStartIndex, getCurrentIndex() - bodyStartIndex - 1 ); context_.addNode(namespaceBody); |
From: <net...@us...> - 2003-09-06 21:38:58
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv31808 Modified Files: rftaparser.dsp Log Message: -- additional files in project Index: rftaparser.dsp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/rftaparser.dsp,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** rftaparser.dsp 16 May 2003 08:30:33 -0000 1.56 --- rftaparser.dsp 6 Sep 2003 21:38:54 -0000 1.57 *************** *** 490,493 **** --- 490,501 ---- # Begin Source File + SOURCE=.\UnparsedDeclaratorMutator.cpp + # End Source File + # Begin Source File + + SOURCE=.\UnparsedDeclaratorMutator.h + # End Source File + # Begin Source File + SOURCE=.\VariableDeclMutator.cpp # End Source File *************** *** 1308,1311 **** --- 1316,1327 ---- !ENDIF + # End Source File + # Begin Source File + + SOURCE=.\UnparsedDeclaratorMutatorTest.cpp + # End Source File + # Begin Source File + + SOURCE=.\UnparsedDeclaratorMutatorTest.h # End Source File # Begin Source File |
From: <net...@us...> - 2003-09-06 21:38:36
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv31760 Modified Files: SourceRange.cpp Log Message: -- corrected overlap test Index: SourceRange.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/SourceRange.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SourceRange.cpp 10 May 2003 10:55:38 -0000 1.4 --- SourceRange.cpp 6 Sep 2003 21:38:30 -0000 1.5 *************** *** 94,102 **** SourceRange::overlap( const SourceRange &other ) const { ! if ( other.startIndex_ < startIndex_ && ! other.startIndex_ + other.length_ > startIndex_ ) return true; ! return startIndex_ + length_ > other.startIndex_; } --- 94,105 ---- SourceRange::overlap( const SourceRange &other ) const { ! // other starts is inside this range ! if ( other.startIndex_ >= startIndex_ && ! other.startIndex_ < startIndex_ + length_ ) return true; ! // other ends inside this range: ! return other.startIndex_ + other.length_ >= startIndex_ && ! other.startIndex_ + other.length_ < startIndex_ + length_; } |
From: <net...@us...> - 2003-09-06 21:37:56
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv31665 Modified Files: UnparsedDeclarationListMutator.cpp Log Message: -- fixed mutator for new start/end position Index: UnparsedDeclarationListMutator.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/UnparsedDeclarationListMutator.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** UnparsedDeclarationListMutator.cpp 29 Apr 2003 10:29:16 -0000 1.2 --- UnparsedDeclarationListMutator.cpp 6 Sep 2003 21:37:48 -0000 1.3 *************** *** 35,42 **** node->getStartIndex(); ! const char *end = start + node->getLength(); ! ! ++start; ! --end; ParseContext::ParentNodePusher pusher( node, context ); --- 35,39 ---- node->getStartIndex(); ! const char *end = start + node->getLength(); ParseContext::ParentNodePusher pusher( node, context ); |
From: <net...@us...> - 2003-09-06 21:37:09
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv31593 Modified Files: UnparsedDeclarationListMutatorTest.cpp Log Message: -- corrections in body length (was tested wrong) Index: UnparsedDeclarationListMutatorTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/UnparsedDeclarationListMutatorTest.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** UnparsedDeclarationListMutatorTest.cpp 3 May 2003 20:40:06 -0000 1.5 --- UnparsedDeclarationListMutatorTest.cpp 6 Sep 2003 21:37:06 -0000 1.6 *************** *** 65,70 **** RFTA_ASSERT_NODE_HAS( namespaceNode->getProperty(ASTNodeProperties::namespaceBodyProperty), ASTNodeTypes::unparsedDeclarationList, ! 12, ! 29 ); ASTNodePtr namespaceBody = namespaceNode->getProperty(ASTNodeProperties::namespaceBodyProperty); --- 65,70 ---- RFTA_ASSERT_NODE_HAS( namespaceNode->getProperty(ASTNodeProperties::namespaceBodyProperty), ASTNodeTypes::unparsedDeclarationList, ! 13, ! 27 ); ASTNodePtr namespaceBody = namespaceNode->getProperty(ASTNodeProperties::namespaceBodyProperty); *************** *** 78,83 **** ASTNodeProperties::namespaceBodyProperty, ASTNodeTypes::declarationList, ! 12, ! 29); RFTA_ASSERT_EQUAL( 2, namespaceNode->getProperty(ASTNodeProperties::namespaceBodyProperty)->getChildCount() ); --- 78,83 ---- ASTNodeProperties::namespaceBodyProperty, ASTNodeTypes::declarationList, ! 13, ! 27); RFTA_ASSERT_EQUAL( 2, namespaceNode->getProperty(ASTNodeProperties::namespaceBodyProperty)->getChildCount() ); *************** *** 99,104 **** source << "protected: "; source << "signals: "; - source << "}"; source.setKeyEnd("CLASS-BODY"); source << ";"; --- 99,104 ---- source << "protected: "; source << "signals: "; source.setKeyEnd("CLASS-BODY"); + source << "}"; source << ";"; |
From: <net...@us...> - 2003-09-06 21:36:03
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv31393 Modified Files: UnparsedDeclarationMutatorTest.h UnparsedDeclarationMutatorTest.cpp Log Message: -- added test for constructor mutation -- modifications of declaration elements fixed Index: UnparsedDeclarationMutatorTest.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/UnparsedDeclarationMutatorTest.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** UnparsedDeclarationMutatorTest.h 16 May 2003 09:59:57 -0000 1.9 --- UnparsedDeclarationMutatorTest.h 6 Sep 2003 21:35:59 -0000 1.10 *************** *** 102,105 **** --- 102,106 ---- void testOperatorMember(); void testEmptyParameterList(); + void testConstructor(); private: Index: UnparsedDeclarationMutatorTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/UnparsedDeclarationMutatorTest.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** UnparsedDeclarationMutatorTest.cpp 16 May 2003 09:59:57 -0000 1.14 --- UnparsedDeclarationMutatorTest.cpp 6 Sep 2003 21:35:59 -0000 1.15 *************** *** 212,217 **** Testing::KeyedString source; source.addKeyed(SPECIFIER,"const") << " "; ! source.setKeyStart(SPECIFIER) << "class x {"; ! source.addKeyed("CLASS-BODY" , " public: int x() { } }" ); source.setKeyEnd(SPECIFIER) << " "; source.addKeyed(DECLARATOR, "y" ) << ";"; --- 212,218 ---- Testing::KeyedString source; source.addKeyed(SPECIFIER,"const") << " "; ! source.setKeyStart(SPECIFIER) << "class "; ! source.addKeyed("CLASS-NAME","x") << " {"; ! source.addKeyed("CLASS-BODY" , " public: int x() { } " ) << "}"; source.setKeyEnd(SPECIFIER) << " "; source.addKeyed(DECLARATOR, "y" ) << ";"; *************** *** 228,232 **** RFTA_ASSERT_NODE_TYPE( specifier, ASTNodeTypes::classSpecifier, "class-specifier" ); ! // CHECK CLASS BODY PROPERTY !! RFTA_ASSERT_NODE_PROPERTY_HAS( specifier, ASTNodeProperties::classBodyProperty, --- 229,241 ---- RFTA_ASSERT_NODE_TYPE( specifier, ASTNodeTypes::classSpecifier, "class-specifier" ); ! // CHECK CLASS NAME PROPERTY: ! RFTA_ASSERT_NODE_PROPERTY_HAS( specifier, ! ASTNodeProperties::classNameProperty, ! ASTNodeTypes::localScopeIdentifier, ! source.getKeyedIndex("CLASS-NAME",0), ! source.getKeyedLen("CLASS-NAME",0) ! ); ! ! // CHECK CLASS BODY PROPERTY: RFTA_ASSERT_NODE_PROPERTY_HAS( specifier, ASTNodeProperties::classBodyProperty, *************** *** 244,248 **** { Testing::KeyedString source; ! source.addKeyed(SPECIFIER , "class x: public std::c1, protected user::c3 { public: int x() { } }" ) << ";"; SourceASTNodePtr sourceAST = RFTA_ASSERT_DECLARATION_MUTATOR_PASS( source ); --- 253,262 ---- { Testing::KeyedString source; ! source.setKeyStart(SPECIFIER) << "class "; ! ! source.addKeyed("CLASS-NAME", "x") << " : "; ! source.addKeyed("CLASS-INHERITANCE","public std::c1, protected user::c3") << " {"; ! source.addKeyed("CLASS-BODY","public: int x() { } " ) << "}"; ! source.setKeyEnd(SPECIFIER) << ";"; SourceASTNodePtr sourceAST = RFTA_ASSERT_DECLARATION_MUTATOR_PASS( source ); *************** *** 254,258 **** // check specifier types: ASTNodePtr specifierList = node->getProperty( ASTNodeProperties::declarationSpecifiersProperty ); ! RFTA_ASSERT_NODE_TYPE( specifierList->getChildAt(0), ASTNodeTypes::classSpecifier, "class-specifier" ); } --- 268,300 ---- // check specifier types: ASTNodePtr specifierList = node->getProperty( ASTNodeProperties::declarationSpecifiersProperty ); ! ASTNodePtr specifier = specifierList->getChildAt(0); ! RFTA_ASSERT_NODE_TYPE( specifier, ASTNodeTypes::classSpecifier, "class-specifier" ); ! ! // CHECK CLASS NAME PROPERTY: ! RFTA_ASSERT_NODE_PROPERTY_HAS( specifier, ! ASTNodeProperties::classNameProperty, ! ASTNodeTypes::localScopeIdentifier, ! source.getKeyedIndex("CLASS-NAME",0), ! source.getKeyedLen("CLASS-NAME",0) ! ); ! ! // CHECK CLASS INHERITANCE PROPERTY: ! /* ! RFTA_ASSERT_NODE_PROPERTY_HAS( specifier, ! ASTNodeProperties::classInheritanceProperty, ! ASTNodeTypes::classInheritanceList, ! source.getKeyedIndex("CLASS-INHERITANCE",0), ! source.getKeyedLen("CLASS-INHERITANCE",0) ! ); ! // subnodes are inheritance elements: "public x", "y", "protected z" etc. ! */ ! ! // CHECK CLASS BODY PROPERTY: ! RFTA_ASSERT_NODE_PROPERTY_HAS( specifier, ! ASTNodeProperties::classBodyProperty, ! ASTNodeTypes::unparsedDeclarationList, ! source.getKeyedIndex("CLASS-BODY",0), ! source.getKeyedLen("CLASS-BODY",0) ! ); } *************** *** 872,875 **** --- 914,935 ---- source.getKeyedLen("PURESPECIFIER",0) ); + } + + void + UnparsedDeclarationMutatorTest::testConstructor() + { + Testing::KeyedString source; + source.addKeyed("DECLARATOR","T()" ) << ";" ; + + source << ";"; + + SourceASTNodePtr sourceAST = RFTA_ASSERT_DECLARATION_MUTATOR_PASS( source ); + ASTNodePtr node = sourceAST->getChildAt(0); + + // check AST: + RFTA_ASSERT_DECLARATION( source, sourceAST ); + + // check declarator types: + RFTA_ASSERT_NODE_TYPE( node->getChildAt(0), ASTNodeTypes::unparsedDeclarator, "declarator"); } |
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv31122 Added Files: UnparsedDeclaratorMutatorTest.h UnparsedDeclaratorMutatorTest.cpp UnparsedDeclaratorMutator.h UnparsedDeclaratorMutator.cpp Log Message: -- declarator mutator, only search for identifier at the moment... --- NEW FILE: UnparsedDeclaratorMutatorTest.h --- // ////////////////////////////////////////////////////////////////////////// // Header file UnparsedDeclaratorMutatorTest.h for class UnparsedDeclaratorMutatorTest // (c)Copyright 2003, Andre Baresel. // Created: 2003/08/27 // ////////////////////////////////////////////////////////////////////////// #ifndef RFTA_UnparsedDeclaratorMutatorTest_H #define RFTA_UnparsedDeclaratorMutatorTest_H #include "ParserTesting.h" namespace Refactoring { /// Unit tests for UnparsedDeclaratorMutatorTest class UnparsedDeclaratorMutatorTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE( UnparsedDeclaratorMutatorTest ); CPPUNIT_TEST( testSimpleDeclarator ); CPPUNIT_TEST( testBracedDeclarator ); CPPUNIT_TEST( testRootScopeDeclarator ); CPPUNIT_TEST( testScopedDeclarator ); CPPUNIT_TEST_SUITE_END(); public: /*! Constructs a UnparsedDeclaratorMutatorTest object. */ UnparsedDeclaratorMutatorTest(); /// Destructor. virtual ~UnparsedDeclaratorMutatorTest(); void setUp(); void tearDown(); void testSimpleDeclarator(); void testBracedDeclarator(); void testRootScopeDeclarator(); void testScopedDeclarator(); private: /// Prevents the use of the copy constructor. UnparsedDeclaratorMutatorTest( const UnparsedDeclaratorMutatorTest &other ); /// Prevents the use of the copy operator. void operator =( const UnparsedDeclaratorMutatorTest &other ); private: }; // Inlines methods for UnparsedDeclaratorMutatorTest: // ------------------------------------------------ } // namespace Refactoring #endif // RFTA_UnparsedDeclaratorMutatorTest_H --- NEW FILE: UnparsedDeclaratorMutatorTest.cpp --- // ////////////////////////////////////////////////////////////////////////// // Implementation file UnparsedDeclaratorMutatorTest.cpp for class UnparsedDeclaratorMutatorTest // (c)Copyright 2003, Andre Baresel. // Created: 2003/04/18 // ////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "UnparsedDeclaratorMutator.h" #include "UnparsedDeclaratorMutatorTest.h" #include "KeyedString.h" #include <rfta/parser/ASTNode.h> #include <rfta/parser/ASTNodes.h> #include <rfta/parser/ParseContext.h> #include <rfta/parser/SourceASTNode.h> #include <boost/format.hpp> namespace Refactoring { RFTAPARSER_TEST_SUITE_REGISTRATION( UnparsedDeclaratorMutatorTest ); const std::string SPECIFIER = "SPECIFIER"; const std::string DECLARATOR = "DECLARATOR"; const std::string SPECIFIERLIST = "SPECIFIERLIST"; namespace Testing { static SourceASTNodePtr checkDeclaratorMutatorPass( const std::string &source, const CppUnit::SourceLine &sourceLine ) { SourceASTNodePtr sourceNode = SourceASTNode::create( source, source ); ParseContext context( sourceNode ); ASTNodePtr decl = ASTNode::create( ASTNodeTypes::unparsedDeclarator, sourceNode, 0, source.length(), sourceNode ); context.addNode( decl ); // do variable declarator parsing UnparsedDeclaratorMutator mutator; mutator.mutate(decl,sourceNode); return sourceNode; } } // namespace Testing #define RFTA_ASSERT_DECLARATOR_MUTATOR_PASS( source ) \ Refactoring::Testing::checkDeclaratorMutatorPass( source, CPPUNIT_SOURCELINE() ) UnparsedDeclaratorMutatorTest::UnparsedDeclaratorMutatorTest() : CppUnit::TestFixture() { } UnparsedDeclaratorMutatorTest::~UnparsedDeclaratorMutatorTest() { } void UnparsedDeclaratorMutatorTest::setUp() { } void UnparsedDeclaratorMutatorTest::tearDown() { } void UnparsedDeclaratorMutatorTest::testSimpleDeclarator() { Testing::KeyedString source; source.addKeyed("IDENT","x_0") << "[] = 0"; SourceASTNodePtr sourceAST = RFTA_ASSERT_DECLARATOR_MUTATOR_PASS( source ); ASTNodePtr node = sourceAST->getChildAt(0); RFTA_ASSERT_NODE_HAS( node, ASTNodeTypes::declarator, 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) ); } void UnparsedDeclaratorMutatorTest::testBracedDeclarator() { Testing::KeyedString source; source << "((*"; source.addKeyed("IDENT","x_0") << ") const = 0"; SourceASTNodePtr sourceAST = RFTA_ASSERT_DECLARATOR_MUTATOR_PASS( source ); ASTNodePtr node = sourceAST->getChildAt(0); RFTA_ASSERT_NODE_HAS( node, ASTNodeTypes::declarator, 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) ); } void UnparsedDeclaratorMutatorTest::testRootScopeDeclarator() { Testing::KeyedString source; source << "((*"; source.addKeyed("IDENT","::hello") << ") const = 0"; SourceASTNodePtr sourceAST = RFTA_ASSERT_DECLARATOR_MUTATOR_PASS( source ); ASTNodePtr node = sourceAST->getChildAt(0); RFTA_ASSERT_NODE_HAS( node, ASTNodeTypes::declarator, 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) ); } void UnparsedDeclaratorMutatorTest::testScopedDeclarator() { Testing::KeyedString source; source << "((*"; source.addKeyed("IDENT","hello::hello2::hello3") << ") const = 0"; SourceASTNodePtr sourceAST = RFTA_ASSERT_DECLARATOR_MUTATOR_PASS( source ); ASTNodePtr node = sourceAST->getChildAt(0); RFTA_ASSERT_NODE_HAS( node, ASTNodeTypes::declarator, 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) ); } } // namespace Refactoring --- NEW FILE: UnparsedDeclaratorMutator.h --- // ////////////////////////////////////////////////////////////////////////// // Header file UnparsedDeclaratorMutator.h for class UnparsedDeclaratorMutator // (c)Copyright 2003, Andre Baresel. // Created: 2003/08/27 // ////////////////////////////////////////////////////////////////////////// #ifndef RFTA_UnparsedDeclaratorMutator_H #define RFTA_UnparsedDeclaratorMutator_H #include <rfta/parser/Mutator.h> namespace Refactoring { /// Mutate an unparsed-declarator into a parsed declarator class UnparsedDeclaratorMutator : public Mutator , public boost::noncopyable { public: /*! Constructs a UnparsedDeclaratorMutator object. * * source range must not start with white spaces. */ UnparsedDeclaratorMutator(); /// Destructor. virtual ~UnparsedDeclaratorMutator(); void mutate( const ASTNodePtr &node, const SourceASTNodePtr &sourceNode) const; }; // Inlines methods for UnparsedDeclaratorMutator: // -------------------------------------------- } // namespace Refactoring #endif // RFTA_UnparsedDeclaratorMutator_H --- NEW FILE: UnparsedDeclaratorMutator.cpp --- // ////////////////////////////////////////////////////////////////////////// // Implementation file UnparsedDeclaratorMutator.cpp for class UnparsedDeclaratorMutator // (c)Copyright 2003, Andre Baresel. // Created: 2003/08/27 // ////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "UnparsedDeclaratorMutator.h" #include <rfta/parser/ASTNodes.h> #include <rfta/parser/ParseContext.h> #include <rfta/parser/ParserTools.h> namespace Refactoring { UnparsedDeclaratorMutator::UnparsedDeclaratorMutator() { } UnparsedDeclaratorMutator::~UnparsedDeclaratorMutator() { } void UnparsedDeclaratorMutator::mutate(const ASTNodePtr &node, const SourceASTNodePtr &sourceNode) const { const char *start = sourceNode->getBlankedSourceStart() + node->getStartIndex(); const char *end = start + node->getLength(); const char *current = start; ASTNodePtr identifierNode; bool identFound = false; while (current != end && !identFound) { 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); } } // namespace Refactoring |