mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-10 01:35:39 +02:00
Reduced the number of TokenDuple's instantiated during a parse. <BR>
Removed symbol table warnings.
This commit is contained in:
parent
f64e265d26
commit
22c73dc031
20 changed files with 500 additions and 376 deletions
|
@ -29,7 +29,6 @@ import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
|
import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
|
||||||
import org.eclipse.cdt.core.parser.extension.IParserExtension;
|
import org.eclipse.cdt.core.parser.extension.IParserExtension;
|
||||||
import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
|
import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
|
||||||
import org.eclipse.cdt.internal.core.parser.token.TokenDuple;
|
|
||||||
import org.eclipse.cdt.internal.core.parser.token.TokenFactory;
|
import org.eclipse.cdt.internal.core.parser.token.TokenFactory;
|
||||||
import org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key;
|
import org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key;
|
||||||
|
|
||||||
|
@ -155,7 +154,7 @@ public class ContextualParser extends CompleteParser {
|
||||||
setCompletionScope( scope );
|
setCompletionScope( scope );
|
||||||
setCompletionKind( kind );
|
setCompletionKind( kind );
|
||||||
setCompletionKeywords(key);
|
setCompletionKeywords(key);
|
||||||
ITokenDuple duple = new TokenDuple( first, last );
|
ITokenDuple duple = TokenFactory.createTokenDuple( first, last );
|
||||||
try {
|
try {
|
||||||
setCompletionContext( astFactory.lookupSymbolInContext( scope, duple, null ) );
|
setCompletionContext( astFactory.lookupSymbolInContext( scope, duple, null ) );
|
||||||
} catch (ASTNotImplementedException e) {
|
} catch (ASTNotImplementedException e) {
|
||||||
|
|
|
@ -35,7 +35,7 @@ import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
|
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
|
||||||
import org.eclipse.cdt.internal.core.parser.token.TokenDuple;
|
import org.eclipse.cdt.internal.core.parser.token.TokenFactory;
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*
|
*
|
||||||
|
@ -435,7 +435,7 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
||||||
convertedParms,
|
convertedParms,
|
||||||
(ASTPointerOperator)i.next());
|
(ASTPointerOperator)i.next());
|
||||||
|
|
||||||
ITokenDuple nameDuple = ( d.getPointerOperatorNameDuple() != null ) ? new TokenDuple( d.getPointerOperatorNameDuple(), d.getNameDuple() ) : d.getNameDuple();
|
ITokenDuple nameDuple = ( d.getPointerOperatorNameDuple() != null ) ? TokenFactory.createTokenDuple( d.getPointerOperatorNameDuple(), d.getNameDuple() ) : d.getNameDuple();
|
||||||
|
|
||||||
if( typedef )
|
if( typedef )
|
||||||
return astFactory.createTypedef(scope, nameDuple.toString(), abs,
|
return astFactory.createTypedef(scope, nameDuple.toString(), abs,
|
||||||
|
|
|
@ -42,6 +42,7 @@ import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
|
||||||
import org.eclipse.cdt.core.parser.extension.IParserExtension;
|
import org.eclipse.cdt.core.parser.extension.IParserExtension;
|
||||||
import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
|
import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
|
||||||
import org.eclipse.cdt.internal.core.parser.token.TokenDuple;
|
import org.eclipse.cdt.internal.core.parser.token.TokenDuple;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.token.TokenFactory;
|
||||||
import org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key;
|
import org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key;
|
||||||
import org.eclipse.cdt.internal.core.parser.util.TraceUtil;
|
import org.eclipse.cdt.internal.core.parser.util.TraceUtil;
|
||||||
|
|
||||||
|
@ -458,7 +459,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ITokenDuple tokenDuple = new TokenDuple(first, last, ( hasTemplateId ? argumentList.getTemplateArgumentsList() : null ) );
|
ITokenDuple tokenDuple = TokenFactory.createTokenDuple(first, last, ( hasTemplateId ? argumentList.getTemplateArgumentsList() : null ) );
|
||||||
setGreaterNameContext( tokenDuple );
|
setGreaterNameContext( tokenDuple );
|
||||||
return tokenDuple;
|
return tokenDuple;
|
||||||
}
|
}
|
||||||
|
@ -672,7 +673,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
}
|
}
|
||||||
|
|
||||||
ITokenDuple duple =
|
ITokenDuple duple =
|
||||||
new TokenDuple( originalToken == null ? operatorToken : originalToken, toSend, (hasTemplateId ? templateArgs.getTemplateArgumentsList() : null ) );
|
TokenFactory.createTokenDuple( originalToken == null ? operatorToken : originalToken, toSend, (hasTemplateId ? templateArgs.getTemplateArgumentsList() : null ) );
|
||||||
|
|
||||||
d.setName(duple);
|
d.setName(duple);
|
||||||
}
|
}
|
||||||
|
@ -2127,7 +2128,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
ITokenDuple templateId = null;
|
ITokenDuple templateId = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
templateId = new TokenDuple( current, templateId(scope, CompletionKind.SINGLE_NAME_REFERENCE ) );
|
templateId = TokenFactory.createTokenDuple( current, templateId(scope, CompletionKind.SINGLE_NAME_REFERENCE ) );
|
||||||
}
|
}
|
||||||
catch( BacktrackException bt )
|
catch( BacktrackException bt )
|
||||||
{
|
{
|
||||||
|
|
|
@ -60,7 +60,7 @@ import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier.ClassNameType;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||||
import org.eclipse.cdt.core.parser.extension.IParserExtension;
|
import org.eclipse.cdt.core.parser.extension.IParserExtension;
|
||||||
import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
|
import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
|
||||||
import org.eclipse.cdt.internal.core.parser.token.TokenDuple;
|
import org.eclipse.cdt.internal.core.parser.token.TokenFactory;
|
||||||
import org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key;
|
import org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key;
|
||||||
import org.eclipse.cdt.internal.core.parser.util.TraceUtil;
|
import org.eclipse.cdt.internal.core.parser.util.TraceUtil;
|
||||||
|
|
||||||
|
@ -1629,7 +1629,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
}
|
}
|
||||||
if( sdw.getName() != null )
|
if( sdw.getName() != null )
|
||||||
first = sdw.getName().getFirstToken();
|
first = sdw.getName().getFirstToken();
|
||||||
ITokenDuple duple = new TokenDuple(first, last);
|
ITokenDuple duple = TokenFactory.createTokenDuple(first, last);
|
||||||
sdw.setTypeName(duple);
|
sdw.setTypeName(duple);
|
||||||
flags.setEncounteredTypename(true);
|
flags.setEncounteredTypename(true);
|
||||||
break;
|
break;
|
||||||
|
@ -1725,7 +1725,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
private void setTypeName(DeclarationWrapper sdw, IToken typeNameBegin, IToken typeNameEnd) {
|
private void setTypeName(DeclarationWrapper sdw, IToken typeNameBegin, IToken typeNameEnd) {
|
||||||
if (typeNameBegin != null)
|
if (typeNameBegin != null)
|
||||||
sdw.setTypeName(
|
sdw.setTypeName(
|
||||||
new TokenDuple(typeNameBegin, typeNameEnd));
|
TokenFactory.createTokenDuple(typeNameBegin, typeNameEnd));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||||
import org.eclipse.cdt.core.parser.extension.IParserExtension;
|
import org.eclipse.cdt.core.parser.extension.IParserExtension;
|
||||||
import org.eclipse.cdt.internal.core.parser.token.OffsetDuple;
|
import org.eclipse.cdt.internal.core.parser.token.OffsetDuple;
|
||||||
import org.eclipse.cdt.internal.core.parser.token.TokenDuple;
|
import org.eclipse.cdt.internal.core.parser.token.TokenFactory;
|
||||||
import org.eclipse.cdt.internal.core.parser.util.TraceUtil;
|
import org.eclipse.cdt.internal.core.parser.util.TraceUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -133,7 +133,7 @@ public class SelectionParser extends ContextualParser {
|
||||||
if( getCompletionKind() == IASTCompletionNode.CompletionKind.UNREACHABLE_CODE )
|
if( getCompletionKind() == IASTCompletionNode.CompletionKind.UNREACHABLE_CODE )
|
||||||
throw new ParseError( ParseError.ParseErrorKind.OFFSETDUPLE_UNREACHABLE );
|
throw new ParseError( ParseError.ParseErrorKind.OFFSETDUPLE_UNREACHABLE );
|
||||||
|
|
||||||
ITokenDuple duple = new TokenDuple( firstTokenOfDuple, lastTokenOfDuple );
|
ITokenDuple duple = TokenFactory.createTokenDuple( firstTokenOfDuple, lastTokenOfDuple );
|
||||||
|
|
||||||
if( ! duple.syntaxOfName() )
|
if( ! duple.syntaxOfName() )
|
||||||
throw new ParseError( ParseError.ParseErrorKind.OFFSET_RANGE_NOT_NAME );
|
throw new ParseError( ParseError.ParseErrorKind.OFFSET_RANGE_NOT_NAME );
|
||||||
|
|
|
@ -721,8 +721,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
||||||
|
|
||||||
if( found instanceof IParameterizedSymbol )
|
if( found instanceof IParameterizedSymbol )
|
||||||
return (IParameterizedSymbol) found;
|
return (IParameterizedSymbol) found;
|
||||||
else
|
return null;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -828,54 +827,53 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
||||||
if( paramList != null ){
|
if( paramList != null ){
|
||||||
ParserSymbolTable.resolveFunction( data, constructors );
|
ParserSymbolTable.resolveFunction( data, constructors );
|
||||||
return constructors;
|
return constructors;
|
||||||
} else {
|
}
|
||||||
return constructors;
|
return constructors;
|
||||||
}
|
}
|
||||||
} else
|
return null;
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
//remove any ambiguous symbols
|
|
||||||
if( data.ambiguities != null && !data.ambiguities.isEmpty() ){
|
|
||||||
Iterator iter = data.ambiguities.iterator();
|
|
||||||
while( iter.hasNext() ){
|
|
||||||
data.foundItems.remove( iter.next() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List list = new LinkedList();
|
|
||||||
|
|
||||||
Iterator iter = data.foundItems.keySet().iterator();
|
|
||||||
Object obj = null;
|
|
||||||
List tempList = null;
|
|
||||||
while( iter.hasNext() ){
|
|
||||||
obj = data.foundItems.get( iter.next() );
|
|
||||||
|
|
||||||
if( obj instanceof List ){
|
|
||||||
//a list must be all functions?
|
|
||||||
if( paramList != null )
|
|
||||||
ParserSymbolTable.resolveFunction( data, (List) obj );
|
|
||||||
list.addAll( (List) obj );
|
|
||||||
} else{
|
|
||||||
if( paramList != null && ((ISymbol)obj).isType( TypeInfo.t_function ) )
|
|
||||||
{
|
|
||||||
if( tempList == null )
|
|
||||||
tempList = new LinkedList();
|
|
||||||
else
|
|
||||||
tempList.clear();
|
|
||||||
tempList.add( obj );
|
|
||||||
ParserSymbolTable.resolveFunction( data, tempList );
|
|
||||||
list.addAll( tempList );
|
|
||||||
} else {
|
|
||||||
list.add( obj );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( constructors != null )
|
|
||||||
list.addAll( constructors );
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
//remove any ambiguous symbols
|
||||||
|
if( data.ambiguities != null && !data.ambiguities.isEmpty() ){
|
||||||
|
Iterator iter = data.ambiguities.iterator();
|
||||||
|
while( iter.hasNext() ){
|
||||||
|
data.foundItems.remove( iter.next() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List list = new LinkedList();
|
||||||
|
|
||||||
|
Iterator iter = data.foundItems.keySet().iterator();
|
||||||
|
Object obj = null;
|
||||||
|
List tempList = null;
|
||||||
|
while( iter.hasNext() ){
|
||||||
|
obj = data.foundItems.get( iter.next() );
|
||||||
|
|
||||||
|
if( obj instanceof List ){
|
||||||
|
//a list must be all functions?
|
||||||
|
if( paramList != null )
|
||||||
|
ParserSymbolTable.resolveFunction( data, (List) obj );
|
||||||
|
list.addAll( (List) obj );
|
||||||
|
} else{
|
||||||
|
if( paramList != null && ((ISymbol)obj).isType( TypeInfo.t_function ) )
|
||||||
|
{
|
||||||
|
if( tempList == null )
|
||||||
|
tempList = new LinkedList();
|
||||||
|
else
|
||||||
|
tempList.clear();
|
||||||
|
tempList.add( obj );
|
||||||
|
ParserSymbolTable.resolveFunction( data, tempList );
|
||||||
|
list.addAll( tempList );
|
||||||
|
} else {
|
||||||
|
list.add( obj );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( constructors != null )
|
||||||
|
list.addAll( constructors );
|
||||||
|
|
||||||
|
return list;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isVisible( ISymbol symbol, IContainerSymbol qualifyingSymbol ){
|
public boolean isVisible( ISymbol symbol, IContainerSymbol qualifyingSymbol ){
|
||||||
|
@ -918,9 +916,8 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
||||||
} catch (ParserSymbolTableException e) {
|
} catch (ParserSymbolTableException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else { //PRIVATE
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,8 +75,7 @@ public class DeferredTemplateInstance extends BasicSymbol implements IDeferredTe
|
||||||
ISymbol symbol = _template.getTemplatedSymbol();
|
ISymbol symbol = _template.getTemplatedSymbol();
|
||||||
if( symbol != null )
|
if( symbol != null )
|
||||||
return symbol.isType( type, upperType );
|
return symbol.isType( type, upperType );
|
||||||
else
|
return super.isType( type, upperType );
|
||||||
return super.isType( type, upperType );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,16 +83,14 @@ public class DeferredTemplateInstance extends BasicSymbol implements IDeferredTe
|
||||||
ISymbol symbol = _template.getTemplatedSymbol();
|
ISymbol symbol = _template.getTemplatedSymbol();
|
||||||
if( symbol != null )
|
if( symbol != null )
|
||||||
return symbol.getType();
|
return symbol.getType();
|
||||||
else
|
return super.getType();
|
||||||
return super.getType();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TypeInfo getTypeInfo(){
|
public TypeInfo getTypeInfo(){
|
||||||
ISymbol symbol = _template.getTemplatedSymbol();
|
ISymbol symbol = _template.getTemplatedSymbol();
|
||||||
if( symbol != null )
|
if( symbol != null )
|
||||||
return symbol.getTypeInfo();
|
return symbol.getTypeInfo();
|
||||||
else
|
return super.getTypeInfo();
|
||||||
return super.getTypeInfo();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isType( TypeInfo.eType type ){
|
public boolean isType( TypeInfo.eType type ){
|
||||||
|
|
|
@ -58,8 +58,7 @@ public class ExtensibleSymbolExtension implements ISymbolASTExtension {
|
||||||
public ISymbol getSymbol() {
|
public ISymbol getSymbol() {
|
||||||
if( extensibleSymbol instanceof ISymbol )
|
if( extensibleSymbol instanceof ISymbol )
|
||||||
return (ISymbol) extensibleSymbol;
|
return (ISymbol) extensibleSymbol;
|
||||||
else
|
return null;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IExtensibleSymbol getExtensibleSymbol(){
|
public IExtensibleSymbol getExtensibleSymbol(){
|
||||||
|
|
|
@ -451,9 +451,8 @@ public class ParserSymbolTable {
|
||||||
private static boolean nameMatches( LookupData data, String name ){
|
private static boolean nameMatches( LookupData data, String name ){
|
||||||
if( data.mode == LookupMode.PREFIX ){
|
if( data.mode == LookupMode.PREFIX ){
|
||||||
return name.regionMatches( true, 0, data.name, 0, data.name.length() );
|
return name.regionMatches( true, 0, data.name, 0, data.name.length() );
|
||||||
} else {
|
}
|
||||||
return name.equals( data.name );
|
return name.equals( data.name );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
private static boolean checkType( LookupData data, ISymbol symbol ) { //, TypeInfo.eType type, TypeInfo.eType upperType ){
|
private static boolean checkType( LookupData data, ISymbol symbol ) { //, TypeInfo.eType type, TypeInfo.eType upperType ){
|
||||||
if( data.filter == null ){
|
if( data.filter == null ){
|
||||||
|
@ -804,20 +803,18 @@ public class ParserSymbolTable {
|
||||||
|
|
||||||
if( origType == TypeInfo.t_template ){
|
if( origType == TypeInfo.t_template ){
|
||||||
ITemplateSymbol template = (ITemplateSymbol) origSymbol;
|
ITemplateSymbol template = (ITemplateSymbol) origSymbol;
|
||||||
origSymbol = (ISymbol) template.getTemplatedSymbol();
|
origSymbol = template.getTemplatedSymbol();
|
||||||
if( origSymbol == null )
|
if( origSymbol == null )
|
||||||
return true;
|
return true;
|
||||||
else
|
origType = origSymbol.getType();
|
||||||
origType = origSymbol.getType();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( newType == TypeInfo.t_template ){
|
if( newType == TypeInfo.t_template ){
|
||||||
ITemplateSymbol template = (ITemplateSymbol) newSymbol;
|
ITemplateSymbol template = (ITemplateSymbol) newSymbol;
|
||||||
newSymbol = (ISymbol) template.getTemplatedSymbol();
|
newSymbol = template.getTemplatedSymbol();
|
||||||
if( newSymbol == null )
|
if( newSymbol == null )
|
||||||
return true;
|
return true;
|
||||||
else
|
newType = newSymbol.getType();
|
||||||
newType = newSymbol.getType();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//handle forward decls
|
//handle forward decls
|
||||||
|
@ -841,7 +838,6 @@ public class ParserSymbolTable {
|
||||||
//allowable thing is if they are both functions.
|
//allowable thing is if they are both functions.
|
||||||
if( origSymbol instanceof IParameterizedSymbol && newSymbol instanceof IParameterizedSymbol )
|
if( origSymbol instanceof IParameterizedSymbol && newSymbol instanceof IParameterizedSymbol )
|
||||||
return isValidFunctionOverload( (IParameterizedSymbol) origSymbol, (IParameterizedSymbol) newSymbol );
|
return isValidFunctionOverload( (IParameterizedSymbol) origSymbol, (IParameterizedSymbol) newSymbol );
|
||||||
else
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -875,7 +871,7 @@ public class ParserSymbolTable {
|
||||||
symbol = (ISymbol) iter.next();
|
symbol = (ISymbol) iter.next();
|
||||||
if( symbol.isType( TypeInfo.t_template ) ){
|
if( symbol.isType( TypeInfo.t_template ) ){
|
||||||
ITemplateSymbol template = (ITemplateSymbol) symbol;
|
ITemplateSymbol template = (ITemplateSymbol) symbol;
|
||||||
symbol = (ISymbol) template.getTemplatedSymbol();
|
symbol = template.getTemplatedSymbol();
|
||||||
}
|
}
|
||||||
valid = ( symbol instanceof IParameterizedSymbol) && isValidFunctionOverload( (IParameterizedSymbol)symbol, (IParameterizedSymbol)newSymbol );
|
valid = ( symbol instanceof IParameterizedSymbol) && isValidFunctionOverload( (IParameterizedSymbol)symbol, (IParameterizedSymbol)newSymbol );
|
||||||
}
|
}
|
||||||
|
@ -1288,10 +1284,9 @@ public class ParserSymbolTable {
|
||||||
if( num < numParameters ){
|
if( num < numParameters ){
|
||||||
if( function.hasVariableArgs() ) {
|
if( function.hasVariableArgs() ) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
}
|
||||||
//not enough parameters, remove it
|
//not enough parameters, remove it
|
||||||
iter.remove();
|
iter.remove();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//a candidate function having more than m parameters is viable only if the (m+1)-st
|
//a candidate function having more than m parameters is viable only if the (m+1)-st
|
||||||
//parameter has a default argument
|
//parameter has a default argument
|
||||||
|
@ -1438,14 +1433,11 @@ public class ParserSymbolTable {
|
||||||
if( parent == base ){
|
if( parent == base ){
|
||||||
if( throwIfNotVisible && !isVisible )
|
if( throwIfNotVisible && !isVisible )
|
||||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadVisibility );
|
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadVisibility );
|
||||||
else
|
return 1;
|
||||||
return 1;
|
}
|
||||||
} else {
|
int n = hasBaseClass( parent, base, throwIfNotVisible );
|
||||||
int n = hasBaseClass( parent, base, throwIfNotVisible );
|
if( n > 0 )
|
||||||
if( n > 0 ){
|
return n + 1;
|
||||||
return n + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2001,17 +1993,14 @@ public class ParserSymbolTable {
|
||||||
if( secondCost.userDefined == Cost.AMBIGUOUS_USERDEFINED_CONVERSION ){
|
if( secondCost.userDefined == Cost.AMBIGUOUS_USERDEFINED_CONVERSION ){
|
||||||
//conversion is ambiguous -> ill-formed
|
//conversion is ambiguous -> ill-formed
|
||||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_Ambiguous );
|
throw new ParserSymbolTableException( ParserSymbolTableException.r_Ambiguous );
|
||||||
} else {
|
}
|
||||||
return thirdOp;
|
return thirdOp;
|
||||||
}
|
}
|
||||||
} else {
|
if( thirdCost.userDefined == Cost.AMBIGUOUS_USERDEFINED_CONVERSION )
|
||||||
if( thirdCost.userDefined == Cost.AMBIGUOUS_USERDEFINED_CONVERSION ){
|
//conversion is ambiguous -> ill-formed
|
||||||
//conversion is ambiguous -> ill-formed
|
throw new ParserSymbolTableException( ParserSymbolTableException.r_Ambiguous );
|
||||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_Ambiguous );
|
|
||||||
} else {
|
return secondOp;
|
||||||
return secondOp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2227,15 +2216,14 @@ public class ParserSymbolTable {
|
||||||
if( userDefined != 0 || cost.userDefined != 0 ){
|
if( userDefined != 0 || cost.userDefined != 0 ){
|
||||||
if( userDefined == 0 || cost.userDefined == 0 ){
|
if( userDefined == 0 || cost.userDefined == 0 ){
|
||||||
return cost.userDefined - userDefined;
|
return cost.userDefined - userDefined;
|
||||||
} else {
|
}
|
||||||
if( (userDefined == AMBIGUOUS_USERDEFINED_CONVERSION || cost.userDefined == AMBIGUOUS_USERDEFINED_CONVERSION) ||
|
if( (userDefined == AMBIGUOUS_USERDEFINED_CONVERSION || cost.userDefined == AMBIGUOUS_USERDEFINED_CONVERSION) ||
|
||||||
(userDefined != cost.userDefined ) )
|
(userDefined != cost.userDefined ) )
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
// else they are the same constructor/conversion operator and are ranked
|
// else they are the same constructor/conversion operator and are ranked
|
||||||
//on the standard conversion sequence
|
//on the standard conversion sequence
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( promotion > 0 || cost.promotion > 0 ){
|
if( promotion > 0 || cost.promotion > 0 ){
|
||||||
|
@ -2307,9 +2295,8 @@ public class ParserSymbolTable {
|
||||||
IASTNode node = extension != null ? extension.getPrimaryDeclaration() : null;
|
IASTNode node = extension != null ? extension.getPrimaryDeclaration() : null;
|
||||||
if( node != null && node instanceof IASTMember ){
|
if( node != null && node instanceof IASTMember ){
|
||||||
return ((IASTMember)node).getVisiblity();
|
return ((IASTMember)node).getVisiblity();
|
||||||
} else {
|
}
|
||||||
throw new ParserSymbolTableError( ParserSymbolTableError.r_InternalError );
|
throw new ParserSymbolTableError( ParserSymbolTableError.r_InternalError );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! (qualifyingSymbol instanceof IDerivableContainerSymbol) ){
|
if( ! (qualifyingSymbol instanceof IDerivableContainerSymbol) ){
|
||||||
|
|
|
@ -103,20 +103,20 @@ public class SpecializedSymbol extends TemplateSymbol implements ISpecializedSym
|
||||||
IContainerSymbol instance = findInstantiation( actualArgs );
|
IContainerSymbol instance = findInstantiation( actualArgs );
|
||||||
if( instance != null ){
|
if( instance != null ){
|
||||||
return instance;
|
return instance;
|
||||||
} else {
|
}
|
||||||
IContainerSymbol symbol = null;
|
IContainerSymbol symbol = null;
|
||||||
|
|
||||||
if( getContainedSymbols().size() == 1 ){
|
if( getContainedSymbols().size() == 1 ){
|
||||||
Iterator iter = getContainedSymbols().keySet().iterator();
|
Iterator iter = getContainedSymbols().keySet().iterator();
|
||||||
symbol = (IContainerSymbol)getContainedSymbols().get( iter.next() );
|
symbol = (IContainerSymbol)getContainedSymbols().get( iter.next() );
|
||||||
}
|
|
||||||
|
|
||||||
instance = (IContainerSymbol) symbol.instantiate( this, argMap );
|
|
||||||
addInstantiation( instance, actualArgs );
|
|
||||||
processDeferredInstantiations();
|
|
||||||
|
|
||||||
return instance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
instance = (IContainerSymbol) symbol.instantiate( this, argMap );
|
||||||
|
addInstantiation( instance, actualArgs );
|
||||||
|
processDeferredInstantiations();
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -28,42 +28,42 @@ import org.eclipse.cdt.internal.core.parser.pst.TypeInfo.PtrOp;
|
||||||
public final class TemplateEngine {
|
public final class TemplateEngine {
|
||||||
|
|
||||||
static protected TypeInfo instantiateTypeInfo( TypeInfo info, ITemplateSymbol template, Map argMap ) throws ParserSymbolTableException{
|
static protected TypeInfo instantiateTypeInfo( TypeInfo info, ITemplateSymbol template, Map argMap ) throws ParserSymbolTableException{
|
||||||
if( argMap == null ){
|
if( argMap == null )
|
||||||
return info;
|
return info;
|
||||||
} else {
|
|
||||||
if( info.isType( TypeInfo.t_type ) && info.getTypeSymbol() == null )
|
if( info.isType( TypeInfo.t_type ) && info.getTypeSymbol() == null )
|
||||||
return info;
|
return info;
|
||||||
if( info.isType( TypeInfo.t_type ) && info.getTypeSymbol() instanceof IDeferredTemplateInstance ){
|
if( info.isType( TypeInfo.t_type ) && info.getTypeSymbol() instanceof IDeferredTemplateInstance ){
|
||||||
IDeferredTemplateInstance deferred = (IDeferredTemplateInstance) info.getTypeSymbol();
|
IDeferredTemplateInstance deferred = (IDeferredTemplateInstance) info.getTypeSymbol();
|
||||||
TypeInfo newInfo = new TypeInfo( info );
|
TypeInfo newInfo = new TypeInfo( info );
|
||||||
//newInfo.setTypeSymbol( deferred.instantiate( template, argMap ) );
|
//newInfo.setTypeSymbol( deferred.instantiate( template, argMap ) );
|
||||||
template.registerDeferredInstatiation( newInfo, deferred, ITemplateSymbol.DeferredKind.TYPE_SYMBOL, argMap );
|
template.registerDeferredInstatiation( newInfo, deferred, ITemplateSymbol.DeferredKind.TYPE_SYMBOL, argMap );
|
||||||
newInfo.setTypeSymbol( deferred );
|
newInfo.setTypeSymbol( deferred );
|
||||||
return newInfo;
|
return newInfo;
|
||||||
} else if( info.isType( TypeInfo.t_type ) &&
|
} else if( info.isType( TypeInfo.t_type ) &&
|
||||||
info.getTypeSymbol().isType( TypeInfo.t_templateParameter ) &&
|
info.getTypeSymbol().isType( TypeInfo.t_templateParameter ) &&
|
||||||
argMap.containsKey( info.getTypeSymbol() ) )
|
argMap.containsKey( info.getTypeSymbol() ) )
|
||||||
{
|
{
|
||||||
TypeInfo targetInfo = new TypeInfo( (TypeInfo) argMap.get( info.getTypeSymbol() ) );
|
TypeInfo targetInfo = new TypeInfo( (TypeInfo) argMap.get( info.getTypeSymbol() ) );
|
||||||
if( info.hasPtrOperators() ){
|
if( info.hasPtrOperators() ){
|
||||||
List infoOperators = new LinkedList( info.getPtrOperators() );
|
List infoOperators = new LinkedList( info.getPtrOperators() );
|
||||||
targetInfo.addPtrOperator( infoOperators );
|
targetInfo.addPtrOperator( infoOperators );
|
||||||
}
|
|
||||||
|
|
||||||
if( info.checkBit( TypeInfo.isConst ) )
|
|
||||||
targetInfo.setBit( true, TypeInfo.isConst );
|
|
||||||
|
|
||||||
if( info.checkBit( TypeInfo.isVolatile ) )
|
|
||||||
targetInfo.setBit( true, TypeInfo.isVolatile );
|
|
||||||
|
|
||||||
return targetInfo;
|
|
||||||
} else if( info.isType( TypeInfo.t_type ) && info.getTypeSymbol().isType( TypeInfo.t_function ) ){
|
|
||||||
TypeInfo newInfo = new TypeInfo( info );
|
|
||||||
newInfo.setTypeSymbol( info.getTypeSymbol().instantiate( template, argMap ) );
|
|
||||||
return newInfo;
|
|
||||||
}
|
}
|
||||||
return info;
|
|
||||||
|
if( info.checkBit( TypeInfo.isConst ) )
|
||||||
|
targetInfo.setBit( true, TypeInfo.isConst );
|
||||||
|
|
||||||
|
if( info.checkBit( TypeInfo.isVolatile ) )
|
||||||
|
targetInfo.setBit( true, TypeInfo.isVolatile );
|
||||||
|
|
||||||
|
return targetInfo;
|
||||||
|
} else if( info.isType( TypeInfo.t_type ) && info.getTypeSymbol().isType( TypeInfo.t_function ) ){
|
||||||
|
TypeInfo newInfo = new TypeInfo( info );
|
||||||
|
newInfo.setTypeSymbol( info.getTypeSymbol().instantiate( template, argMap ) );
|
||||||
|
return newInfo;
|
||||||
}
|
}
|
||||||
|
return info;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static protected void instantiateDeferredTypeInfo( TypeInfo info, ITemplateSymbol template, Map argMap ) throws ParserSymbolTableException {
|
static protected void instantiateDeferredTypeInfo( TypeInfo info, ITemplateSymbol template, Map argMap ) throws ParserSymbolTableException {
|
||||||
|
@ -349,27 +349,25 @@ public final class TemplateEngine {
|
||||||
if( symbol instanceof IDeferredTemplateInstance ){
|
if( symbol instanceof IDeferredTemplateInstance ){
|
||||||
IDeferredTemplateInstance deferred = (IDeferredTemplateInstance) symbol;
|
IDeferredTemplateInstance deferred = (IDeferredTemplateInstance) symbol;
|
||||||
return deferred.getArguments();
|
return deferred.getArguments();
|
||||||
} else {
|
}
|
||||||
ISymbol instantiated = symbol.getInstantiatedSymbol();
|
ISymbol instantiated = symbol.getInstantiatedSymbol();
|
||||||
template = (ITemplateSymbol) instantiated.getContainingSymbol();
|
template = (ITemplateSymbol) instantiated.getContainingSymbol();
|
||||||
}
|
|
||||||
|
|
||||||
if( template instanceof ISpecializedSymbol ){
|
if( template instanceof ISpecializedSymbol ){
|
||||||
return ((ISpecializedSymbol)template).getArgumentList();
|
return ((ISpecializedSymbol)template).getArgumentList();
|
||||||
} else {
|
}
|
||||||
return template.getParameterList();
|
return template.getParameterList();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static private List getTargetList( ISymbol symbol ){
|
static private List getTargetList( ISymbol symbol ){
|
||||||
if( symbol instanceof IDeferredTemplateInstance ){
|
if( symbol instanceof IDeferredTemplateInstance ){
|
||||||
IDeferredTemplateInstance deferred = (IDeferredTemplateInstance) symbol;
|
IDeferredTemplateInstance deferred = (IDeferredTemplateInstance) symbol;
|
||||||
return deferred.getArguments();
|
return deferred.getArguments();
|
||||||
} else {
|
}
|
||||||
ISymbol instantiated = symbol.getInstantiatedSymbol();
|
ISymbol instantiated = symbol.getInstantiatedSymbol();
|
||||||
ITemplateSymbol template = (ITemplateSymbol) instantiated.getContainingSymbol();
|
ITemplateSymbol template = (ITemplateSymbol) instantiated.getContainingSymbol();
|
||||||
return template.findArgumentsFor( (IContainerSymbol) symbol );
|
return template.findArgumentsFor( (IContainerSymbol) symbol );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -445,120 +443,113 @@ public final class TemplateEngine {
|
||||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTypeInfo );
|
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTypeInfo );
|
||||||
if( symbol instanceof IDeferredTemplateInstance || symbol.isTemplateInstance() ){
|
if( symbol instanceof IDeferredTemplateInstance || symbol.isTemplateInstance() ){
|
||||||
return deduceFromTemplateTemplateArguments(map, symbol, aSymbol);
|
return deduceFromTemplateTemplateArguments(map, symbol, aSymbol);
|
||||||
} else {
|
}
|
||||||
if( symbol.isType( TypeInfo.t_templateParameter ) ){
|
if( symbol.isType( TypeInfo.t_templateParameter ) ){
|
||||||
if( symbol.getTypeInfo().getTemplateParameterType() == TypeInfo.t_typeName ){
|
if( symbol.getTypeInfo().getTemplateParameterType() == TypeInfo.t_typeName ){
|
||||||
//a = getFlatTypeInfo( a );
|
//a = getFlatTypeInfo( a );
|
||||||
List aPtrs = a.getPtrOperators();
|
List aPtrs = a.getPtrOperators();
|
||||||
List pPtrs = p.getPtrOperators();
|
List pPtrs = p.getPtrOperators();
|
||||||
|
|
||||||
if( pPtrs != null && pPtrs.size() > 0){
|
if( pPtrs != null && pPtrs.size() > 0){
|
||||||
if( aPtrs == null ){
|
if( aPtrs == null ){
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Iterator pIter = pPtrs.iterator();
|
|
||||||
ListIterator aIter = aPtrs.listIterator();
|
|
||||||
PtrOp pOp = null;
|
|
||||||
PtrOp aOp = null;
|
|
||||||
while( pIter.hasNext() ){
|
|
||||||
pOp = (PtrOp) pIter.next();
|
|
||||||
if( !aIter.hasNext() ){
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
aOp = (PtrOp) aIter.next();
|
|
||||||
if( pOp.getType() == aOp.getType() ){
|
|
||||||
if( !pOp.equals( aOp ) ){
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
aIter.remove();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//cvlist T
|
|
||||||
if( p.checkBit( TypeInfo.isConst ) ){
|
|
||||||
if( !a.checkBit( TypeInfo.isConst ) )
|
|
||||||
return false;
|
|
||||||
a.setBit( false, TypeInfo.isConst);
|
|
||||||
}
|
|
||||||
if( p.checkBit( TypeInfo.isVolatile ) ){
|
|
||||||
if( !a.checkBit( TypeInfo.isVolatile ) )
|
|
||||||
return false;
|
|
||||||
a.setBit( false, TypeInfo.isVolatile);
|
|
||||||
}
|
|
||||||
|
|
||||||
//T
|
|
||||||
return deduceArgument( map, symbol, a );
|
|
||||||
|
|
||||||
} else if ( symbol.getTypeInfo().getTemplateParameterType() == TypeInfo.t_template ){
|
|
||||||
|
|
||||||
} else {
|
|
||||||
//non-type parameter
|
|
||||||
if( symbol.getTypeInfo().getTemplateParameterType() == a.getType() ){
|
|
||||||
return deduceArgument( map, symbol, a );
|
|
||||||
} else {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
Iterator pIter = pPtrs.iterator();
|
||||||
}
|
ListIterator aIter = aPtrs.listIterator();
|
||||||
//T (*) ( ), T ( T::* ) ( T ), & variations
|
PtrOp pOp = null;
|
||||||
else if( symbol.isType( TypeInfo.t_function ) ){
|
PtrOp aOp = null;
|
||||||
if( !(aSymbol instanceof IParameterizedSymbol)||
|
|
||||||
!aSymbol.isType( TypeInfo.t_function ) )
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
IParameterizedSymbol pFunction = (IParameterizedSymbol)symbol;
|
|
||||||
IParameterizedSymbol aFunction = (IParameterizedSymbol)aSymbol;
|
|
||||||
|
|
||||||
if( !deduceTemplateArgument( map, pFunction.getReturnType(), aFunction.getReturnType().getTypeInfo() ) ){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
List pPtrs = p.getPtrOperators();
|
|
||||||
if( pPtrs.size() != 0 ){
|
|
||||||
PtrOp op = (PtrOp) pPtrs.iterator().next();
|
|
||||||
if( op.getType() == PtrOp.t_memberPointer ){
|
|
||||||
TypeInfo info = new TypeInfo( TypeInfo.t_type, 0, aFunction.getContainingSymbol() );
|
|
||||||
if( !deduceTemplateArgument( map, op.getMemberOf(), info ) ){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List pParams = pFunction.getParameterList();
|
|
||||||
List aParams = aFunction.getParameterList();
|
|
||||||
if( pParams.size() != aParams.size() ){
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
Iterator pIter = pParams.iterator();
|
|
||||||
Iterator aIter = aParams.iterator();
|
|
||||||
while( pIter.hasNext() ){
|
while( pIter.hasNext() ){
|
||||||
TypeInfo info = ((ISymbol)aIter.next()).getTypeInfo();
|
pOp = (PtrOp) pIter.next();
|
||||||
if( !deduceTemplateArgument( map, (ISymbol) pIter.next(), info ) ){
|
if( !aIter.hasNext() ){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
aOp = (PtrOp) aIter.next();
|
||||||
|
if( pOp.getType() == aOp.getType() ){
|
||||||
|
if( !pOp.equals( aOp ) )
|
||||||
|
return false;
|
||||||
|
aIter.remove();
|
||||||
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//cvlist T
|
||||||
|
if( p.checkBit( TypeInfo.isConst ) ){
|
||||||
|
if( !a.checkBit( TypeInfo.isConst ) )
|
||||||
|
return false;
|
||||||
|
a.setBit( false, TypeInfo.isConst);
|
||||||
|
}
|
||||||
|
if( p.checkBit( TypeInfo.isVolatile ) ){
|
||||||
|
if( !a.checkBit( TypeInfo.isVolatile ) )
|
||||||
|
return false;
|
||||||
|
a.setBit( false, TypeInfo.isVolatile);
|
||||||
|
}
|
||||||
|
|
||||||
|
//T
|
||||||
|
return deduceArgument( map, symbol, a );
|
||||||
|
|
||||||
|
} else if ( symbol.getTypeInfo().getTemplateParameterType() == TypeInfo.t_template ){
|
||||||
|
|
||||||
|
} else {
|
||||||
|
//non-type parameter
|
||||||
|
if( symbol.getTypeInfo().getTemplateParameterType() == a.getType() ){
|
||||||
|
return deduceArgument( map, symbol, a );
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//T (*) ( ), T ( T::* ) ( T ), & variations
|
||||||
|
else if( symbol.isType( TypeInfo.t_function ) ){
|
||||||
|
if( !(aSymbol instanceof IParameterizedSymbol)||
|
||||||
|
!aSymbol.isType( TypeInfo.t_function ) )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
IParameterizedSymbol pFunction = (IParameterizedSymbol)symbol;
|
||||||
|
IParameterizedSymbol aFunction = (IParameterizedSymbol)aSymbol;
|
||||||
|
|
||||||
|
if( !deduceTemplateArgument( map, pFunction.getReturnType(), aFunction.getReturnType().getTypeInfo() ) ){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
List pPtrs = p.getPtrOperators();
|
||||||
|
if( pPtrs.size() != 0 ){
|
||||||
|
PtrOp op = (PtrOp) pPtrs.iterator().next();
|
||||||
|
if( op.getType() == PtrOp.t_memberPointer ){
|
||||||
|
TypeInfo info = new TypeInfo( TypeInfo.t_type, 0, aFunction.getContainingSymbol() );
|
||||||
|
if( !deduceTemplateArgument( map, op.getMemberOf(), info ) ){
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
}
|
||||||
|
|
||||||
|
List pParams = pFunction.getParameterList();
|
||||||
|
List aParams = aFunction.getParameterList();
|
||||||
|
if( pParams.size() != aParams.size() ){
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
Iterator pIter = pParams.iterator();
|
||||||
} else {
|
Iterator aIter = aParams.iterator();
|
||||||
if( p.isType( TypeInfo.t_templateParameter ) ){
|
while( pIter.hasNext() ){
|
||||||
return deduceArgument( map, pSymbol, a );
|
TypeInfo info = ((ISymbol)aIter.next()).getTypeInfo();
|
||||||
}
|
if( !deduceTemplateArgument( map, (ISymbol) pIter.next(), info ) ){
|
||||||
if( p.getType() == a.getType() ){
|
return false;
|
||||||
if( p.getDefault() != null ){
|
}
|
||||||
return ( p.getDefault().equals( a.getDefault() ) );
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if( p.isType( TypeInfo.t_templateParameter ) ){
|
||||||
|
return deduceArgument( map, pSymbol, a );
|
||||||
|
}
|
||||||
|
if( p.getType() == a.getType() ){
|
||||||
|
if( p.getDefault() != null ){
|
||||||
|
return ( p.getDefault().equals( a.getDefault() ) );
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -668,7 +659,7 @@ public final class TemplateEngine {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
ISymbol templateSymbol = (ISymbol) template.getTemplatedSymbol();
|
ISymbol templateSymbol = template.getTemplatedSymbol();
|
||||||
if( !templateSymbol.isType( TypeInfo.t_function ) ){
|
if( !templateSymbol.isType( TypeInfo.t_function ) ){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -706,10 +697,9 @@ public final class TemplateEngine {
|
||||||
if( map.containsKey( p ) ){
|
if( map.containsKey( p ) ){
|
||||||
TypeInfo current = (TypeInfo)map.get( p );
|
TypeInfo current = (TypeInfo)map.get( p );
|
||||||
return current.equals( a );
|
return current.equals( a );
|
||||||
} else {
|
}
|
||||||
map.put( p, a );
|
map.put( p, a );
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Compare spec1 to spec2. Return > 0 if spec1 is more specialized, < 0 if spec2
|
* Compare spec1 to spec2. Return > 0 if spec1 is more specialized, < 0 if spec2
|
||||||
|
@ -723,7 +713,7 @@ public final class TemplateEngine {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ISymbol decl = (ISymbol) spec1.getTemplatedSymbol();
|
ISymbol decl = spec1.getTemplatedSymbol();
|
||||||
|
|
||||||
//to order class template specializations, we need to transform them into function templates
|
//to order class template specializations, we need to transform them into function templates
|
||||||
ITemplateSymbol template1 = spec1;
|
ITemplateSymbol template1 = spec1;
|
||||||
|
@ -961,9 +951,8 @@ public final class TemplateEngine {
|
||||||
//make sure parameters match up with found template
|
//make sure parameters match up with found template
|
||||||
if( checkTemplateParameterListsAreEquivalent( primary.getParameterList(), parameters ) ){
|
if( checkTemplateParameterListsAreEquivalent( primary.getParameterList(), parameters ) ){
|
||||||
return template;
|
return template;
|
||||||
} else {
|
}
|
||||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplateParameter );
|
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplateParameter );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//specialization
|
//specialization
|
||||||
|
@ -1208,28 +1197,25 @@ public final class TemplateEngine {
|
||||||
Map map = deduceTemplateArgumentsUsingParameterList( tmpl, (IParameterizedSymbol) symbol );
|
Map map = deduceTemplateArgumentsUsingParameterList( tmpl, (IParameterizedSymbol) symbol );
|
||||||
|
|
||||||
if( map == null )
|
if( map == null )
|
||||||
continue;
|
continue;
|
||||||
else {
|
Iterator pIter = tmpl.getParameterList().iterator();
|
||||||
Iterator pIter = tmpl.getParameterList().iterator();
|
Iterator aIter = args.iterator();
|
||||||
Iterator aIter = args.iterator();
|
while( pIter.hasNext() && aIter.hasNext() ){
|
||||||
while( pIter.hasNext() && aIter.hasNext() ){
|
ISymbol param = (ISymbol) pIter.next();
|
||||||
ISymbol param = (ISymbol) pIter.next();
|
TypeInfo arg = (TypeInfo) aIter.next();
|
||||||
TypeInfo arg = (TypeInfo) aIter.next();
|
if( map.containsKey( param ) ) {
|
||||||
if( map.containsKey( param ) ) {
|
if( !map.get( param ).equals( arg )){
|
||||||
if( !map.get( param ).equals( arg )){
|
|
||||||
continue outer;
|
|
||||||
}
|
|
||||||
} else if( !matchTemplateParameterAndArgument( param, arg )){
|
|
||||||
continue outer;
|
continue outer;
|
||||||
}
|
}
|
||||||
}
|
} else if( !matchTemplateParameterAndArgument( param, arg )){
|
||||||
//made it this far, its a match
|
continue outer;
|
||||||
if( template != null ){
|
|
||||||
throw new ParserSymbolTableException(ParserSymbolTableException.r_Ambiguous );
|
|
||||||
} else {
|
|
||||||
template = tmpl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//made it this far, its a match
|
||||||
|
if( template != null ){
|
||||||
|
throw new ParserSymbolTableException(ParserSymbolTableException.r_Ambiguous );
|
||||||
|
}
|
||||||
|
template = tmpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return template;
|
return template;
|
||||||
|
|
|
@ -253,24 +253,22 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
||||||
if( previous == null ) {
|
if( previous == null ) {
|
||||||
//could happen in trying to define something for which we don't have a declaration
|
//could happen in trying to define something for which we don't have a declaration
|
||||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplate );
|
throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplate );
|
||||||
} else {
|
}
|
||||||
IContainerSymbol originalContainer = previous.getContainingSymbol();
|
IContainerSymbol originalContainer = previous.getContainingSymbol();
|
||||||
|
|
||||||
if( previous.isForwardDeclaration() ){
|
|
||||||
doDefinitionParameterMaps( symbol );
|
|
||||||
|
|
||||||
originalContainer.addSymbol( symbol );
|
|
||||||
|
|
||||||
if( getASTExtension() != null ){
|
|
||||||
ASTTemplateDeclaration templateDecl = (ASTTemplateDeclaration) getASTExtension().getPrimaryDeclaration();
|
|
||||||
templateDecl.releaseFactory();
|
|
||||||
templateDecl.setOwnedDeclaration( symbol );
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_InvalidOverload );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if( previous.isForwardDeclaration() ){
|
||||||
|
doDefinitionParameterMaps( symbol );
|
||||||
|
|
||||||
|
originalContainer.addSymbol( symbol );
|
||||||
|
|
||||||
|
if( getASTExtension() != null ){
|
||||||
|
ASTTemplateDeclaration templateDecl = (ASTTemplateDeclaration) getASTExtension().getPrimaryDeclaration();
|
||||||
|
templateDecl.releaseFactory();
|
||||||
|
templateDecl.setOwnedDeclaration( symbol );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new ParserSymbolTableException( ParserSymbolTableException.r_InvalidOverload );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doDefinitionParameterMaps( ISymbol newSymbol ) throws ParserSymbolTableException {
|
private void doDefinitionParameterMaps( ISymbol newSymbol ) throws ParserSymbolTableException {
|
||||||
|
@ -357,9 +355,8 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
||||||
}
|
}
|
||||||
if( look instanceof ITemplateSymbol ){
|
if( look instanceof ITemplateSymbol ){
|
||||||
return ((ITemplateSymbol)look).getTemplatedSymbol();
|
return ((ITemplateSymbol)look).getTemplatedSymbol();
|
||||||
} else {
|
}
|
||||||
return look;
|
return look;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -530,8 +527,7 @@ public class TemplateFactory extends ExtensibleSymbol implements ITemplateFactor
|
||||||
|
|
||||||
if( !tIter.hasNext() )
|
if( !tIter.hasNext() )
|
||||||
return null;
|
return null;
|
||||||
else
|
return (ITemplateSymbol) tIter.next();
|
||||||
return (ITemplateSymbol) tIter.next();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -139,23 +139,22 @@ public class TemplateSymbol extends ParameterizedSymbol implements ITemplateSymb
|
||||||
IContainerSymbol instance = findInstantiation( actualArgs );
|
IContainerSymbol instance = findInstantiation( actualArgs );
|
||||||
if( instance != null ){
|
if( instance != null ){
|
||||||
return instance;
|
return instance;
|
||||||
} else {
|
}
|
||||||
if( template.isType( TypeInfo.t_templateParameter ) ){
|
if( template.isType( TypeInfo.t_templateParameter ) ){
|
||||||
//template template parameter. must defer instantiation
|
//template template parameter. must defer instantiation
|
||||||
return deferredInstance( arguments );
|
return deferredInstance( arguments );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IContainerSymbol symbol = template.getTemplatedSymbol();
|
||||||
|
ISymbol temp = TemplateEngine.checkForTemplateExplicitSpecialization( template, symbol, actualArgs );
|
||||||
|
symbol = (IContainerSymbol) ( temp != null ? temp : symbol);
|
||||||
|
|
||||||
IContainerSymbol symbol = template.getTemplatedSymbol();
|
instance = (IContainerSymbol) symbol.instantiate( template, map );
|
||||||
ISymbol temp = TemplateEngine.checkForTemplateExplicitSpecialization( template, symbol, actualArgs );
|
addInstantiation( instance, actualArgs );
|
||||||
symbol = (IContainerSymbol) ( temp != null ? temp : symbol);
|
|
||||||
|
processDeferredInstantiations();
|
||||||
instance = (IContainerSymbol) symbol.instantiate( template, map );
|
|
||||||
addInstantiation( instance, actualArgs );
|
return instance;
|
||||||
|
|
||||||
processDeferredInstantiations();
|
|
||||||
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ISymbol instantiate( ITemplateSymbol template, Map argMap ) throws ParserSymbolTableException{
|
public ISymbol instantiate( ITemplateSymbol template, Map argMap ) throws ParserSymbolTableException{
|
||||||
|
|
|
@ -75,18 +75,16 @@ public class TypeFilter {
|
||||||
( acceptedKinds.contains( LookupKind.METHODS ) && symbolIsMember ) )
|
( acceptedKinds.contains( LookupKind.METHODS ) && symbolIsMember ) )
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
} else {
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if ( typeInfo.isType( TypeInfo.t_type ) && typeInfo.checkBit( TypeInfo.isTypedef ) ){
|
else if ( typeInfo.isType( TypeInfo.t_type ) && typeInfo.checkBit( TypeInfo.isTypedef ) ){
|
||||||
if( acceptedKinds.contains( LookupKind.TYPEDEFS ) ||
|
if( acceptedKinds.contains( LookupKind.TYPEDEFS ) ||
|
||||||
acceptedKinds.contains( LookupKind.TYPES ) )
|
acceptedKinds.contains( LookupKind.TYPES ) )
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
} else {
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if ( typeInfo.isType( TypeInfo.t_type ) || typeInfo.isType( TypeInfo.t__Bool, TypeInfo.t_void ) )
|
else if ( typeInfo.isType( TypeInfo.t_type ) || typeInfo.isType( TypeInfo.t__Bool, TypeInfo.t_void ) )
|
||||||
{
|
{
|
||||||
|
@ -95,9 +93,8 @@ public class TypeFilter {
|
||||||
( acceptedKinds.contains( LookupKind.FIELDS ) && symbolIsMember ) )
|
( acceptedKinds.contains( LookupKind.FIELDS ) && symbolIsMember ) )
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
} else {
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -307,9 +307,8 @@ public class TypeInfo {
|
||||||
//upperType of 0 means no range
|
//upperType of 0 means no range
|
||||||
if( upperType == TypeInfo.t_undef ){
|
if( upperType == TypeInfo.t_undef ){
|
||||||
return ( getType() == type );
|
return ( getType() == type );
|
||||||
} else {
|
}
|
||||||
return ( getType().compareTo( type ) >= 0 && getType().compareTo( upperType ) <= 0 );
|
return ( getType().compareTo( type ) >= 0 && getType().compareTo( upperType ) <= 0 );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ISymbol getTypeSymbol(){
|
public ISymbol getTypeSymbol(){
|
||||||
|
@ -450,10 +449,9 @@ public class TypeInfo {
|
||||||
public boolean canHold( TypeInfo type ){
|
public boolean canHold( TypeInfo type ){
|
||||||
if( getType().compareTo( type.getType()) > 0 ){
|
if( getType().compareTo( type.getType()) > 0 ){
|
||||||
return true;
|
return true;
|
||||||
} else {
|
}
|
||||||
int mask = TypeInfo.isShort | TypeInfo.isLong | TypeInfo.isLongLong;
|
int mask = TypeInfo.isShort | TypeInfo.isLong | TypeInfo.isLongLong;
|
||||||
return ( getTypeInfo() & mask ) >= ( type.getTypeInfo() & mask );
|
return ( getTypeInfo() & mask ) >= ( type.getTypeInfo() & mask );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals( Object t ){
|
public boolean equals( Object t ){
|
||||||
|
@ -528,9 +526,8 @@ public class TypeInfo {
|
||||||
public String toString(){
|
public String toString(){
|
||||||
if( isType( TypeInfo.t_type ) ){
|
if( isType( TypeInfo.t_type ) ){
|
||||||
return _typeDeclaration.getName();
|
return _typeDeclaration.getName();
|
||||||
} else {
|
}
|
||||||
return TypeInfo._image[ getType().toInt() ];
|
return TypeInfo._image[ getType().toInt() ];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int _typeInfo = 0;
|
private int _typeInfo = 0;
|
||||||
|
|
|
@ -2948,7 +2948,7 @@ public class Scanner implements IScanner {
|
||||||
scannerExtension );
|
scannerExtension );
|
||||||
tokenizer.setThrowExceptionOnBadCharacterRead(false);
|
tokenizer.setThrowExceptionOnBadCharacterRead(false);
|
||||||
IToken t = null;
|
IToken t = null;
|
||||||
StringBuffer strbuff = new StringBuffer();
|
StringBuffer strBuff2 = new StringBuffer();
|
||||||
boolean space = false;
|
boolean space = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -2961,26 +2961,26 @@ public class Scanner implements IScanner {
|
||||||
t = (forStringizing ? tokenizer.nextTokenForStringizing() : tokenizer.nextToken(false));
|
t = (forStringizing ? tokenizer.nextTokenForStringizing() : tokenizer.nextToken(false));
|
||||||
|
|
||||||
if (space)
|
if (space)
|
||||||
strbuff.append( ' ' );
|
strBuff2.append( ' ' );
|
||||||
|
|
||||||
switch (t.getType()) {
|
switch (t.getType()) {
|
||||||
case IToken.tSTRING :
|
case IToken.tSTRING :
|
||||||
strbuff.append('\"');
|
strBuff2.append('\"');
|
||||||
strbuff.append(t.getImage());
|
strBuff2.append(t.getImage());
|
||||||
strbuff.append('\"');
|
strBuff2.append('\"');
|
||||||
break;
|
break;
|
||||||
case IToken.tLSTRING :
|
case IToken.tLSTRING :
|
||||||
strbuff.append( "L\""); //$NON-NLS-1$
|
strBuff2.append( "L\""); //$NON-NLS-1$
|
||||||
strbuff.append(t.getImage());
|
strBuff2.append(t.getImage());
|
||||||
strbuff.append('\"');
|
strBuff2.append('\"');
|
||||||
break;
|
break;
|
||||||
case IToken.tCHAR :
|
case IToken.tCHAR :
|
||||||
strbuff.append('\'');
|
strBuff2.append('\'');
|
||||||
strbuff.append(t.getImage());
|
strBuff2.append(t.getImage());
|
||||||
strbuff.append('\'');
|
strBuff2.append('\'');
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
strbuff.append( t.getImage());
|
strBuff2.append( t.getImage());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
space = true;
|
space = true;
|
||||||
|
@ -2988,7 +2988,7 @@ public class Scanner implements IScanner {
|
||||||
}
|
}
|
||||||
catch (EndOfFileException e) {
|
catch (EndOfFileException e) {
|
||||||
// Good
|
// Good
|
||||||
parameterValues.add(strbuff.toString());
|
parameterValues.add(strBuff2.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ public class ScannerStringBuffer {
|
||||||
public ScannerStringBuffer(int initialSize) {
|
public ScannerStringBuffer(int initialSize) {
|
||||||
current_size = initialSize;
|
current_size = initialSize;
|
||||||
s_buff = new char[current_size];
|
s_buff = new char[current_size];
|
||||||
int s_pos = 0;
|
s_pos = 0;
|
||||||
}
|
}
|
||||||
public final void startString(){
|
public final void startString(){
|
||||||
s_pos = 0;
|
s_pos = 0;
|
||||||
|
|
|
@ -10,13 +10,17 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser.token;
|
package org.eclipse.cdt.internal.core.parser.token;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.IToken;
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
|
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author johnc
|
* @author johnc
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractToken implements IToken {
|
public abstract class AbstractToken implements IToken, ITokenDuple {
|
||||||
|
|
||||||
public AbstractToken( int type, int lineNumber )
|
public AbstractToken( int type, int lineNumber )
|
||||||
{
|
{
|
||||||
|
@ -30,7 +34,7 @@ public abstract class AbstractToken implements IToken {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Token=" + getType() + " \"" + getImage() + " @ line:" + getLineNumber() + " offset=" + getOffset(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
return getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract String getImage();
|
public abstract String getImage();
|
||||||
|
@ -52,6 +56,7 @@ public abstract class AbstractToken implements IToken {
|
||||||
protected int type;
|
protected int type;
|
||||||
protected int lineNumber = 1;
|
protected int lineNumber = 1;
|
||||||
protected IToken next = null;
|
protected IToken next = null;
|
||||||
|
private String [] qualifiedName = null;
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see java.lang.Object#equals(java.lang.Object)
|
* @see java.lang.Object#equals(java.lang.Object)
|
||||||
|
@ -167,4 +172,149 @@ public abstract class AbstractToken implements IToken {
|
||||||
public final IToken getNext() { return next; }
|
public final IToken getNext() { return next; }
|
||||||
public void setNext(IToken t) { next = t; }
|
public void setNext(IToken t) { next = t; }
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ITokenDuple#consumeTemplateIdArguments(org.eclipse.cdt.core.parser.IToken, java.util.Iterator)
|
||||||
|
*/
|
||||||
|
public IToken consumeTemplateIdArguments(IToken name, Iterator iter) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ITokenDuple#contains(org.eclipse.cdt.core.parser.ITokenDuple)
|
||||||
|
*/
|
||||||
|
public boolean contains(ITokenDuple duple) {
|
||||||
|
return ( duple.getFirstToken() == duple.getLastToken() ) && ( duple.getFirstToken() == this );
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ITokenDuple#extractNameFromTemplateId()
|
||||||
|
*/
|
||||||
|
public String extractNameFromTemplateId(){
|
||||||
|
return getImage();
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ITokenDuple#findLastTokenType(int)
|
||||||
|
*/
|
||||||
|
public int findLastTokenType(int t) {
|
||||||
|
if( getType() == t ) return 0;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ITokenDuple#getFirstToken()
|
||||||
|
*/
|
||||||
|
public IToken getFirstToken() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ITokenDuple#getLastSegment()
|
||||||
|
*/
|
||||||
|
public ITokenDuple getLastSegment() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ITokenDuple#getLastToken()
|
||||||
|
*/
|
||||||
|
public IToken getLastToken() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ITokenDuple#getLeadingSegments()
|
||||||
|
*/
|
||||||
|
public ITokenDuple getLeadingSegments() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ITokenDuple#getSegmentCount()
|
||||||
|
*/
|
||||||
|
public int getSegmentCount() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ITokenDuple#getStartOffset()
|
||||||
|
*/
|
||||||
|
public int getStartOffset() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ITokenDuple#getSubrange(int, int)
|
||||||
|
*/
|
||||||
|
public ITokenDuple getSubrange(int startIndex, int endIndex) {
|
||||||
|
if( startIndex == 0 && endIndex == 0 ) return this;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ITokenDuple#getTemplateIdArgLists()
|
||||||
|
*/
|
||||||
|
public List[] getTemplateIdArgLists() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ITokenDuple#getToken(int)
|
||||||
|
*/
|
||||||
|
public IToken getToken(int index) {
|
||||||
|
if( index == 0 ) return this;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ITokenDuple#isIdentifier()
|
||||||
|
*/
|
||||||
|
public boolean isIdentifier() {
|
||||||
|
return ( getType() == IToken.tIDENTIFIER );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private class SingleIterator implements Iterator
|
||||||
|
{
|
||||||
|
boolean hasNext = true;
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.util.Iterator#remove()
|
||||||
|
*/
|
||||||
|
public void remove() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.util.Iterator#hasNext()
|
||||||
|
*/
|
||||||
|
public boolean hasNext() {
|
||||||
|
return hasNext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.util.Iterator#next()
|
||||||
|
*/
|
||||||
|
public Object next() {
|
||||||
|
hasNext = false;
|
||||||
|
return AbstractToken.this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ITokenDuple#iterator()
|
||||||
|
*/
|
||||||
|
public Iterator iterator() {
|
||||||
|
return new SingleIterator();
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ITokenDuple#length()
|
||||||
|
*/
|
||||||
|
public int length() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ITokenDuple#syntaxOfName()
|
||||||
|
*/
|
||||||
|
public boolean syntaxOfName() {
|
||||||
|
return ( getType() == IToken.tIDENTIFIER );
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ITokenDuple#toQualifiedName()
|
||||||
|
*/
|
||||||
|
public String[] toQualifiedName() {
|
||||||
|
if( qualifiedName == null )
|
||||||
|
{
|
||||||
|
qualifiedName = new String[1];
|
||||||
|
qualifiedName[0] = getImage();
|
||||||
|
}
|
||||||
|
return qualifiedName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||||
*/
|
*/
|
||||||
public class TokenDuple implements ITokenDuple {
|
public class TokenDuple implements ITokenDuple {
|
||||||
|
|
||||||
public TokenDuple( IToken first, IToken last )
|
TokenDuple( IToken first, IToken last )
|
||||||
{
|
{
|
||||||
// assert ( first != null && last != null ) : this;
|
// assert ( first != null && last != null ) : this;
|
||||||
firstToken = first;
|
firstToken = first;
|
||||||
|
@ -33,7 +33,7 @@ public class TokenDuple implements ITokenDuple {
|
||||||
argLists = null;
|
argLists = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TokenDuple( IToken first, IToken last, List templateArgLists ){
|
TokenDuple( IToken first, IToken last, List templateArgLists ){
|
||||||
firstToken = first;
|
firstToken = first;
|
||||||
lastToken = last;
|
lastToken = last;
|
||||||
if( templateArgLists != null && !templateArgLists.isEmpty() ){
|
if( templateArgLists != null && !templateArgLists.isEmpty() ){
|
||||||
|
@ -43,7 +43,7 @@ public class TokenDuple implements ITokenDuple {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public TokenDuple( ITokenDuple firstDuple, ITokenDuple secondDuple ){
|
TokenDuple( ITokenDuple firstDuple, ITokenDuple secondDuple ){
|
||||||
firstToken = firstDuple.getFirstToken();
|
firstToken = firstDuple.getFirstToken();
|
||||||
lastToken = secondDuple.getLastToken();
|
lastToken = secondDuple.getLastToken();
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,10 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser.token;
|
package org.eclipse.cdt.internal.core.parser.token;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.IToken;
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
|
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||||
import org.eclipse.cdt.internal.core.parser.scanner.IScannerContext;
|
import org.eclipse.cdt.internal.core.parser.scanner.IScannerContext;
|
||||||
import org.eclipse.cdt.internal.core.parser.scanner.IScannerData;
|
import org.eclipse.cdt.internal.core.parser.scanner.IScannerData;
|
||||||
|
|
||||||
|
@ -49,4 +52,20 @@ public class TokenFactory {
|
||||||
{
|
{
|
||||||
return new ImagedToken( type, image);
|
return new ImagedToken( type, image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ITokenDuple createTokenDuple( IToken first, IToken last )
|
||||||
|
{
|
||||||
|
if( (first == last) && ( first instanceof ITokenDuple )) return (ITokenDuple) first;
|
||||||
|
return new TokenDuple( first, last );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ITokenDuple createTokenDuple( IToken first, IToken last, List templateArgLists )
|
||||||
|
{
|
||||||
|
if( (first == last) && ( templateArgLists == null ) && ( first instanceof ITokenDuple )) return (ITokenDuple) first;
|
||||||
|
return new TokenDuple( first, last, templateArgLists );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ITokenDuple createTokenDuple( ITokenDuple firstDuple, ITokenDuple secondDuple ){
|
||||||
|
return new TokenDuple( firstDuple, secondDuple );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue