1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-15 21:15:23 +02:00

Fixed spelling of reverseConstantPropagationLookup (245053).

This commit is contained in:
Sergey Prigogin 2008-08-25 01:14:00 +00:00
parent e9629b194e
commit b4981a7e62
4 changed files with 60 additions and 58 deletions

View file

@ -189,7 +189,7 @@ public class CPPTemplates {
*/ */
private static IBinding instantiateSelectedTemplate(ICPPTemplateDefinition template, IType[] arguments) private static IBinding instantiateSelectedTemplate(ICPPTemplateDefinition template, IType[] arguments)
throws DOMException { throws DOMException {
Assert.isTrue(template instanceof ICPPClassTemplatePartialSpecialization == false); Assert.isTrue(!(template instanceof ICPPClassTemplatePartialSpecialization));
ICPPTemplateParameter[] parameters= template.getTemplateParameters(); ICPPTemplateParameter[] parameters= template.getTemplateParameters();
if (parameters == null || parameters.length == 0) if (parameters == null || parameters.length == 0)
@ -262,7 +262,7 @@ public class CPPTemplates {
// we do not correctly distinguish between type and non-type parameters, this works // we do not correctly distinguish between type and non-type parameters, this works
// around getting the wrong instance when providing a value rather than a type. // around getting the wrong instance when providing a value rather than a type.
if (instance != null) { if (instance != null) {
if (argsContainDependentType || instance instanceof ICPPDeferredClassInstance == false) if (argsContainDependentType || !(instance instanceof ICPPDeferredClassInstance))
return instance; return instance;
} }
@ -1007,8 +1007,8 @@ public class CPPTemplates {
parent = parent.getParent(); parent = parent.getParent();
} }
if (parent instanceof IASTDeclSpecifier) { if (parent instanceof IASTDeclSpecifier) {
if (parent instanceof IASTCompositeTypeSpecifier == false if (!(parent instanceof IASTCompositeTypeSpecifier) &&
&& parent instanceof IASTElaboratedTypeSpecifier == false) { !(parent instanceof IASTElaboratedTypeSpecifier)) {
return null; return null;
} }
parent = parent.getParent(); parent = parent.getParent();
@ -1017,7 +1017,7 @@ public class CPPTemplates {
parent = parent.getParent(); parent = parent.getParent();
} }
} }
if (parent instanceof IASTDeclaration == false) { if (!(parent instanceof IASTDeclaration)) {
return null; return null;
} }
@ -1282,7 +1282,7 @@ public class CPPTemplates {
* will include its value) * will include its value)
*/ */
if (param instanceof IASTIdExpression) { if (param instanceof IASTIdExpression) {
param= CPPVisitor.reverseConstantPropogationLookup((IASTIdExpression)param); param= CPPVisitor.reverseConstantPropagationLookup((IASTIdExpression)param);
} }
IType type= CPPVisitor.createType(param); IType type= CPPVisitor.createType(param);
@ -1523,8 +1523,8 @@ public class CPPTemplates {
if (e1 == null) if (e1 == null)
return true; return true;
e1= CPPVisitor.reverseConstantPropogationLookup(e1); e1= CPPVisitor.reverseConstantPropagationLookup(e1);
e2= CPPVisitor.reverseConstantPropogationLookup(e2); e2= CPPVisitor.reverseConstantPropagationLookup(e2);
if (e1 instanceof IASTLiteralExpression && e2 instanceof IASTLiteralExpression) { if (e1 instanceof IASTLiteralExpression && e2 instanceof IASTLiteralExpression) {
IType t1= e1.getExpressionType(); IType t1= e1.getExpressionType();
@ -1887,7 +1887,8 @@ public class CPPTemplates {
return !(argument instanceof IProblemBinding); return !(argument instanceof IProblemBinding);
} }
static protected boolean matchTemplateParameterAndArgument(ICPPTemplateParameter param, IType argument, ObjectMap map) { static protected boolean matchTemplateParameterAndArgument(ICPPTemplateParameter param, IType argument,
ObjectMap map) {
if (!isValidArgument(param, argument)) { if (!isValidArgument(param, argument)) {
return false; return false;
} }
@ -1897,7 +1898,8 @@ public class CPPTemplates {
if (!(argument instanceof ICPPTemplateDefinition)) if (!(argument instanceof ICPPTemplateDefinition))
return false; return false;
ICPPTemplateParameter[] pParams = null, aParams = null; ICPPTemplateParameter[] pParams = null;
ICPPTemplateParameter[] aParams = null;
try { try {
pParams = ((ICPPTemplateTemplateParameter) param).getTemplateParameters(); pParams = ((ICPPTemplateTemplateParameter) param).getTemplateParameters();
aParams = ((ICPPTemplateDefinition) argument).getTemplateParameters(); aParams = ((ICPPTemplateDefinition) argument).getTemplateParameters();

View file

@ -567,7 +567,7 @@ public class CPPVisitor {
if (parent instanceof IASTStandardFunctionDeclarator) { if (parent instanceof IASTStandardFunctionDeclarator) {
IASTStandardFunctionDeclarator fdtor = (IASTStandardFunctionDeclarator) param.getParent(); IASTStandardFunctionDeclarator fdtor = (IASTStandardFunctionDeclarator) param.getParent();
// if the fdtor does not declare a function we don't create a binding for the parameter. // if the fdtor does not declare a function we don't create a binding for the parameter.
if (findOutermostDeclarator(fdtor).getParent() instanceof IASTDeclaration == false || if (!(findOutermostDeclarator(fdtor).getParent() instanceof IASTDeclaration) ||
findTypeRelevantDeclarator(fdtor) != fdtor) findTypeRelevantDeclarator(fdtor) != fdtor)
return null; return null;
IBinding temp = findInnermostDeclarator(fdtor).getName().resolveBinding(); IBinding temp = findInnermostDeclarator(fdtor).getName().resolveBinding();
@ -779,7 +779,7 @@ public class CPPVisitor {
} else if (node instanceof IASTTypeId) { } else if (node instanceof IASTTypeId) {
if (node.getPropertyInParent() == ICPPASTTemplateId.TEMPLATE_ID_ARGUMENT) { if (node.getPropertyInParent() == ICPPASTTemplateId.TEMPLATE_ID_ARGUMENT) {
node= node.getParent(); // template-id node= node.getParent(); // template-id
while(node instanceof IASTName) { while (node instanceof IASTName) {
node= node.getParent(); node= node.getParent();
} }
continue; continue;
@ -1540,9 +1540,9 @@ public class CPPVisitor {
IScope scope = fnDtor.getFunctionScope(); IScope scope = fnDtor.getFunctionScope();
IType thisType= getThisType(scope); IType thisType= getThisType(scope);
IASTDeclarator nested = fnDtor.getNestedDeclarator(); IASTDeclarator nested = fnDtor.getNestedDeclarator();
if(thisType == null && nested != null) { if (thisType == null && nested != null) {
IType pts= getPointerTypes(new CPPBasicType(-1,-1), nested); IType pts= getPointerTypes(new CPPBasicType(-1,-1), nested);
if(pts instanceof ICPPPointerToMemberType) { if (pts instanceof ICPPPointerToMemberType) {
thisType= new CPPPointerType(((ICPPPointerToMemberType)pts).getMemberOfClass()); thisType= new CPPPointerType(((ICPPPointerToMemberType)pts).getMemberOfClass());
} }
} }
@ -1582,9 +1582,9 @@ public class CPPVisitor {
// Currently, CPPBasicType objects are also used to represent non-type template argument // Currently, CPPBasicType objects are also used to represent non-type template argument
// values. We must ensure the initializer expression is attached to the type if available. // values. We must ensure the initializer expression is attached to the type if available.
if(declarator.getInitializer() instanceof IASTInitializerExpression) { if (declarator.getInitializer() instanceof IASTInitializerExpression) {
IType utype= getUltimateTypeUptoPointers(baseType); IType utype= getUltimateTypeUptoPointers(baseType);
if(utype instanceof CPPBasicType) { if (utype instanceof CPPBasicType) {
((CPPBasicType)utype).setValue(((IASTInitializerExpression) declarator.getInitializer()).getExpression()); ((CPPBasicType)utype).setValue(((IASTInitializerExpression) declarator.getInitializer()).getExpression());
} }
} }
@ -1801,11 +1801,11 @@ public class CPPVisitor {
} else if (expression instanceof ICPPASTLiteralExpression) { } else if (expression instanceof ICPPASTLiteralExpression) {
ICPPASTLiteralExpression lit= (ICPPASTLiteralExpression) expression; ICPPASTLiteralExpression lit= (ICPPASTLiteralExpression) expression;
switch(lit.getKind()) { switch(lit.getKind()) {
case ICPPASTLiteralExpression.lk_this : { case ICPPASTLiteralExpression.lk_this: {
IScope scope = getContainingScope(expression); IScope scope = getContainingScope(expression);
return getThisType(scope); return getThisType(scope);
} }
case ICPPASTLiteralExpression.lk_true : case ICPPASTLiteralExpression.lk_true:
case ICPPASTLiteralExpression.lk_false: case ICPPASTLiteralExpression.lk_false:
return new CPPBasicType(ICPPBasicType.t_bool, 0, expression); return new CPPBasicType(ICPPBasicType.t_bool, 0, expression);
case IASTLiteralExpression.lk_char_constant: case IASTLiteralExpression.lk_char_constant:
@ -1836,7 +1836,7 @@ public class CPPVisitor {
} else if (binding instanceof IFunction) { } else if (binding instanceof IFunction) {
IFunctionType fType; IFunctionType fType;
try { try {
fType = ((IFunction)binding).getType(); fType = ((IFunction) binding).getType();
if (fType != null) if (fType != null)
return fType.getReturnType(); return fType.getReturnType();
} catch (DOMException e) { } catch (DOMException e) {
@ -1844,12 +1844,12 @@ public class CPPVisitor {
} }
} else if (binding instanceof IVariable) { } else if (binding instanceof IVariable) {
try { try {
IType t = ((IVariable)binding).getType(); IType t = ((IVariable) binding).getType();
while (t instanceof ITypedef) { while (t instanceof ITypedef) {
t = ((ITypedef)t).getType(); t = ((ITypedef)t).getType();
} }
if (t instanceof IPointerType && ((IPointerType)t).getType() instanceof IFunctionType) { if (t instanceof IPointerType && ((IPointerType) t).getType() instanceof IFunctionType) {
IFunctionType ftype = (IFunctionType) ((IPointerType)t).getType(); IFunctionType ftype = (IFunctionType) ((IPointerType) t).getType();
if (ftype != null) if (ftype != null)
return ftype.getReturnType(); return ftype.getReturnType();
} }
@ -1865,11 +1865,11 @@ public class CPPVisitor {
} }
} else if (binding instanceof ITypedef) { } else if (binding instanceof ITypedef) {
try { try {
IType type = ((ITypedef)binding).getType(); IType type = ((ITypedef) binding).getType();
while (type instanceof ITypedef) while (type instanceof ITypedef)
type = ((ITypedef)type).getType(); type = ((ITypedef) type).getType();
if (type instanceof IFunctionType) { if (type instanceof IFunctionType) {
return ((IFunctionType)type).getReturnType(); return ((IFunctionType) type).getReturnType();
} }
return type; return type;
} catch (DOMException e) { } catch (DOMException e) {
@ -2166,7 +2166,6 @@ public class CPPVisitor {
public static IASTProblem[] getProblems(IASTTranslationUnit tu) { public static IASTProblem[] getProblems(IASTTranslationUnit tu) {
CollectProblemsAction action = new CollectProblemsAction(); CollectProblemsAction action = new CollectProblemsAction();
tu.accept(action); tu.accept(action);
return action.getProblems(); return action.getProblems();
} }
@ -2182,9 +2181,9 @@ public class CPPVisitor {
IASTName[] found = action.getDeclarations(); IASTName[] found = action.getDeclarations();
if (found.length == 0 && binding instanceof ICPPSpecialization && binding instanceof ICPPInternalBinding) { if (found.length == 0 && binding instanceof ICPPSpecialization && binding instanceof ICPPInternalBinding) {
IASTNode node = ((ICPPInternalBinding)binding).getDefinition(); IASTNode node = ((ICPPInternalBinding) binding).getDefinition();
if (node == null) { if (node == null) {
IASTNode[] nds = ((ICPPInternalBinding)binding).getDeclarations(); IASTNode[] nds = ((ICPPInternalBinding) binding).getDeclarations();
if (nds != null && nds.length > 0) if (nds != null && nds.length > 0)
node = nds[0]; node = nds[0];
} }
@ -2312,7 +2311,7 @@ public class CPPVisitor {
IASTIdExpression ide= (IASTIdExpression) fne; IASTIdExpression ide= (IASTIdExpression) fne;
IBinding b= ide.getName().resolveBinding(); IBinding b= ide.getName().resolveBinding();
if (b instanceof IFunction) { if (b instanceof IFunction) {
IFunctionType tp= ((IFunction)b).getType(); IFunctionType tp= ((IFunction) b).getType();
return !(tp.getReturnType() instanceof ICPPReferenceType); return !(tp.getReturnType() instanceof ICPPReferenceType);
} }
} }
@ -2333,28 +2332,29 @@ public class CPPVisitor {
*/ */
public static BigInteger parseIntegral(String integral) { public static BigInteger parseIntegral(String integral) {
int radix= 10; int radix= 10;
if(integral.length() == 3 if (integral.length() == 3
&& integral.charAt(0) == '\'' && integral.charAt(0) == '\''
&& integral.charAt(2) == '\'') { && integral.charAt(2) == '\'') {
String lo= Long.toString(Character.getNumericValue(integral.charAt(1))); String lo= Long.toString(Character.getNumericValue(integral.charAt(1)));
return new BigInteger(lo); return new BigInteger(lo);
} else if(Keywords.TRUE.equals(integral)) { } else if (Keywords.TRUE.equals(integral)) {
return BigInteger.ONE; return BigInteger.ONE;
} else if(Keywords.FALSE.equals(integral)) { } else if (Keywords.FALSE.equals(integral)) {
return BigInteger.ZERO; return BigInteger.ZERO;
} }
int start=0, end= integral.length(); int start=0;
int end= integral.length();
boolean negate= integral.charAt(start)=='-'; boolean negate= integral.charAt(start) == '-';
if(negate || integral.charAt(start)=='+') { if (negate || integral.charAt(start) == '+') {
start++; start++;
} }
if(start<integral.length() && integral.charAt(start) == '0') { if (start < integral.length() && integral.charAt(start) == '0') {
if(start+1<integral.length()) { if (start + 1 < integral.length()) {
if(integral.charAt(start+1) == 'x') { if (integral.charAt(start + 1) == 'x') {
start+=2; start += 2;
radix= 16; radix= 16;
} else { } else {
radix= 8; radix= 8;
@ -2362,9 +2362,9 @@ public class CPPVisitor {
} }
} }
for(end--; end>0; end--) { for (end--; end > 0; end--) {
final char c= integral.charAt(end); final char c= integral.charAt(end);
if(c != 'L' && c!='l' && c!='U' && c!='u') { if (c != 'L' && c!='l' && c!='U' && c!='u') {
break; break;
} }
} }
@ -2379,25 +2379,25 @@ public class CPPVisitor {
* @param e1 * @param e1
* @return the first non id-expression by following values assigned to basic types. * @return the first non id-expression by following values assigned to basic types.
*/ */
public static final IASTExpression reverseConstantPropogationLookup(IASTExpression e1) { public static final IASTExpression reverseConstantPropagationLookup(IASTExpression e1) {
try { try {
for(int i=0; e1 instanceof IASTIdExpression && i<8; i++) { for(int i= 0; e1 instanceof IASTIdExpression && i < 8; i++) {
IBinding b1= ((IASTIdExpression)e1).getName().resolveBinding(); IBinding b1= ((IASTIdExpression)e1).getName().resolveBinding();
if(b1 instanceof ICPPVariable) { if (b1 instanceof ICPPVariable) {
ICPPVariable var= (ICPPVariable) b1; ICPPVariable var= (ICPPVariable) b1;
IType t1= SemanticUtil.getUltimateTypeViaTypedefs(var.getType()); IType t1= SemanticUtil.getUltimateTypeViaTypedefs(var.getType());
if(t1 instanceof IQualifierType) { if (t1 instanceof IQualifierType) {
IQualifierType qt= (IQualifierType) t1; IQualifierType qt= (IQualifierType) t1;
if(qt.isConst()) { if (qt.isConst()) {
t1= SemanticUtil.getUltimateTypeViaTypedefs(qt.getType()); t1= SemanticUtil.getUltimateTypeViaTypedefs(qt.getType());
if(t1 instanceof ICPPBasicType) { if (t1 instanceof ICPPBasicType) {
e1= ((ICPPBasicType)t1).getValue(); e1= ((ICPPBasicType) t1).getValue();
} }
} }
} }
} }
} }
} catch(DOMException de) { } catch (DOMException de) {
CCorePlugin.log(de); CCorePlugin.log(de);
} }
return e1; return e1;
@ -2410,7 +2410,7 @@ public class CPPVisitor {
public static IASTDeclarator findOutermostDeclarator(IASTDeclarator declarator) { public static IASTDeclarator findOutermostDeclarator(IASTDeclarator declarator) {
IASTDeclarator outermost= null; IASTDeclarator outermost= null;
IASTNode candidate= declarator; IASTNode candidate= declarator;
while(candidate instanceof IASTDeclarator) { while (candidate instanceof IASTDeclarator) {
outermost= (IASTDeclarator) candidate; outermost= (IASTDeclarator) candidate;
candidate= outermost.getParent(); candidate= outermost.getParent();
} }
@ -2423,7 +2423,7 @@ public class CPPVisitor {
*/ */
public static IASTDeclarator findInnermostDeclarator(IASTDeclarator declarator) { public static IASTDeclarator findInnermostDeclarator(IASTDeclarator declarator) {
IASTDeclarator innermost= null; IASTDeclarator innermost= null;
while(declarator != null) { while (declarator != null) {
innermost= declarator; innermost= declarator;
declarator= declarator.getNestedDeclarator(); declarator= declarator.getNestedDeclarator();
} }
@ -2436,9 +2436,9 @@ public class CPPVisitor {
public static IASTDeclarator findTypeRelevantDeclarator(IASTDeclarator declarator) { public static IASTDeclarator findTypeRelevantDeclarator(IASTDeclarator declarator) {
IASTDeclarator result= findInnermostDeclarator(declarator); IASTDeclarator result= findInnermostDeclarator(declarator);
while (result.getPointerOperators().length == 0 while (result.getPointerOperators().length == 0
&& result instanceof IASTFieldDeclarator == false && !(result instanceof IASTFieldDeclarator)
&& result instanceof IASTFunctionDeclarator == false && !(result instanceof IASTFunctionDeclarator)
&& result instanceof IASTArrayModifier == false) { && !(result instanceof IASTArrayModifier)) {
final IASTNode parent= result.getParent(); final IASTNode parent= result.getParent();
if (parent instanceof IASTDeclarator) { if (parent instanceof IASTDeclarator) {
result= (IASTDeclarator) parent; result= (IASTDeclarator) parent;
@ -2453,7 +2453,7 @@ public class CPPVisitor {
* Searches for the function enclosing the given node. May return <code>null</code>. * Searches for the function enclosing the given node. May return <code>null</code>.
*/ */
public static IBinding findEnclosingFunction(IASTNode node) { public static IBinding findEnclosingFunction(IASTNode node) {
while(node != null && node instanceof IASTFunctionDefinition == false) { while (node != null && !(node instanceof IASTFunctionDefinition)) {
node= node.getParent(); node= node.getParent();
} }
if (node == null) if (node == null)
@ -2490,7 +2490,7 @@ public class CPPVisitor {
*/ */
public static IBinding findDeclarationOwner(IASTNode node, boolean allowFunction) { public static IBinding findDeclarationOwner(IASTNode node, boolean allowFunction) {
// search for declaration // search for declaration
while (node instanceof IASTDeclaration == false) { while (!(node instanceof IASTDeclaration)) {
if (node == null) if (node == null)
return null; return null;

View file

@ -117,7 +117,7 @@ public class IndexCPPSignatureUtil {
} }
private static String getValueString(IASTExpression e) { private static String getValueString(IASTExpression e) {
e= CPPVisitor.reverseConstantPropogationLookup(e); e= CPPVisitor.reverseConstantPropagationLookup(e);
if (e instanceof IASTLiteralExpression) { if (e instanceof IASTLiteralExpression) {
IType t1= e.getExpressionType(); IType t1= e.getExpressionType();
try { try {

View file

@ -65,7 +65,7 @@ class PDOMCPPBasicType extends PDOMNode implements ICPPBasicType, IIndexType {
db.putShort(record + TYPE_ID, getTypeCode(type)); db.putShort(record + TYPE_ID, getTypeCode(type));
try { try {
if(type.getValue() != null) { if(type.getValue() != null) {
IASTExpression e= CPPVisitor.reverseConstantPropogationLookup(type.getValue()); IASTExpression e= CPPVisitor.reverseConstantPropagationLookup(type.getValue());
if(e != null) { if(e != null) {
db.putInt(record + INTEGRAL, CPPVisitor.parseIntegral(e.toString()).intValue()); db.putInt(record + INTEGRAL, CPPVisitor.parseIntegral(e.toString()).intValue());
db.putByte(record + INTERNAL_FLAGS, (byte)1); db.putByte(record + INTERNAL_FLAGS, (byte)1);