1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 14:55:41 +02:00

small change to help performance

This commit is contained in:
Andrew Niefer 2005-03-01 21:42:46 +00:00
parent b7dffd1646
commit 97e4969629

View file

@ -123,7 +123,8 @@ public class CPPSemantics {
public boolean forUserDefinedConversion = false; public boolean forUserDefinedConversion = false;
public boolean forAssociatedScopes = false; public boolean forAssociatedScopes = false;
public boolean prefixLookup = false; public boolean prefixLookup = false;
public boolean typesOnly = false;
public boolean considerConstructors = false;
public Object foundItems = null; public Object foundItems = null;
public Object [] functionParameters; public Object [] functionParameters;
public ProblemBinding problem; public ProblemBinding problem;
@ -132,6 +133,8 @@ public class CPPSemantics {
public LookupData( IASTName n ){ public LookupData( IASTName n ){
astName = n; astName = n;
this.name = n.toCharArray(); this.name = n.toCharArray();
typesOnly = typesOnly();
considerConstructors = considerConstructors();
} }
public LookupData( char [] n ){ public LookupData( char [] n ){
astName = null; astName = null;
@ -146,7 +149,7 @@ public class CPPSemantics {
} }
return false; return false;
} }
public boolean typesOnly(){ private boolean typesOnly(){
if( astName == null ) return false; if( astName == null ) return false;
IASTNode parent = astName.getParent(); IASTNode parent = astName.getParent();
if( parent instanceof ICPPASTBaseSpecifier || parent instanceof ICPPASTElaboratedTypeSpecifier || if( parent instanceof ICPPASTBaseSpecifier || parent instanceof ICPPASTElaboratedTypeSpecifier ||
@ -182,7 +185,7 @@ public class CPPSemantics {
( p1 instanceof IASTDeclarator && p2 instanceof IASTSimpleDeclaration) || ( p1 instanceof IASTDeclarator && p2 instanceof IASTSimpleDeclaration) ||
( p1 instanceof IASTDeclarator && p2 instanceof IASTFunctionDefinition)); ( p1 instanceof IASTDeclarator && p2 instanceof IASTFunctionDefinition));
} }
public boolean considerConstructors(){ private boolean considerConstructors(){
if( astName == null ) return false; if( astName == null ) return false;
IASTNode p1 = astName.getParent(); IASTNode p1 = astName.getParent();
IASTNode p2 = p1.getParent(); IASTNode p2 = p1.getParent();
@ -427,7 +430,7 @@ public class CPPSemantics {
} }
} }
if( binding instanceof ICPPClassType && data.considerConstructors() ){ if( binding instanceof ICPPClassType && data.considerConstructors ){
ICPPClassType cls = (ICPPClassType) binding; ICPPClassType cls = (ICPPClassType) binding;
try { try {
//force resolution of constructor bindings //force resolution of constructor bindings
@ -1040,7 +1043,7 @@ public class CPPSemantics {
declaration = ((IASTDeclarationStatement)node).getDeclaration(); declaration = ((IASTDeclarationStatement)node).getDeclaration();
else if( node instanceof IASTForStatement && checkAux ) else if( node instanceof IASTForStatement && checkAux )
declaration = ((IASTForStatement)node).getInitDeclaration(); declaration = ((IASTForStatement)node).getInitDeclaration();
else if( node instanceof IASTParameterDeclaration && !data.typesOnly() ){ else if( node instanceof IASTParameterDeclaration && !data.typesOnly ){
IASTParameterDeclaration parameterDeclaration = (IASTParameterDeclaration) node; IASTParameterDeclaration parameterDeclaration = (IASTParameterDeclaration) node;
IASTDeclarator dtor = parameterDeclaration.getDeclarator(); IASTDeclarator dtor = parameterDeclaration.getDeclarator();
while( dtor.getNestedDeclarator() != null ) while( dtor.getNestedDeclarator() != null )
@ -1055,13 +1058,13 @@ public class CPPSemantics {
if( declaration instanceof IASTSimpleDeclaration ){ if( declaration instanceof IASTSimpleDeclaration ){
IASTSimpleDeclaration simpleDeclaration = (IASTSimpleDeclaration) declaration; IASTSimpleDeclaration simpleDeclaration = (IASTSimpleDeclaration) declaration;
if( !data.typesOnly() || simpleDeclaration.getDeclSpecifier().getStorageClass() == IASTDeclSpecifier.sc_typedef ) { if( !data.typesOnly || simpleDeclaration.getDeclSpecifier().getStorageClass() == IASTDeclSpecifier.sc_typedef ) {
IASTDeclarator [] declarators = simpleDeclaration.getDeclarators(); IASTDeclarator [] declarators = simpleDeclaration.getDeclarators();
for( int i = 0; i < declarators.length; i++ ){ for( int i = 0; i < declarators.length; i++ ){
IASTDeclarator declarator = declarators[i]; IASTDeclarator declarator = declarators[i];
while( declarator.getNestedDeclarator() != null ) while( declarator.getNestedDeclarator() != null )
declarator = declarator.getNestedDeclarator(); declarator = declarator.getNestedDeclarator();
if( data.considerConstructors() || !CPPVisitor.isConstructor( scope, declarator ) ){ if( data.considerConstructors || !CPPVisitor.isConstructor( scope, declarator ) ){
IASTName declaratorName = declarator.getName(); IASTName declaratorName = declarator.getName();
if( nameMatches( data, declaratorName.toCharArray() ) ) { if( nameMatches( data, declaratorName.toCharArray() ) ) {
return declaratorName; return declaratorName;
@ -1088,7 +1091,7 @@ public class CPPSemantics {
if( nameMatches( data, eName.toCharArray() ) ) { if( nameMatches( data, eName.toCharArray() ) ) {
return eName; return eName;
} }
if( !data.typesOnly() ) { if( !data.typesOnly ) {
//check enumerators too //check enumerators too
IASTEnumerator [] list = enumeration.getEnumerators(); IASTEnumerator [] list = enumeration.getEnumerators();
for( int i = 0; i < list.length; i++ ) { for( int i = 0; i < list.length; i++ ) {
@ -1121,7 +1124,7 @@ public class CPPSemantics {
return alias; return alias;
} }
if( data.typesOnly() ) if( data.typesOnly )
return null; return null;
if( declaration instanceof IASTFunctionDefinition ){ if( declaration instanceof IASTFunctionDefinition ){
@ -1130,7 +1133,7 @@ public class CPPSemantics {
//check the function itself //check the function itself
IASTName declName = declarator.getName(); IASTName declName = declarator.getName();
if( data.considerConstructors() || !CPPVisitor.isConstructor( scope, declarator ) ){ if( data.considerConstructors || !CPPVisitor.isConstructor( scope, declarator ) ){
if( nameMatches( data, declName.toCharArray() ) ) { if( nameMatches( data, declName.toCharArray() ) ) {
return declName; return declName;
} }
@ -1296,7 +1299,7 @@ public class CPPSemantics {
} }
if( type != null ) { if( type != null ) {
if( data.typesOnly() || (obj == null && fns == null) ) if( data.typesOnly || (obj == null && fns == null) )
return type; return type;
// IScope typeScope = type.getScope(); // IScope typeScope = type.getScope();
// if( obj != null && obj.getScope() != typeScope ){ // if( obj != null && obj.getScope() != typeScope ){