mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
ITokenDuple support for seperating fully qualified names that use template-ids,
also modify IASTFactory.createField & createVariable to take ITokenDuple for name Better treatement for definitions of static members of template classes.
This commit is contained in:
parent
7d0581e51c
commit
2153d2d6ec
18 changed files with 396 additions and 166 deletions
|
@ -1,3 +1,7 @@
|
|||
2003-04-25 Andrew Niefer
|
||||
-added parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.testClassTemplateStaticMemberDefinition()
|
||||
-modified parser/org/eclipse/cdt/core/parser/tests/QuickParseASTTests.testPointersToMemberFunctions
|
||||
|
||||
2003-03-23 Andrew Niefer
|
||||
bug 55673 & fix recursive loop in template instantiation
|
||||
-parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.testInstantiatingDeferredInstances()
|
||||
|
|
|
@ -1834,4 +1834,20 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
|||
assertFalse( i.hasNext() );
|
||||
}
|
||||
|
||||
public void testClassTemplateStaticMemberDefinition() throws Exception {
|
||||
Writer writer = new StringWriter();
|
||||
writer.write( "template< class T > class A{ \n" );
|
||||
writer.write( " typedef T * PT; \n" );
|
||||
writer.write( " static T member; \n" );
|
||||
writer.write( "}; \n" );
|
||||
writer.write( "template< class T> A<T>::PT A<T>::member = null; \n" );
|
||||
|
||||
Iterator i = parse( writer.toString() ).getDeclarations();
|
||||
|
||||
IASTTemplateDeclaration template = (IASTTemplateDeclaration) i.next();
|
||||
IASTTemplateDeclaration template2 = (IASTTemplateDeclaration) i.next();
|
||||
|
||||
IASTField member = (IASTField) getDeclarations( template2 ).next();
|
||||
assertEquals( member.getName(), "member" );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1645,7 +1645,7 @@ public class QuickParseASTTests extends BaseASTTest
|
|||
{
|
||||
IASTVariable p2m = (IASTVariable)parse("void (A::*name)(void);").getDeclarations().next();
|
||||
assertSimpleType( p2m, IASTSimpleTypeSpecifier.Type.VOID );
|
||||
assertEquals( p2m.getName(), "A::name");
|
||||
assertEquals( p2m.getName(), "A::* name");
|
||||
assertEquals( p2m.getAbstractDeclaration().getPointerToFunctionOperator(), ASTPointerOperator.POINTER);
|
||||
Iterator parameters = p2m.getAbstractDeclaration().getParameters();
|
||||
IASTParameterDeclaration parm = (IASTParameterDeclaration)parameters.next();
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2004-03-25 Andrew Niefer
|
||||
-modify IASTFactory.createField & .createVariable to take ITokenDuple's for the name
|
||||
-modify ITokenDuple to support manipulating TokenDuples that have template arguments in them
|
||||
-fix NullPointer & ClassCast exceptions found while parsing <string>
|
||||
|
||||
2004-03-25 Hoda Amer
|
||||
Joined effort with Bogdan: Added a parserTimeout() method to ISourceElementRequestor
|
||||
and the ability for the parser to timeout.
|
||||
|
|
|
@ -32,6 +32,11 @@ public interface ITokenDuple {
|
|||
public abstract IToken getLastToken();
|
||||
|
||||
public List [] getTemplateIdArgLists();
|
||||
public IToken consumeTemplateIdArguments( IToken name, Iterator iter );
|
||||
|
||||
public ITokenDuple getLastSegment();
|
||||
public ITokenDuple getLeadingSegments();
|
||||
public int getSegmentCount();
|
||||
|
||||
public abstract Iterator iterator();
|
||||
public abstract String toString();
|
||||
|
|
|
@ -199,10 +199,10 @@ public interface IASTFactory
|
|||
boolean isVolatile,
|
||||
boolean isVirtual, boolean isExplicit, boolean isPureVirtual, ASTAccessVisibility visibility, List constructorChain, boolean isDefinition, boolean hasFunctionTryBlock, boolean hasVariableArguments) throws ASTSemanticException;
|
||||
|
||||
public IASTVariable createVariable(IASTScope scope, String name, boolean isAuto, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression,
|
||||
public IASTVariable createVariable(IASTScope scope, ITokenDuple name, boolean isAuto, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression,
|
||||
IASTAbstractDeclaration abstractDeclaration, boolean isMutable, boolean isExtern, boolean isRegister, boolean isStatic, int startingOffset, int startingLine, int nameOffset, int nameEndOffset, int nameLine, IASTExpression constructorExpression ) throws ASTSemanticException;
|
||||
|
||||
public IASTField createField( IASTScope scope, String name, boolean isAuto, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression, IASTAbstractDeclaration abstractDeclaration, boolean isMutable, boolean isExtern, boolean isRegister, boolean isStatic, int startingOffset, int startingLine, int nameOffset, int nameEndOffset, int nameLine, IASTExpression constructorExpression, ASTAccessVisibility visibility) throws ASTSemanticException;
|
||||
public IASTField createField( IASTScope scope, ITokenDuple name, boolean isAuto, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression, IASTAbstractDeclaration abstractDeclaration, boolean isMutable, boolean isExtern, boolean isRegister, boolean isStatic, int startingOffset, int startingLine, int nameOffset, int nameEndOffset, int nameLine, IASTExpression constructorExpression, ASTAccessVisibility visibility) throws ASTSemanticException;
|
||||
|
||||
public IASTDesignator createDesignator( IASTDesignator.DesignatorKind kind, IASTExpression constantExpression, IToken fieldIdentifier );
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
|
||||
import org.eclipse.cdt.internal.core.parser.token.TokenDuple;
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
|
@ -403,9 +404,11 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
|||
declarator.getArrayModifiers(),
|
||||
convertedParms,
|
||||
(ASTPointerOperator)i.next());
|
||||
String name = ( d.getPointerOperatorNameDuple() != null ) ? d.getPointerOperatorNameDuple().toString() + d.getName() : d.getName();
|
||||
|
||||
ITokenDuple name = ( d.getPointerOperatorNameDuple() != null ) ? new TokenDuple( d.getPointerOperatorNameDuple(), d.getNameDuple() ) : d.getNameDuple();
|
||||
|
||||
if( typedef )
|
||||
return astFactory.createTypedef(scope, name, abs,
|
||||
return astFactory.createTypedef(scope, name.toString(), abs,
|
||||
getStartingOffset(), getStartingLine(), d
|
||||
.getNameStartOffset(), d.getNameEndOffset(), d
|
||||
.getNameLine());
|
||||
|
@ -499,7 +502,7 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
|||
{
|
||||
return astFactory.createField(
|
||||
scope,
|
||||
nested ? declarator.getOwnedDeclarator().getName() : declarator.getName(),
|
||||
nested ? declarator.getOwnedDeclarator().getNameDuple() : declarator.getNameDuple(),
|
||||
auto,
|
||||
declarator.getInitializerClause(),
|
||||
declarator.getBitFieldExpression(),
|
||||
|
@ -551,7 +554,7 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
|||
{
|
||||
return astFactory.createVariable(
|
||||
scope,
|
||||
nested ? declarator.getOwnedDeclarator().getName() : declarator.getName(),
|
||||
nested ? declarator.getOwnedDeclarator().getNameDuple() : declarator.getNameDuple(),
|
||||
isAuto(),
|
||||
declarator.getInitializerClause(),
|
||||
declarator.getBitFieldExpression(),
|
||||
|
|
|
@ -267,15 +267,17 @@ public class ExpressionParser implements IExpressionParser {
|
|||
IToken last = null;
|
||||
IToken mark = mark();
|
||||
|
||||
if (LT(1) == IToken.tCOLONCOLON)
|
||||
List argumentList = new LinkedList();
|
||||
boolean hasTemplateId = false;
|
||||
|
||||
if (LT(1) == IToken.tCOLONCOLON){
|
||||
argumentList.add( null );
|
||||
last = consume( IToken.tCOLONCOLON );
|
||||
}
|
||||
|
||||
if (LT(1) == IToken.tCOMPL)
|
||||
consume();
|
||||
|
||||
List argumentList = new LinkedList();
|
||||
boolean hasTemplateId = false;
|
||||
|
||||
switch (LT(1))
|
||||
{
|
||||
case IToken.tIDENTIFIER :
|
||||
|
|
|
@ -48,7 +48,12 @@ public class ASTTemplateDeclaration extends ASTSymbol implements IASTTemplateDec
|
|||
{
|
||||
super( template );
|
||||
|
||||
IContainerSymbol container = ((ASTScope)scope).getContainerSymbol();
|
||||
IContainerSymbol container = null;
|
||||
if( scope instanceof ASTTemplateDeclaration )
|
||||
container = ((ASTTemplateDeclaration)scope).getContainerSymbol();
|
||||
else
|
||||
container = ((ASTScope)scope).getContainerSymbol();
|
||||
|
||||
if( container instanceof ITemplateFactory ){
|
||||
factory = (ITemplateFactory) container;
|
||||
} else {
|
||||
|
|
|
@ -18,7 +18,6 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Stack;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.eclipse.cdt.core.parser.Enum;
|
||||
import org.eclipse.cdt.core.parser.IFilenameProvider;
|
||||
|
@ -301,6 +300,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
if( ((IASTCodeScope) startingScope.getASTExtension().getPrimaryDeclaration()).getContainingFunction() instanceof IASTMethod )
|
||||
{
|
||||
IASTClassSpecifier classSpecifier = ((IASTMethod) ((IASTCodeScope) startingScope.getASTExtension().getPrimaryDeclaration()).getContainingFunction()).getOwnerClassSpecifier();
|
||||
if( classSpecifier != null )
|
||||
((ASTClassSpecifier)classSpecifier).addUnresolvedReference( new UnresolvedReferenceDuple( startingScope, name ));
|
||||
break;
|
||||
}
|
||||
|
@ -330,18 +330,23 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
int offset = t.getOffset();
|
||||
|
||||
if( templateArgLists != null && templateArgLists[ idx ] != null ){
|
||||
t = consumeTemplateIdArguments( t, iter );
|
||||
if( iter.hasNext() && t.getNext().getType() == IToken.tLT )
|
||||
t = name.consumeTemplateIdArguments( (IToken) iter.next(), iter );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if( result instanceof IDeferredTemplateInstance ){
|
||||
result = ((IDeferredTemplateInstance)result).getTemplate().getTemplatedSymbol();
|
||||
}
|
||||
|
||||
if( t == name.getLastToken() )
|
||||
if( templateArgLists != null )
|
||||
result = lookupElement((IContainerSymbol)result, image, type, parameters, getTemplateArgList( templateArgLists[idx] ), ( lookup == LookupType.FORDEFINITION ) ? lookup : LookupType.QUALIFIED );
|
||||
else
|
||||
result = lookupElement((IContainerSymbol)result, image, type, parameters, ( lookup == LookupType.FORDEFINITION ) ? lookup : LookupType.QUALIFIED );
|
||||
else
|
||||
if( templateArgLists != null )
|
||||
if( templateArgLists != null && templateArgLists[idx] != null )
|
||||
result = ((IContainerSymbol)result).lookupTemplateId( image, getTemplateArgList( templateArgLists[idx] ) );
|
||||
else
|
||||
result = ((IContainerSymbol)result).lookupNestedNameSpecifier( image );
|
||||
|
@ -650,29 +655,26 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
boolean isTemplateId = false;
|
||||
|
||||
if( name != null ){
|
||||
IToken lastToken = name.getLastToken();
|
||||
if( name.length() != 1 ) // qualified name
|
||||
IToken nameToken = null;
|
||||
if( name.getSegmentCount() != 1 ) // qualified name
|
||||
{
|
||||
int idx = name.findLastTokenType( IToken.tCOLONCOLON );
|
||||
if( idx != -1 ){
|
||||
ITokenDuple containerSymbolName =
|
||||
name.getSubrange( 0, idx - 1 ); // -1 for index, -2 for last hop of qualified name
|
||||
currentScopeSymbol = (IContainerSymbol)lookupQualifiedName( currentScopeSymbol,
|
||||
containerSymbolName, references, true);
|
||||
ITokenDuple containerSymbolName = name.getLeadingSegments();
|
||||
currentScopeSymbol = (IContainerSymbol)lookupQualifiedName( currentScopeSymbol, containerSymbolName, references, true);
|
||||
if( currentScopeSymbol == null )
|
||||
handleProblem( IProblem.SEMANTIC_NAME_NOT_FOUND, containerSymbolName.toString(), containerSymbolName.getFirstToken().getOffset(), containerSymbolName.getLastToken().getEndOffset(), containerSymbolName.getLastToken().getLineNumber() );
|
||||
}
|
||||
|
||||
nameToken = name.getLastSegment().getFirstToken();
|
||||
} else {
|
||||
nameToken = name.getFirstToken();
|
||||
}
|
||||
//template-id
|
||||
List [] array = name.getTemplateIdArgLists();
|
||||
if( array != null ){
|
||||
isTemplateId = true;
|
||||
templateIdArgList = array[ array.length - 1 ];
|
||||
lastToken = name.getToken( idx + 1);
|
||||
}
|
||||
|
||||
}
|
||||
newSymbolName = lastToken.getImage();
|
||||
newSymbolName = nameToken.getImage();
|
||||
}
|
||||
|
||||
ISymbol classSymbol = null;
|
||||
|
@ -1708,9 +1710,13 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
int offset = current.getOffset();
|
||||
|
||||
if( argLists != null && argLists[ idx ] != null ){
|
||||
current = consumeTemplateIdArguments( current, i );
|
||||
if( i.hasNext() && current.getNext().getType() == IToken.tLT )
|
||||
current = typeName.consumeTemplateIdArguments( (IToken) i.next(), i );
|
||||
}
|
||||
|
||||
if( typeSymbol instanceof IDeferredTemplateInstance ){
|
||||
typeSymbol = ((IDeferredTemplateInstance)typeSymbol).getTemplate().getTemplatedSymbol();
|
||||
}
|
||||
try
|
||||
{
|
||||
if( argLists != null && argLists[ idx ] != null )
|
||||
|
@ -1771,15 +1777,19 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
IContainerSymbol ownerScope = scopeToSymbol( scope );
|
||||
|
||||
// check if this is a method in a body file
|
||||
if(name.length() > 1){
|
||||
IContainerSymbol parentScope = (IContainerSymbol)
|
||||
lookupQualifiedName(
|
||||
ownerScope,
|
||||
name.getSubrange( 0, name.findLastTokenType( IToken.tCOLONCOLON ) - 1),
|
||||
if(name.getSegmentCount() > 1){
|
||||
ISymbol symbol = lookupQualifiedName( ownerScope,
|
||||
name.getLeadingSegments(),
|
||||
references,
|
||||
false,
|
||||
LookupType.FORPARENTSCOPE );
|
||||
|
||||
IContainerSymbol parentScope = null;
|
||||
|
||||
if( symbol instanceof IContainerSymbol )
|
||||
parentScope = (IContainerSymbol) symbol;
|
||||
else if( symbol instanceof IDeferredTemplateInstance )
|
||||
parentScope = ((IDeferredTemplateInstance) symbol).getTemplate().getTemplatedSymbol();
|
||||
|
||||
if((parentScope != null) &&
|
||||
( (parentScope.getType() == TypeInfo.t_class)
|
||||
|
@ -1787,9 +1797,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
|| (parentScope.getType() == TypeInfo.t_union))
|
||||
){
|
||||
IASTScope methodParentScope = (IASTScope)parentScope.getASTExtension().getPrimaryDeclaration();
|
||||
ITokenDuple newName = name.getSubrange(
|
||||
name.findLastTokenType( IToken.tCOLONCOLON) + 1,
|
||||
name.length() - 1 );
|
||||
ITokenDuple newName = name.getLastSegment();
|
||||
return createMethod(
|
||||
methodParentScope,
|
||||
newName,
|
||||
|
@ -1815,7 +1823,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
}
|
||||
}
|
||||
|
||||
IParameterizedSymbol symbol = pst.newParameterizedSymbol( name.getLastToken().getImage(), TypeInfo.t_function );
|
||||
IParameterizedSymbol symbol = pst.newParameterizedSymbol( name.getFirstToken().getImage(), TypeInfo.t_function );
|
||||
setFunctionTypeInfoBits(isInline, isFriend, isStatic, symbol);
|
||||
|
||||
symbol.setHasVariableArgs( hasVariableArguments );
|
||||
|
@ -1838,7 +1846,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
IParameterizedSymbol functionDeclaration = null;
|
||||
|
||||
functionDeclaration =
|
||||
(IParameterizedSymbol) lookupQualifiedName(ownerScope, name.getLastToken().getImage(), TypeInfo.t_function, functionParameters, 0, new ArrayList(), false, LookupType.FORDEFINITION );
|
||||
(IParameterizedSymbol) lookupQualifiedName(ownerScope, name.getFirstToken().getImage(), TypeInfo.t_function, functionParameters, 0, new ArrayList(), false, LookupType.FORDEFINITION );
|
||||
|
||||
if( functionDeclaration != null ){
|
||||
previouslyDeclared = true;
|
||||
|
@ -2273,7 +2281,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
*/
|
||||
public IASTVariable createVariable(
|
||||
IASTScope scope,
|
||||
String name,
|
||||
ITokenDuple name,
|
||||
boolean isAuto,
|
||||
IASTInitializerClause initializerClause,
|
||||
IASTExpression bitfieldExpression,
|
||||
|
@ -2288,58 +2296,36 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
List references = new ArrayList();
|
||||
IContainerSymbol ownerScope = scopeToSymbol( scope );
|
||||
|
||||
// check if this is a scoped field, not a variable
|
||||
StringTokenizer tokenizer = new StringTokenizer(name,DOUBLE_COLON);
|
||||
int tokencount = tokenizer.countTokens();
|
||||
if(tokencount > 1){
|
||||
List tokens = new ArrayList();
|
||||
String oneToken = ""; //$NON-NLS-1$
|
||||
// This is NOT a function. This is a method definition
|
||||
while (tokenizer.hasMoreTokens()){
|
||||
oneToken = tokenizer.nextToken();
|
||||
tokens.add(oneToken);
|
||||
}
|
||||
if(name.getSegmentCount() > 1)
|
||||
{
|
||||
ISymbol symbol = lookupQualifiedName( ownerScope,
|
||||
name.getLeadingSegments(),
|
||||
references,
|
||||
false,
|
||||
LookupType.FORPARENTSCOPE );
|
||||
IContainerSymbol parentScope = null;
|
||||
|
||||
String fieldName = oneToken;
|
||||
if( symbol instanceof IContainerSymbol )
|
||||
parentScope = (IContainerSymbol) symbol;
|
||||
else if( symbol instanceof IDeferredTemplateInstance )
|
||||
parentScope = ((IDeferredTemplateInstance) symbol).getTemplate().getTemplatedSymbol();
|
||||
|
||||
int numOfTokens = 1;
|
||||
int offset = nameOffset;
|
||||
IContainerSymbol parentScope = ownerScope;
|
||||
Iterator i = tokens.iterator();
|
||||
while (i.hasNext() && (numOfTokens++) < tokens.size()){
|
||||
String token = (String) i.next();
|
||||
|
||||
IContainerSymbol parentSymbol = null;
|
||||
try {
|
||||
parentSymbol = parentScope.lookupNestedNameSpecifier( token );
|
||||
if( parentSymbol != null )
|
||||
addReference( references, createReference( parentSymbol, name, offset ));
|
||||
} catch (ParserSymbolTableException e1) {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
if(parentSymbol == null)
|
||||
break;
|
||||
else {
|
||||
parentScope = parentSymbol;
|
||||
offset += token.length()+ DOUBLE_COLON.length();
|
||||
}
|
||||
}
|
||||
|
||||
if((parentScope != null) &&
|
||||
( (parentScope.getType() == TypeInfo.t_class)
|
||||
|| (parentScope.getType() == TypeInfo.t_struct)
|
||||
|| (parentScope.getType() == TypeInfo.t_union))
|
||||
){
|
||||
if( (parentScope != null) && ( (parentScope.getType() == TypeInfo.t_class) ||
|
||||
(parentScope.getType() == TypeInfo.t_struct)||
|
||||
(parentScope.getType() == TypeInfo.t_union) ) )
|
||||
{
|
||||
IASTScope fieldParentScope = (IASTScope)parentScope.getASTExtension().getPrimaryDeclaration();
|
||||
return createField(fieldParentScope, fieldName,isAuto, initializerClause, bitfieldExpression, abstractDeclaration, isMutable, isExtern,
|
||||
isRegister, isStatic, startingOffset, startingLine, offset, nameEndOffset, nameLine, constructorExpression, ASTAccessVisibility.PRIVATE, references);
|
||||
|
||||
ITokenDuple newName = name.getLastSegment();
|
||||
|
||||
return createField(fieldParentScope, newName,isAuto, initializerClause, bitfieldExpression, abstractDeclaration, isMutable, isExtern,
|
||||
isRegister, isStatic, startingOffset, startingLine, newName.getStartOffset(), nameEndOffset, nameLine, constructorExpression, ASTAccessVisibility.PRIVATE, references);
|
||||
}
|
||||
}
|
||||
|
||||
ISymbol newSymbol = cloneSimpleTypeSymbol(name, abstractDeclaration, references);
|
||||
ISymbol newSymbol = cloneSimpleTypeSymbol(name.getFirstToken().getImage(), abstractDeclaration, references);
|
||||
if( newSymbol == null )
|
||||
handleProblem( IProblem.SEMANTICS_RELATED, name );
|
||||
handleProblem( IProblem.SEMANTICS_RELATED, name.toString() );
|
||||
|
||||
setVariableTypeInfoBits(
|
||||
isAuto,
|
||||
|
@ -2354,7 +2340,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
newSymbol.setIsForwardDeclaration(isStatic);
|
||||
boolean previouslyDeclared = false;
|
||||
if(!isStatic){
|
||||
ISymbol variableDeclaration = lookupQualifiedName(ownerScope, name, new ArrayList(), false, LookupType.UNQUALIFIED);
|
||||
ISymbol variableDeclaration = lookupQualifiedName(ownerScope, name.toString(), new ArrayList(), false, LookupType.UNQUALIFIED);
|
||||
|
||||
if( variableDeclaration != null )
|
||||
{
|
||||
|
@ -2368,7 +2354,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
}
|
||||
catch (ParserSymbolTableException e)
|
||||
{
|
||||
handleProblem(e.createProblemID(), name );
|
||||
handleProblem(e.createProblemID(), name.getFirstToken().getImage() );
|
||||
}
|
||||
|
||||
ASTVariable variable = new ASTVariable( newSymbol, abstractDeclaration, initializerClause, bitfieldExpression, startingOffset, startingLine, nameOffset, nameEndOffset, nameLine, references, constructorExpression, previouslyDeclared );
|
||||
|
@ -2497,8 +2483,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
symbolToBeCloned = pst.newSymbol( name, TypeInfo.t_type );
|
||||
symbolToBeCloned.setTypeSymbol(((ASTEnumerationSpecifier)abstractDeclaration.getTypeSpecifier()).getSymbol());
|
||||
}
|
||||
if( symbolToBeCloned != null ){
|
||||
newSymbol = (ISymbol) symbolToBeCloned.clone();
|
||||
newSymbol.setName( name );
|
||||
}
|
||||
|
||||
return newSymbol;
|
||||
}
|
||||
|
@ -2507,7 +2495,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
*/
|
||||
public IASTField createField(
|
||||
IASTScope scope,
|
||||
String name,
|
||||
ITokenDuple name,
|
||||
boolean isAuto,
|
||||
IASTInitializerClause initializerClause,
|
||||
IASTExpression bitfieldExpression,
|
||||
|
@ -2526,7 +2514,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
|
||||
public IASTField createField(
|
||||
IASTScope scope,
|
||||
String name,
|
||||
ITokenDuple name,
|
||||
boolean isAuto,
|
||||
IASTInitializerClause initializerClause,
|
||||
IASTExpression bitfieldExpression,
|
||||
|
@ -2546,9 +2534,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
|
||||
if(references == null)
|
||||
references = new ArrayList();
|
||||
ISymbol newSymbol = cloneSimpleTypeSymbol(name, abstractDeclaration, references);
|
||||
ISymbol newSymbol = cloneSimpleTypeSymbol(name.toString(), abstractDeclaration, references);
|
||||
if( newSymbol == null )
|
||||
handleProblem( IProblem.SEMANTICS_RELATED, name );
|
||||
handleProblem( IProblem.SEMANTICS_RELATED, name.toString() );
|
||||
|
||||
|
||||
setVariableTypeInfoBits(
|
||||
|
@ -2565,7 +2553,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
boolean previouslyDeclared = false;
|
||||
if(!isStatic){
|
||||
List fieldReferences = new ArrayList();
|
||||
ISymbol fieldDeclaration = lookupQualifiedName(ownerScope, name, fieldReferences, false, LookupType.FORDEFINITION);
|
||||
ISymbol fieldDeclaration = lookupQualifiedName(ownerScope, name.toString(), fieldReferences, false, LookupType.FORDEFINITION);
|
||||
|
||||
if( fieldDeclaration != null )
|
||||
{
|
||||
|
@ -2583,7 +2571,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
}
|
||||
catch (ParserSymbolTableException e)
|
||||
{
|
||||
handleProblem(e.createProblemID(), name );
|
||||
handleProblem(e.createProblemID(), name.toString() );
|
||||
}
|
||||
|
||||
ASTField field = new ASTField( newSymbol, abstractDeclaration, initializerClause, bitfieldExpression, startingOffset, startingLine, nameOffset, nameEndOffset, nameLine, references, previouslyDeclared, constructorExpression, visibility );
|
||||
|
@ -2734,20 +2722,21 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
IContainerSymbol currentScopeSymbol = scopeToSymbol(scope);
|
||||
TypeInfo.eType pstType = classKindToTypeInfo(kind);
|
||||
List references = new ArrayList();
|
||||
IToken lastToken = name.getLastToken();
|
||||
|
||||
IToken nameToken = name.getFirstToken();
|
||||
|
||||
String newSymbolName = ""; //$NON-NLS-1$
|
||||
List templateIdArgList = null;
|
||||
boolean isTemplateId = false;
|
||||
|
||||
if( name.length() != 1 ) // qualified name
|
||||
if( name.getSegmentCount() != 1 ) // qualified name
|
||||
{
|
||||
int idx = name.findLastTokenType( IToken.tCOLONCOLON );
|
||||
if( idx != -1 ){
|
||||
ITokenDuple containerSymbolName = name.getSubrange( 0, idx - 1 );
|
||||
ITokenDuple containerSymbolName = name.getLeadingSegments();
|
||||
currentScopeSymbol = (IContainerSymbol)lookupQualifiedName( currentScopeSymbol, containerSymbolName, references, true);
|
||||
if( currentScopeSymbol == null )
|
||||
handleProblem( IProblem.SEMANTIC_NAME_NOT_FOUND, containerSymbolName.toString(), containerSymbolName.getFirstToken().getOffset(), containerSymbolName.getLastToken().getEndOffset(), containerSymbolName.getLastToken().getLineNumber() );
|
||||
|
||||
nameToken = name.getLastSegment().getFirstToken();
|
||||
}
|
||||
|
||||
//template-id
|
||||
|
@ -2755,11 +2744,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
if( array != null ){
|
||||
isTemplateId = true;
|
||||
templateIdArgList = array[ array.length - 1 ];
|
||||
lastToken = name.getToken( idx + 1);
|
||||
}
|
||||
}
|
||||
|
||||
newSymbolName = lastToken.getImage();
|
||||
newSymbolName = nameToken.getImage();
|
||||
|
||||
ISymbol checkSymbol = null;
|
||||
if( !isTemplateId ){
|
||||
|
@ -2773,7 +2760,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
}
|
||||
catch (ParserSymbolTableException e)
|
||||
{
|
||||
handleProblem(e.createProblemID(),lastToken.getImage(), lastToken.getOffset(), lastToken.getEndOffset(), lastToken.getLineNumber() );
|
||||
handleProblem(e.createProblemID(),nameToken.getImage(), nameToken.getOffset(), nameToken.getEndOffset(), nameToken.getLineNumber() );
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -2802,7 +2789,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
}
|
||||
catch (ParserSymbolTableException e1)
|
||||
{
|
||||
handleProblem(e1.createProblemID(),lastToken.getImage(), lastToken.getOffset(), lastToken.getEndOffset(), lastToken.getLineNumber() );
|
||||
handleProblem(e1.createProblemID(),nameToken.getImage(), nameToken.getOffset(), nameToken.getEndOffset(), nameToken.getLineNumber() );
|
||||
}
|
||||
|
||||
ASTElaboratedTypeSpecifier elab =
|
||||
|
@ -2827,7 +2814,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
if( checkSymbol.getASTExtension().getPrimaryDeclaration() instanceof IASTElaboratedTypeSpecifier )
|
||||
return (IASTElaboratedTypeSpecifier)checkSymbol.getASTExtension().getPrimaryDeclaration();
|
||||
} else {
|
||||
handleProblem(IProblem.SEMANTIC_NAME_NOT_FOUND, newSymbolName, lastToken.getOffset(), lastToken.getEndOffset(), lastToken.getLineNumber() );
|
||||
handleProblem(IProblem.SEMANTIC_NAME_NOT_FOUND, newSymbolName, nameToken.getOffset(), nameToken.getEndOffset(), nameToken.getLineNumber() );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -625,7 +625,7 @@ public class ExpressionParseASTFactory extends BaseASTFactory implements IASTFac
|
|||
*/
|
||||
public IASTVariable createVariable(
|
||||
IASTScope scope,
|
||||
String name,
|
||||
ITokenDuple name,
|
||||
boolean isAuto,
|
||||
IASTInitializerClause initializerClause,
|
||||
IASTExpression bitfieldExpression,
|
||||
|
@ -659,7 +659,7 @@ public class ExpressionParseASTFactory extends BaseASTFactory implements IASTFac
|
|||
*/
|
||||
public IASTField createField(
|
||||
IASTScope scope,
|
||||
String name,
|
||||
ITokenDuple name,
|
||||
boolean isAuto,
|
||||
IASTInitializerClause initializerClause,
|
||||
IASTExpression bitfieldExpression,
|
||||
|
|
|
@ -232,17 +232,17 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createVariable(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, boolean, org.eclipse.cdt.core.parser.ast.IASTInitializerClause, org.eclipse.cdt.core.parser.ast.IASTExpression, org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration, boolean, boolean, boolean, boolean)
|
||||
*/
|
||||
public IASTVariable createVariable(IASTScope scope, String name, boolean isAuto, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression, IASTAbstractDeclaration abstractDeclaration, boolean isMutable, boolean isExtern, boolean isRegister, boolean isStatic, int startingOffset, int startingLine, int nameOffset, int nameEndOffset, int nameLine, IASTExpression constructorExpression)
|
||||
public IASTVariable createVariable(IASTScope scope, ITokenDuple name, boolean isAuto, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression, IASTAbstractDeclaration abstractDeclaration, boolean isMutable, boolean isExtern, boolean isRegister, boolean isStatic, int startingOffset, int startingLine, int nameOffset, int nameEndOffset, int nameLine, IASTExpression constructorExpression)
|
||||
{
|
||||
return new ASTVariable(scope, name, isAuto, initializerClause, bitfieldExpression, abstractDeclaration, isMutable, isExtern, isRegister, isStatic, startingOffset, startingLine, nameOffset, nameEndOffset, nameLine, constructorExpression);
|
||||
return new ASTVariable(scope, ( name != null ? name.toString() : "" ), isAuto, initializerClause, bitfieldExpression, abstractDeclaration, isMutable, isExtern, isRegister, isStatic, startingOffset, startingLine, nameOffset, nameEndOffset, nameLine, constructorExpression); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createField(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, boolean, org.eclipse.cdt.core.parser.ast.IASTInitializerClause, org.eclipse.cdt.core.parser.ast.IASTExpression, org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration, boolean, boolean, boolean, boolean, org.eclipse.cdt.core.parser.ast.ASTAccessVisibility)
|
||||
*/
|
||||
public IASTField createField(IASTScope scope, String name, boolean isAuto, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression, IASTAbstractDeclaration abstractDeclaration, boolean isMutable, boolean isExtern, boolean isRegister, boolean isStatic, int startingOffset, int startingLine, int nameOffset, int nameEndOffset, int nameLine, IASTExpression constructorExpression, ASTAccessVisibility visibility)
|
||||
public IASTField createField(IASTScope scope, ITokenDuple name, boolean isAuto, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression, IASTAbstractDeclaration abstractDeclaration, boolean isMutable, boolean isExtern, boolean isRegister, boolean isStatic, int startingOffset, int startingLine, int nameOffset, int nameEndOffset, int nameLine, IASTExpression constructorExpression, ASTAccessVisibility visibility)
|
||||
{
|
||||
return new ASTField(scope, name, isAuto, initializerClause, bitfieldExpression, abstractDeclaration, isMutable, isExtern, isRegister, isStatic, startingOffset, startingLine, nameOffset, nameEndOffset, nameLine, constructorExpression, visibility);
|
||||
return new ASTField(scope, ( name != null ? name.toString() : "" ), isAuto, initializerClause, bitfieldExpression, abstractDeclaration, isMutable, isExtern, isRegister, isStatic, startingOffset, startingLine, nameOffset, nameEndOffset, nameLine, constructorExpression, visibility); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -201,7 +201,10 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
throw new ParserSymbolTableError( ParserSymbolTableError.r_InternalError );
|
||||
}
|
||||
|
||||
boolean validOverride = ((origList == null) ? ParserSymbolTable.isValidOverload( origDecl, obj ) : ParserSymbolTable.isValidOverload( origList, obj ) );
|
||||
boolean validOverride = ( !unnamed ? ( (origList == null) ? ParserSymbolTable.isValidOverload( origDecl, obj )
|
||||
: ParserSymbolTable.isValidOverload( origList, obj ) )
|
||||
: true );
|
||||
|
||||
if( unnamed || validOverride )
|
||||
{
|
||||
if( origList == null ){
|
||||
|
|
|
@ -770,7 +770,7 @@ public class ParserSymbolTable {
|
|||
|
||||
if( origType == TypeInfo.t_template ){
|
||||
ITemplateSymbol template = (ITemplateSymbol) origSymbol;
|
||||
origSymbol = (ISymbol) template.getContainedSymbols().get( template.getName() );
|
||||
origSymbol = (ISymbol) template.getTemplatedSymbol();
|
||||
if( origSymbol == null )
|
||||
return true;
|
||||
else
|
||||
|
@ -779,7 +779,7 @@ public class ParserSymbolTable {
|
|||
|
||||
if( newType == TypeInfo.t_template ){
|
||||
ITemplateSymbol template = (ITemplateSymbol) newSymbol;
|
||||
newSymbol = (ISymbol) template.getContainedSymbols().get( template.getName() );
|
||||
newSymbol = (ISymbol) template.getTemplatedSymbol();
|
||||
if( newSymbol == null )
|
||||
return true;
|
||||
else
|
||||
|
|
|
@ -309,7 +309,7 @@ public final class TemplateEngine {
|
|||
* @param aInfo
|
||||
* @return
|
||||
*/
|
||||
static private TypeInfo getArgumentTypeForDeduction( TypeInfo aInfo, boolean pIsAReferenceType ){
|
||||
static private TypeInfo getArgumentTypeForDeduction( TypeInfo aInfo, boolean pIsAReferenceType ) throws ParserSymbolTableException{
|
||||
|
||||
TypeInfo a = ParserSymbolTable.getFlatTypeInfo( aInfo );
|
||||
|
||||
|
@ -317,8 +317,10 @@ public final class TemplateEngine {
|
|||
List aPtrs = a.getPtrOperators();
|
||||
ISymbol aSymbol = a.getTypeSymbol();
|
||||
|
||||
if( a.getType() == TypeInfo.t_type && aSymbol.isType( TypeInfo.t_function ) ){
|
||||
if( aPtrs.size() == 0 ){
|
||||
if( a.getType() == TypeInfo.t_type ){
|
||||
if( aSymbol == null ){
|
||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplateArgument );
|
||||
} else if( aSymbol.isType( TypeInfo.t_function ) && aPtrs.size() == 0 ){
|
||||
aPtrs.add( new PtrOp( PtrOp.t_pointer ) );
|
||||
}
|
||||
}
|
||||
|
@ -420,7 +422,7 @@ public final class TemplateEngine {
|
|||
return aSymbol;
|
||||
}
|
||||
|
||||
static private boolean deduceTemplateArgument( Map map, ISymbol pSymbol, TypeInfo a ){//, Map argumentMap ){
|
||||
static private boolean deduceTemplateArgument( Map map, ISymbol pSymbol, TypeInfo a ) throws ParserSymbolTableException{//, Map argumentMap ){
|
||||
ISymbol symbol;
|
||||
|
||||
boolean pIsAReferenceType = false;
|
||||
|
@ -613,9 +615,13 @@ public final class TemplateEngine {
|
|||
|
||||
TypeInfo arg = transformTypeInfo( aIter.next(), null );
|
||||
|
||||
try {
|
||||
if( !deduceTemplateArgument( map, sym, arg ) ){
|
||||
return false;
|
||||
}
|
||||
} catch (ParserSymbolTableException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -677,9 +683,13 @@ public final class TemplateEngine {
|
|||
Iterator aIter = arguments.iterator();
|
||||
|
||||
while( pIter.hasNext() ){
|
||||
try {
|
||||
if( !deduceTemplateArgument( map, (ISymbol) pIter.next(), (TypeInfo) aIter.next() ) ){
|
||||
return null;
|
||||
}
|
||||
} catch (ParserSymbolTableException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
|
|
|
@ -96,7 +96,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
|||
}
|
||||
|
||||
public void addSymbol(ISymbol symbol) throws ParserSymbolTableException {
|
||||
lastSymbol = (IContainerSymbol) (( symbols.size() > 0 ) ? symbols.get( symbols.size() - 1) : null);
|
||||
lastSymbol = getLastSymbol();
|
||||
|
||||
Iterator iter = symbols.iterator();
|
||||
ListIterator tIter = templates.listIterator();
|
||||
|
@ -281,14 +281,27 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
|||
// }
|
||||
}
|
||||
|
||||
private IContainerSymbol getLastSymbol() {
|
||||
if( lastSymbol != null )
|
||||
return lastSymbol;
|
||||
else if( !symbols.isEmpty() ) {
|
||||
ISymbol symbol = (ISymbol) symbols.get( symbols.size() - 1 );
|
||||
if( symbol instanceof IDeferredTemplateInstance )
|
||||
return ((IDeferredTemplateInstance)symbol).getTemplate().getTemplatedSymbol();
|
||||
else if( symbol instanceof IContainerSymbol )
|
||||
return (IContainerSymbol) symbol;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ITemplateFactory#lookupMemberForDefinition(java.lang.String)
|
||||
*/
|
||||
public ISymbol lookupMemberForDefinition(String name) throws ParserSymbolTableException {
|
||||
ISymbol look = null;
|
||||
if( lastSymbol != null || !symbols.isEmpty() ){
|
||||
IContainerSymbol symbol = (lastSymbol != null ) ? lastSymbol : (IContainerSymbol) symbols.get( symbols.size() - 1 );
|
||||
look = ((IContainerSymbol)symbol).lookupMemberForDefinition( name );
|
||||
IContainerSymbol last = getLastSymbol();
|
||||
if( last != null ){
|
||||
look = last.lookupMemberForDefinition( name );
|
||||
} else {
|
||||
look = getContainingSymbol().lookupMemberForDefinition( name );
|
||||
}
|
||||
|
@ -401,9 +414,9 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
|||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#lookupMethodForDefinition(java.lang.String, java.util.List)
|
||||
*/
|
||||
public IParameterizedSymbol lookupMethodForDefinition(String name, List parameters) throws ParserSymbolTableException {
|
||||
if( lastSymbol != null || !symbols.isEmpty() ){
|
||||
IContainerSymbol symbol = (lastSymbol != null ) ? lastSymbol : (IContainerSymbol) symbols.get( symbols.size() - 1 );
|
||||
IParameterizedSymbol found = ((IContainerSymbol)symbol).lookupMethodForDefinition( name, parameters );
|
||||
IContainerSymbol last = getLastSymbol();
|
||||
if( last != null ){
|
||||
IParameterizedSymbol found = last.lookupMethodForDefinition( name, parameters );
|
||||
if( found != null ){
|
||||
return found;
|
||||
}
|
||||
|
@ -458,9 +471,9 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
|||
*/
|
||||
public ISymbol lookupTemplateId(String name, List arguments) throws ParserSymbolTableException {
|
||||
ISymbol look = null;
|
||||
if( lastSymbol != null || !symbols.isEmpty() ){
|
||||
IContainerSymbol symbol = (lastSymbol != null ) ? lastSymbol : (IContainerSymbol) symbols.get( symbols.size() - 1 );
|
||||
look = ((IContainerSymbol)symbol).lookupTemplateId( name, arguments );
|
||||
IContainerSymbol last = getLastSymbol();
|
||||
if( last != null ){
|
||||
look = last.lookupTemplateId( name, arguments );
|
||||
} else {
|
||||
look = getContainingSymbol().lookupTemplateId( name, arguments );
|
||||
}
|
||||
|
@ -469,9 +482,9 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
|||
|
||||
public IContainerSymbol lookupTemplateIdForDefinition(String name, List arguments) throws ParserSymbolTableException {
|
||||
ISymbol look = null;
|
||||
if( lastSymbol != null || !symbols.isEmpty() ){
|
||||
IContainerSymbol symbol = (lastSymbol != null ) ? lastSymbol : (IContainerSymbol) symbols.get( symbols.size() - 1 );
|
||||
look = ((IContainerSymbol)symbol).lookupMemberForDefinition( name );
|
||||
IContainerSymbol last = getLastSymbol();
|
||||
if( last != null ){
|
||||
look = last.lookupMemberForDefinition( name );
|
||||
} else {
|
||||
look = getContainingSymbol().lookupMemberForDefinition( name );
|
||||
}
|
||||
|
@ -772,15 +785,17 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
|||
* @see org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol#lookupConstructor(java.util.List)
|
||||
*/
|
||||
public IParameterizedSymbol lookupConstructor(List parameters) throws ParserSymbolTableException {
|
||||
if( lastSymbol != null || !symbols.isEmpty() ){
|
||||
IContainerSymbol symbol = (lastSymbol != null ) ? lastSymbol : (IContainerSymbol) symbols.get( symbols.size() - 1 );
|
||||
if( symbol instanceof IDerivableContainerSymbol ){
|
||||
IParameterizedSymbol found = ((IDerivableContainerSymbol)symbol).lookupConstructor( parameters );
|
||||
IContainerSymbol last = getLastSymbol();
|
||||
if( last != null && last instanceof IDerivableContainerSymbol ){
|
||||
IDerivableContainerSymbol derivable = (IDerivableContainerSymbol) last;
|
||||
IParameterizedSymbol found = derivable.lookupConstructor( parameters );
|
||||
if( found != null )
|
||||
return found;
|
||||
}
|
||||
}
|
||||
if( getContainingSymbol() instanceof IDerivableContainerSymbol )
|
||||
return ((IDerivableContainerSymbol) getContainingSymbol()).lookupConstructor( parameters );
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -487,7 +487,10 @@ public class TypeInfo {
|
|||
IParameterizedSymbol f2 = (IParameterizedSymbol) type._typeDeclaration;
|
||||
|
||||
result &= f1.hasSameParameters( f2 );
|
||||
if( f1.getReturnType() != null && f2.getReturnType() != null )
|
||||
result &= f1.getReturnType().getTypeInfo().equals( f2.getReturnType().getTypeInfo() );
|
||||
else
|
||||
result &= (f1.getReturnType() == f2.getReturnType());
|
||||
} else if( _typeDeclaration.isType( TypeInfo.t_templateParameter ) &&
|
||||
type._typeDeclaration.isType( TypeInfo.t_templateParameter ) ){
|
||||
//template parameters
|
||||
|
|
|
@ -10,7 +10,9 @@
|
|||
***********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.token;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
|
@ -45,8 +47,31 @@ public class TokenDuple implements ITokenDuple {
|
|||
}
|
||||
}
|
||||
|
||||
public TokenDuple( ITokenDuple firstDuple, ITokenDuple secondDuple ){
|
||||
firstToken = firstDuple.getFirstToken();
|
||||
lastToken = secondDuple.getLastToken();
|
||||
|
||||
List [] a1 = firstDuple.getTemplateIdArgLists();
|
||||
List [] a2 = secondDuple.getTemplateIdArgLists();
|
||||
|
||||
if( a1 == null && a2 == null ){
|
||||
argLists = null;
|
||||
} else {
|
||||
int l1 = ( a1 != null ) ? a1.length : firstDuple.getSegmentCount();
|
||||
int l2 = ( a2 != null ) ? a2.length : firstDuple.getSegmentCount();
|
||||
|
||||
argLists = new List[ l1 + l2 ];
|
||||
if( a1 != null )
|
||||
System.arraycopy( a1, 0, argLists, 0, l1 );
|
||||
if( a2 != null )
|
||||
System.arraycopy( a2, 0, argLists, l1, l2 );
|
||||
}
|
||||
}
|
||||
|
||||
protected final IToken firstToken, lastToken;
|
||||
protected final List [] argLists;
|
||||
private int numSegments = -1;
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
|
@ -66,6 +91,153 @@ public class TokenDuple implements ITokenDuple {
|
|||
return new TokenIterator();
|
||||
}
|
||||
|
||||
public ITokenDuple getLastSegment() {
|
||||
Iterator iter = iterator();
|
||||
if( !iter.hasNext() )
|
||||
return null;
|
||||
|
||||
IToken first = null, last = null, token = null;
|
||||
while( iter.hasNext() ){
|
||||
token = (IToken) iter.next();
|
||||
if( first == null )
|
||||
first = token;
|
||||
if( token.getType() == IToken.tLT )
|
||||
token = consumeTemplateIdArguments( token, iter );
|
||||
else if( token.getType() == IToken.tCOLONCOLON ){
|
||||
first = null;
|
||||
continue;
|
||||
}
|
||||
last = token;
|
||||
}
|
||||
|
||||
List [] args = getTemplateIdArgLists();
|
||||
if( args != null && args[ args.length - 1 ] != null ){
|
||||
List newArgs = new ArrayList( 1 );
|
||||
newArgs.add( args[ args.length - 1 ] );
|
||||
return new TokenDuple( first, last, newArgs );
|
||||
} else {
|
||||
return new TokenDuple( first, last );
|
||||
}
|
||||
}
|
||||
|
||||
public ITokenDuple getLeadingSegments(){
|
||||
Iterator iter = iterator();
|
||||
if( !iter.hasNext() )
|
||||
return null;
|
||||
|
||||
int num = getSegmentCount();
|
||||
|
||||
if( num <= 1 )
|
||||
return null;
|
||||
|
||||
IToken first = null, last = null;
|
||||
IToken previous = null, token = null;
|
||||
|
||||
while( iter.hasNext() ){
|
||||
token = (IToken) iter.next();
|
||||
if( first == null )
|
||||
first = token;
|
||||
if( token.getType() == IToken.tLT )
|
||||
token = consumeTemplateIdArguments( token, iter );
|
||||
else if( token.getType() == IToken.tCOLONCOLON ){
|
||||
last = previous;
|
||||
continue;
|
||||
}
|
||||
|
||||
previous = token;
|
||||
}
|
||||
|
||||
if( last == null ){
|
||||
//"::A"
|
||||
return null;
|
||||
}
|
||||
|
||||
if( getTemplateIdArgLists() != null ){
|
||||
List[] args = getTemplateIdArgLists();
|
||||
List newArgs = new ArrayList( args.length - 1 );
|
||||
boolean foundArgs = false;
|
||||
for( int i = 0; i < args.length - 1; i++ ){
|
||||
newArgs.add( args[i] );
|
||||
if( args[i] != null )
|
||||
foundArgs = true;
|
||||
}
|
||||
return new TokenDuple( first, last, ( foundArgs ? newArgs : null ) );
|
||||
} else {
|
||||
return new TokenDuple( first, last );
|
||||
}
|
||||
}
|
||||
|
||||
public int getSegmentCount()
|
||||
{
|
||||
if( numSegments > -1 )
|
||||
return numSegments;
|
||||
|
||||
numSegments = 1;
|
||||
|
||||
if( firstToken == lastToken )
|
||||
return numSegments;
|
||||
|
||||
Iterator iter = iterator();
|
||||
|
||||
IToken token = null;
|
||||
while( iter.hasNext() ){
|
||||
token = (IToken) iter.next();
|
||||
if( token.getType() == IToken.tLT )
|
||||
token = consumeTemplateIdArguments( token, iter );
|
||||
if( token.getType() == IToken.tCOLONCOLON ){
|
||||
numSegments++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return numSegments;
|
||||
}
|
||||
|
||||
private static final Integer LT = new Integer( IToken.tLT );
|
||||
private static final Integer LBRACKET = new Integer( IToken.tLBRACKET );
|
||||
private static final Integer LPAREN = new Integer( IToken.tLPAREN );
|
||||
|
||||
public IToken consumeTemplateIdArguments( IToken name, Iterator iter ){
|
||||
IToken token = name;
|
||||
|
||||
if( token.getType() == IToken.tLT )
|
||||
{
|
||||
if( ! iter.hasNext() )
|
||||
return token;
|
||||
|
||||
token = (IToken) iter.next();
|
||||
LinkedList scopes = new LinkedList();
|
||||
scopes.add( LT );
|
||||
|
||||
while (!scopes.isEmpty() && iter.hasNext() )
|
||||
{
|
||||
Integer top;
|
||||
|
||||
token = (IToken) iter.next();
|
||||
switch( token.getType() ){
|
||||
case IToken.tGT:
|
||||
if( scopes.getLast() == LT ) {
|
||||
scopes.removeLast();
|
||||
}
|
||||
break;
|
||||
case IToken.tRBRACKET :
|
||||
do {
|
||||
top = (Integer)scopes.removeLast();
|
||||
} while (!scopes.isEmpty() && top == LT);
|
||||
break;
|
||||
case IToken.tRPAREN :
|
||||
do {
|
||||
top = (Integer)scopes.removeLast();
|
||||
} while (!scopes.isEmpty() && top == LT);
|
||||
break;
|
||||
case IToken.tLT: scopes.add( LT ); break;
|
||||
case IToken.tLBRACKET: scopes.add( LBRACKET ); break;
|
||||
case IToken.tLPAREN: scopes.add( LPAREN ); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
private class TokenIterator implements Iterator
|
||||
{
|
||||
private IToken iter = TokenDuple.this.firstToken;
|
||||
|
|
Loading…
Add table
Reference in a new issue