From 3b8da01c12ef8e1b6260d892389a4b9f5d7425a2 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Tue, 19 Apr 2016 19:10:53 -0700 Subject: [PATCH] Cosmetics. --- .../parser/cpp/semantics/FunctionCost.java | 80 +++++++++---------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/FunctionCost.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/FunctionCost.java index b894f44100c..22d1c0a4fe9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/FunctionCost.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/FunctionCost.java @@ -7,7 +7,7 @@ * * Contributors: * Markus Schorn - initial API and implementation - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates.TypeSelection.PARAMETERS; @@ -42,14 +42,14 @@ class FunctionCost { private final ValueCategory[] fValueCategories; private final IASTNode fPoint; private boolean fIsDirectCopyCtor; - + public FunctionCost(ICPPFunction fn, int paramCount, IASTNode point) { fFunction= fn; fCosts= new Cost[paramCount]; fValueCategories= new ValueCategory[paramCount]; fPoint = point; } - + public FunctionCost(ICPPFunction fn, Cost cost, IASTNode point) { fFunction= fn; fCosts= new Cost[] {cost}; @@ -60,11 +60,11 @@ class FunctionCost { public int getLength() { return fCosts.length; } - + public Cost getCost(int idx) { return fCosts[idx]; } - + public void setCost(int idx, Cost cost, ValueCategory valueCat) { fCosts[idx]= cost; fValueCategories[idx]= valueCat; @@ -73,7 +73,7 @@ class FunctionCost { public ICPPFunction getFunction() { return fFunction; } - + public boolean hasAmbiguousUserDefinedConversion() { for (Cost cost : fCosts) { if (cost.isAmbiguousUDC()) @@ -91,13 +91,13 @@ class FunctionCost { } return false; } - + public boolean performUDC(IASTNode point) throws DOMException { for (int i = 0; i < fCosts.length; i++) { Cost cost = fCosts[i]; Cost udcCost= null; switch (cost.isDeferredUDC()) { - case NONE: + case NONE: continue; case COPY_INIT_OF_CLASS: udcCost = Conversions.copyInitializationOfClass(fValueCategories[i], cost.source, @@ -109,12 +109,12 @@ class FunctionCost { (ICPPClassType) uqSource, cost.target, false, point); break; case LIST_INIT_OF_CLASS: - udcCost = Conversions.listInitializationOfClass(((InitializerListType) cost.source).getEvaluation(), - (ICPPClassType) cost.target, false, false, point); + udcCost = Conversions.listInitializationOfClass(((InitializerListType) cost.source).getEvaluation(), + (ICPPClassType) cost.target, false, false, point); break; case DIRECT_LIST_INIT_OF_CLASS: - udcCost = Conversions.listInitializationOfClass(((InitializerListType) cost.source).getEvaluation(), - (ICPPClassType) cost.target, true, false, point); + udcCost = Conversions.listInitializationOfClass(((InitializerListType) cost.source).getEvaluation(), + (ICPPClassType) cost.target, true, false, point); break; default: return false; @@ -134,7 +134,7 @@ class FunctionCost { public int compareTo(IASTTranslationUnit tu, FunctionCost other) throws DOMException { if (other == null) return -1; - + boolean haveWorse = false; boolean haveBetter = false; // In order for this function to be better than the previous best, it must @@ -154,7 +154,7 @@ class FunctionCost { haveWorse |= (cmp > 0); haveBetter |= (cmp < 0); } - + final ICPPFunction f1 = getFunction(); final ICPPFunction f2 = other.getFunction(); if (!haveWorse && !haveBetter) { @@ -163,7 +163,7 @@ class FunctionCost { ICPPFunctionTemplate otherAsTemplate= asTemplate(f2); final boolean isTemplate = asTemplate != null; final boolean otherIsTemplate = otherAsTemplate != null; - + // Prefer normal functions over template functions if (isTemplate && !otherIsTemplate) { haveWorse = true; @@ -173,50 +173,50 @@ class FunctionCost { TypeSelection ts= SemanticUtil.isConversionOperator(f1) ? RETURN_TYPE : PARAMETERS; int order = CPPTemplates.orderFunctionTemplates(otherAsTemplate, asTemplate, ts, fPoint); if (order < 0) { - haveBetter= true; + haveBetter= true; } else if (order > 0) { haveWorse= true; } - } + } } - + if (haveBetter == haveWorse) { // 7.3.3-15 Using declarations in classes can be overridden int cmp= overridesUsingDeclaration(f1, f2); if (cmp != 0) return cmp; - + // At this point prefer non-index bindings return -CPPSemantics.compareByRelevance(tu, f1, f2); } - - if (haveBetter) + + if (haveBetter) return -1; - + return 1; } - + private int overridesUsingDeclaration(ICPPFunction f1, ICPPFunction f2) { if (f1.takesVarArgs() != f2.takesVarArgs()) return 0; - if (!(f1 instanceof ICPPMethod && f2 instanceof ICPPMethod)) + if (!(f1 instanceof ICPPMethod && f2 instanceof ICPPMethod)) return 0; - + final ICPPMethod m1 = (ICPPMethod) f1; final ICPPMethod m2 = (ICPPMethod) f2; ICPPClassType o1= m1.getClassOwner(); ICPPClassType o2= m2.getClassOwner(); - if (o1.isSameType(o2)) + if (o1.isSameType(o2)) return 0; - + final ICPPFunctionType ft1 = m1.getType(); final ICPPFunctionType ft2 = m2.getType(); if (ft1.isConst() != ft2.isConst() || ft2.isVolatile() != ft2.isVolatile()) return 0; - + if (!parameterTypesMatch(ft1, ft2)) return 0; - + int diff= SemanticUtil.calculateInheritanceDepth(o2, o1, fPoint); if (diff >= 0) return diff; @@ -227,13 +227,13 @@ class FunctionCost { IType[] p1= ft1.getParameterTypes(); IType[] p2= ft2.getParameterTypes(); if (p1.length != p2.length) { - if (p1.length == 0) + if (p1.length == 0) return p2.length == 1 && SemanticUtil.isVoidType(p2[0]); - if (p2.length == 0) + if (p2.length == 0) return p1.length == 1 && SemanticUtil.isVoidType(p1[0]); return false; - } - + } + for (int i = 0; i < p2.length; i++) { if (!p1[i].isSameType(p2[i])) { return false; @@ -245,30 +245,30 @@ class FunctionCost { public boolean mustBeWorse(FunctionCost other) { if (other == null) return false; - + boolean haveWorse= false; int idx= getLength() - 1; int idxOther= other.getLength() - 1; for (; idx >= 0 && idxOther >= 0; idx--, idxOther--) { Cost cost= getCost(idx); - if (!cost.converts()) + if (!cost.converts()) return true; - + Cost otherCost= other.getCost(idxOther); - + int cmp; if (cost.isDeferredUDC() != DeferredUDC.NONE) { cmp= cost.getRank().compareTo(otherCost.getRank()); } else { cmp= cost.compareTo(otherCost); } - + if (cmp < 0) return false; if (cmp > 0) haveWorse= true; } - + return haveWorse; } @@ -285,7 +285,7 @@ class FunctionCost { public void setIsDirectInitWithCopyCtor(boolean val) { fIsDirectCopyCtor= val; } - + public boolean isDirectInitWithCopyCtor() { return fIsDirectCopyCtor; }