1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-25 18:05:33 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2009-04-12 05:48:15 +00:00
parent 3550a299d4
commit 824d47c599
3 changed files with 21 additions and 31 deletions

View file

@ -156,12 +156,10 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
} }
} }
public IASTNode[] getDeclarations() { public IASTNode[] getDeclarations() {
return declarations; return declarations;
} }
public IASTNode getDefinition() { public IASTNode getDefinition() {
return definition; return definition;
} }
@ -194,7 +192,7 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
} }
} }
} }
private ICPPASTFunctionDeclarator extractFunctionDtor(IASTNode node) { private ICPPASTFunctionDeclarator extractFunctionDtor(IASTNode node) {
if (node instanceof IASTName) if (node instanceof IASTName)
node = node.getParent(); node = node.getParent();
@ -211,7 +209,7 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
IASTStandardFunctionDeclarator dtor = getPreferredDtor(); IASTStandardFunctionDeclarator dtor = getPreferredDtor();
IASTParameterDeclaration[] params = dtor.getParameters(); IASTParameterDeclaration[] params = dtor.getParameters();
int size = params.length; int size = params.length;
IParameter[] result = new IParameter[ size ]; IParameter[] result = new IParameter[size];
if (size > 0) { if (size > 0) {
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
IASTParameterDeclaration p = params[i]; IASTParameterDeclaration p = params[i];
@ -229,7 +227,6 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
return result; return result;
} }
public IScope getFunctionScope() { public IScope getFunctionScope() {
resolveAllDeclarations(); resolveAllDeclarations();
if (definition != null) { if (definition != null) {
@ -239,12 +236,10 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
return declarations[0].getFunctionScope(); return declarations[0].getFunctionScope();
} }
public String getName() { public String getName() {
return getASTName().toString(); return getASTName().toString();
} }
public char[] getNameCharArray() { public char[] getNameCharArray() {
return getASTName().getSimpleID(); return getASTName().getSimpleID();
} }
@ -255,7 +250,7 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
IASTName name= dtor.getName(); IASTName name= dtor.getName();
if (name instanceof ICPPASTQualifiedName) { if (name instanceof ICPPASTQualifiedName) {
IASTName[] ns = ((ICPPASTQualifiedName)name).getNames(); IASTName[] ns = ((ICPPASTQualifiedName)name).getNames();
name = ns[ ns.length - 1 ]; name = ns[ns.length - 1];
} }
return name; return name;
} }
@ -286,7 +281,6 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
return scope; return scope;
} }
public ICPPFunctionType getType() { public ICPPFunctionType getType() {
if (type == null) if (type == null)
type = (ICPPFunctionType) CPPVisitor.createType((definition != null) ? definition : declarations[0]); type = (ICPPFunctionType) CPPVisitor.createType((definition != null) ? definition : declarations[0]);
@ -358,7 +352,6 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
} }
} }
public boolean isStatic() { public boolean isStatic() {
return isStatic(true); return isStatic(true);
} }
@ -401,17 +394,14 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
// return false; // return false;
// } // }
public String[] getQualifiedName() { public String[] getQualifiedName() {
return CPPVisitor.getQualifiedName(this); return CPPVisitor.getQualifiedName(this);
} }
public char[][] getQualifiedNameCharArray() { public char[][] getQualifiedNameCharArray() {
return CPPVisitor.getQualifiedNameCharArray(this); return CPPVisitor.getQualifiedNameCharArray(this);
} }
public boolean isGloballyQualified() throws DOMException { public boolean isGloballyQualified() throws DOMException {
IScope scope = getScope(); IScope scope = getScope();
while (scope != null) { while (scope != null) {
@ -543,7 +533,7 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
return IType.EMPTY_TYPE_ARRAY; return IType.EMPTY_TYPE_ARRAY;
IType[] typeIds = new IType[astTypeIds.length]; IType[] typeIds = new IType[astTypeIds.length];
for (int i=0; i<astTypeIds.length; ++i) { for (int i= 0; i < astTypeIds.length; ++i) {
typeIds[i] = CPPVisitor.createType(astTypeIds[i]); typeIds[i] = CPPVisitor.createType(astTypeIds[i]);
} }
return typeIds; return typeIds;

View file

@ -52,6 +52,7 @@ import org.eclipse.core.runtime.CoreException;
*/ */
public class Conversions { public class Conversions {
enum UDCMode {allowUDC, noUDC, deferUDC} enum UDCMode {allowUDC, noUDC, deferUDC}
/** /**
* Computes the cost of an implicit conversion sequence * Computes the cost of an implicit conversion sequence
* [over.best.ics] 13.3.3.1 * [over.best.ics] 13.3.3.1
@ -201,7 +202,7 @@ public class Conversions {
return -1; return -1;
} }
return cv1-cv2; return cv1 - cv2;
} }
/** /**
@ -338,10 +339,10 @@ public class Conversions {
return c; return c;
} }
//constructors // Constructors
if (t instanceof ICPPClassType) { if (t instanceof ICPPClassType) {
ICPPConstructor[] ctors= ((ICPPClassType) t).getConstructors(); ICPPConstructor[] ctors= ((ICPPClassType) t).getConstructors();
// select converting constructors // Select converting constructors
int j= 0; int j= 0;
ICPPConstructor[] convertingCtors= new ICPPConstructor[ctors.length]; ICPPConstructor[] convertingCtors= new ICPPConstructor[ctors.length];
for (int i = 0; i < ctors.length; i++) { for (int i = 0; i < ctors.length; i++) {
@ -351,23 +352,23 @@ public class Conversions {
} }
if (j > 0) { if (j > 0) {
LookupData data= new LookupData(); LookupData data= new LookupData();
data.setFunctionArgumentTypes(new IType [] { source }); data.setFunctionArgumentTypes(new IType[] { source });
IBinding binding = CPPSemantics.resolveFunction(data, convertingCtors, false); IBinding binding = CPPSemantics.resolveFunction(data, convertingCtors, false);
if (binding instanceof ICPPConstructor && !(binding instanceof IProblemBinding)) { if (binding instanceof ICPPConstructor && !(binding instanceof IProblemBinding)) {
constructorCost = checkStandardConversionSequence(t, target, false); constructorCost = checkStandardConversionSequence(t, target, false);
if (constructorCost.getRank() == Rank.NO_MATCH) { if (constructorCost.getRank() == Rank.NO_MATCH) {
constructorCost= null; constructorCost= null;
} else { } else {
constructorCost.setUserDefinedConversion((ICPPConstructor)binding); constructorCost.setUserDefinedConversion((ICPPConstructor) binding);
} }
} }
} }
} }
//conversion operators // Conversion operators
boolean ambiguousConversionOperator= false; boolean ambiguousConversionOperator= false;
if (s instanceof ICPPClassType) { if (s instanceof ICPPClassType) {
ICPPMethod [] ops = SemanticUtil.getConversionOperators((ICPPClassType) s); ICPPMethod[] ops = SemanticUtil.getConversionOperators((ICPPClassType) s);
if (ops.length > 0 && !(ops[0] instanceof IProblemBinding)) { if (ops.length > 0 && !(ops[0] instanceof IProblemBinding)) {
for (final ICPPMethod op : ops) { for (final ICPPMethod op : ops) {
Cost cost= checkStandardConversionSequence(op.getType().getReturnType(), target, false); Cost cost= checkStandardConversionSequence(op.getType().getReturnType(), target, false);
@ -455,7 +456,6 @@ public class Conversions {
boolean isConverted= false; boolean isConverted= false;
IType target = getNestedType(cost.target, REF | TDEF); IType target = getNestedType(cost.target, REF | TDEF);
IType source= getNestedType(cost.source, TDEF); IType source= getNestedType(cost.source, TDEF);
// 4.1 lvalue to rvalue // 4.1 lvalue to rvalue
IType srcRValue= getNestedType(source, REF | TDEF); IType srcRValue= getNestedType(source, REF | TDEF);
@ -524,7 +524,7 @@ public class Conversions {
} }
} }
// this should actually be done in 'checkImplicitConversionSequence', see 13.3.3.1-6 and 8.5.14 // This should actually be done in 'checkImplicitConversionSequence', see 13.3.3.1-6 and 8.5.14
// 8.5.14 cv-qualifiers can be ignored for non-class types // 8.5.14 cv-qualifiers can be ignored for non-class types
IType unqualifiedTarget= getNestedType(target, CVQ | PTR_CVQ | TDEF | REF); IType unqualifiedTarget= getNestedType(target, CVQ | PTR_CVQ | TDEF | REF);
if (!(unqualifiedTarget instanceof ICPPClassType)) { if (!(unqualifiedTarget instanceof ICPPClassType)) {
@ -788,8 +788,8 @@ public class Conversions {
if (type instanceof IIndexFragmentBinding) { if (type instanceof IIndexFragmentBinding) {
try { try {
return ((IIndexFragmentBinding) type).hasDefinition(); return ((IIndexFragmentBinding) type).hasDefinition();
} catch(CoreException ce) { } catch (CoreException e) {
CCorePlugin.log(ce); CCorePlugin.log(e);
} }
} }
try { try {

View file

@ -87,9 +87,9 @@ class FunctionCost {
// In order for this function to be better than the previous best, it must // In order for this function to be better than the previous best, it must
// have at least one parameter match that is better that the corresponding // have at least one parameter match that is better that the corresponding
// match for the other function, and none that are worse. // match for the other function, and none that are worse.
int idx= getLength()-1; int idx= getLength() - 1;
int idxOther= other.getLength()-1; int idxOther= other.getLength() - 1;
for (; idx>=0 && idxOther>=0; idx--,idxOther--) { for (; idx >= 0 && idxOther >= 0; idx--, idxOther--) {
Cost cost= getCost(idx); Cost cost= getCost(idx);
if (cost.getRank() == Rank.NO_MATCH) { if (cost.getRank() == Rank.NO_MATCH) {
haveWorse = true; haveWorse = true;
@ -140,9 +140,9 @@ class FunctionCost {
return false; return false;
boolean haveWorse= false; boolean haveWorse= false;
int idx= getLength()-1; int idx= getLength() - 1;
int idxOther= other.getLength()-1; int idxOther= other.getLength() - 1;
for (; idx>=0 && idxOther>=0; idx--,idxOther--) { for (; idx >= 0 && idxOther >= 0; idx--, idxOther--) {
Cost cost= getCost(idx); Cost cost= getCost(idx);
if (cost.getRank() == Rank.NO_MATCH) if (cost.getRank() == Rank.NO_MATCH)
return true; return true;