1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

bug 91577. Do a IType.isSameType instead of IType.equals

This commit is contained in:
Andrew Niefer 2005-04-19 18:57:46 +00:00
parent 1da410d13a
commit 12c064978c
32 changed files with 248 additions and 67 deletions

View file

@ -472,7 +472,7 @@ public class CompleteParser2Tests extends TestCase {
assertSame( ((IQualifierType)rt.getType()).getType(), B );
IType pt = ftype.getParameterTypes()[0];
assertEquals( p.getType(), pt );
assertTrue( p.getType().isSameType( pt ) );
assertTrue( pt instanceof IPointerType );
assertSame( ((IPointerType) pt).getType(), A );
}

View file

@ -16,4 +16,10 @@ package org.eclipse.cdt.core.dom.ast;
public interface IType extends Cloneable {
public Object clone();
/**
* is the given type the same as this type?
* @param type
* @return
*/
public boolean isSameType( IType type );
}

View file

@ -180,4 +180,11 @@ public class ProblemBinding implements IProblemBinding, IType, IScope {
public boolean isFullyCached() throws DOMException {
throw new DOMException( this );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
*/
public boolean isSameType( IType type ) {
return type == this;
}
}

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.c.ICASTArrayModifier;
import org.eclipse.cdt.core.dom.ast.c.ICArrayType;
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
@ -29,7 +30,11 @@ public class CArrayType implements ICArrayType, ITypeContainer {
this.type = type;
}
public boolean equals(Object obj) {
public boolean isSameType(IType obj) {
if( obj == this )
return true;
if( obj instanceof ITypedef )
return obj.isSameType( this );
if( obj instanceof ICArrayType ){
ICArrayType at = (ICArrayType) obj;
try {
@ -39,7 +44,7 @@ public class CArrayType implements ICArrayType, ITypeContainer {
if( isVolatile() != at.isVolatile() ) return false;
if( isVariableLength() != at.isVariableLength() ) return false;
return at.getType().equals( type );
return at.getType().isSameType( type );
} catch ( DOMException e ) {
return false;
}

View file

@ -11,6 +11,7 @@
package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICBasicType;
@ -69,10 +70,12 @@ public class CBasicType implements ICBasicType {
return sds.isLongLong();
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(Object obj) {
public boolean isSameType(IType obj) {
if( obj == this )
return true;
if( obj instanceof ITypedef )
return obj.isSameType( this );
if (!(obj instanceof CBasicType)) return false;
CBasicType cObj = (CBasicType)obj;

View file

@ -25,6 +25,7 @@ import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.c.ICASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICASTEnumerationSpecifier;
@ -142,4 +143,16 @@ public class CEnumeration implements IEnumeration {
public void addDefinition( IASTName name ) {
definition = name;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
*/
public boolean isSameType( IType type ) {
if( type == this )
return true;
if( type instanceof ITypedef )
return type.isSameType( this );
return false;
}
}

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
/**
* @author dsteffle
@ -30,7 +31,11 @@ public class CFunctionType implements IFunctionType {
this.parameters = types;
}
public boolean equals( Object o ){
public boolean isSameType( IType o ){
if( o == this )
return true;
if( o instanceof ITypedef )
return o.isSameType( this );
if( o instanceof IFunctionType ){
IFunctionType ft = (IFunctionType) o;
IType [] fps;
@ -42,13 +47,13 @@ public class CFunctionType implements IFunctionType {
if( fps.length != parameters.length )
return false;
try {
if( ! returnType.equals( ft.getReturnType() ) )
if( ! returnType.isSameType( ft.getReturnType() ) )
return false;
} catch ( DOMException e1 ) {
return false;
}
for( int i = 0; i < parameters.length; i++ )
if( ! parameters[i].equals( fps[i] ) )
if( ! parameters[i].isSameType( fps[i] ) )
return false;
return true;
}

View file

@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.c.ICASTPointer;
import org.eclipse.cdt.core.dom.ast.c.ICPointerType;
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
@ -30,7 +31,12 @@ public class CPointerType implements ICPointerType, ITypeContainer {
this.nextType = next;
}
public boolean equals( Object obj ){
public boolean isSameType( IType obj ){
if( obj == this )
return true;
if( obj instanceof ITypedef )
return obj.isSameType( this );
if( obj instanceof ICPointerType ){
ICPointerType pt = (ICPointerType) obj;
try {
@ -38,7 +44,7 @@ public class CPointerType implements ICPointerType, ITypeContainer {
if( isRestrict() != pt.isRestrict() ) return false;
if( isVolatile() != pt.isVolatile() ) return false;
return pt.getType().equals( nextType );
return pt.getType().isSameType( nextType );
} catch ( DOMException e ) {
return false;
}

View file

@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.c.ICASTArrayModifier;
import org.eclipse.cdt.core.dom.ast.c.ICPointerType;
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
@ -72,4 +73,21 @@ public class CQualifiedPointerType implements ICPointerType, ITypeContainer {
}
return t;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
*/
public boolean isSameType( IType type ) {
if( type == this )
return true;
if( type instanceof ITypedef )
return type.isSameType( this );
if( type instanceof CQualifiedPointerType ){
CQualifiedPointerType qual = (CQualifiedPointerType) type;
if( qual.isConst() == isConst() && qual.isRestrict() == isRestrict() && qual.isVolatile() == isVolatile() )
return getType().isSameType( qual.getType() );
}
return false;
}
}

View file

@ -15,6 +15,7 @@ import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.c.ICASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICASTTypedefNameSpecifier;
@ -38,7 +39,12 @@ public class CQualifierType implements ICQualifierType, ITypeContainer {
this.declSpec = declSpec;
}
public boolean equals( Object obj ){
public boolean isSameType( IType obj ){
if( obj == this )
return true;
if( obj instanceof ITypedef )
return obj.isSameType( this );
if( obj instanceof ICQualifierType ){
ICQualifierType qt = (ICQualifierType) obj;
try {
@ -46,7 +52,7 @@ public class CQualifierType implements ICQualifierType, ITypeContainer {
if( isRestrict() != qt.isRestrict() ) return false;
if( isVolatile() != qt.isVolatile() ) return false;
return qt.getType().equals( getType() );
return qt.getType().isSameType( getType() );
} catch ( DOMException e ) {
return false;
}

View file

@ -26,6 +26,7 @@ import org.eclipse.cdt.core.dom.ast.IField;
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.c.ICASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICCompositeTypeScope;
@ -207,4 +208,15 @@ public class CStructure implements ICompositeType, ICInternalBinding {
definition = compositeTypeSpec.getName();
compositeTypeSpec.getName().setBinding( this );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
*/
public boolean isSameType( IType type ) {
if( type == this )
return true;
if( type instanceof ITypedef )
return type.isSameType( this );
return false;
}
}

View file

@ -11,6 +11,7 @@
**********************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
@ -74,4 +75,26 @@ public class CTypeDef implements ITypedef, ITypeContainer {
}
return t;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
*/
public boolean isSameType( IType t ) {
if( t == this )
return true;
if( t instanceof ITypedef )
try {
IType temp = getType();
if( temp != null )
return temp.isSameType( ((ITypedef)t).getType());
return false;
} catch ( DOMException e ) {
return false;
}
IType temp = getType();
if( temp != null )
return temp.isSameType( t );
return false;
}
}

View file

@ -747,7 +747,7 @@ public class CVisitor {
t2 = ((IVariable)binding).getType();
} catch ( DOMException e1 ) {
}
if( t1 != null && t2 != null && t1.equals( t2 ) ){
if( t1 != null && t2 != null && t1.isSameType( t2 ) ){
if( binding instanceof CVariable )
((CVariable)binding).addDeclaration( name );
} else {

View file

@ -18,6 +18,7 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IArrayType;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
/**
@ -44,10 +45,15 @@ public class CPPArrayType implements IArrayType, ITypeContainer {
this.type = t;
}
public boolean equals(Object obj) {
public boolean isSameType(IType obj) {
if( obj == this )
return true;
if( obj instanceof ITypedef )
return ((ITypedef)obj).isSameType( this );
if( obj instanceof IArrayType ){
try {
return ((IArrayType) obj).getType().equals( type );
return ((IArrayType) obj).getType().isSameType( type );
} catch ( DOMException e ) {
return false;
}

View file

@ -34,9 +34,9 @@ public class CPPBasicType implements ICPPBasicType {
qualifierBits = bits;
}
public boolean equals( Object object ) {
public boolean isSameType( IType object ) {
if( object instanceof CPPTypedef )
return object.equals( this );
return object.isSameType( this );
if( !(object instanceof CPPBasicType) )
return false;

View file

@ -19,6 +19,8 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IField;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
@ -192,4 +194,15 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
public void addDefinition(IASTNode node) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
*/
public boolean isSameType( IType type ) {
if( type == this )
return true;
if( type instanceof ITypedef )
return ((ITypedef)type).isSameType( this );
return false;
}
}

View file

@ -21,6 +21,7 @@ import org.eclipse.cdt.core.dom.ast.IField;
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
@ -235,4 +236,15 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements
public ICPPMethod[] getConversionOperators() {
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
*/
public boolean isSameType( IType type ) {
if( type == this )
return true;
if( type instanceof ITypedef )
return ((ITypedef)type).isSameType( this );
return false;
}
}

View file

@ -29,6 +29,7 @@ import org.eclipse.cdt.core.dom.ast.IField;
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
@ -98,15 +99,15 @@ public class CPPClassType implements ICPPClassType, ICPPInternalClassType {
public Object clone() {
return ((ICPPClassType)getBinding()).clone();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalClassType#getConversionOperators()
*/
public ICPPMethod[] getConversionOperators() {
IBinding binding = getBinding();
if( binding instanceof ICPPInternalClassType )
return ((ICPPInternalClassType)binding).getConversionOperators();
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
}
public boolean isSameType( IType type ) {
return ((ICPPClassType)getBinding()).isSameType( type );
}
}
public static class CPPClassTypeProblem extends ProblemBinding implements ICPPClassType{
public CPPClassTypeProblem( IASTNode node, int id, char[] arg ) {
@ -692,4 +693,15 @@ public class CPPClassType implements ICPPClassType, ICPPInternalClassType {
public ICPPDelegate createDelegate( IASTName name ) {
return new CPPClassTypeDelegate( name, this );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
*/
public boolean isSameType( IType type ) {
if( type == this )
return true;
if( type instanceof ITypedef )
return ((ITypedef)type).isSameType( this );
return false;
}
}

View file

@ -22,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.IEnumeration;
import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
@ -40,6 +41,9 @@ public class CPPEnumeration implements IEnumeration, ICPPInternalBinding, ICPPBi
public Object clone() {
return ((IEnumeration)getBinding()).clone();
}
public boolean isSameType( IType type ) {
return ((IEnumeration)getBinding()).isSameType( type );
}
}
private IASTName enumName;
@ -165,4 +169,15 @@ public class CPPEnumeration implements IEnumeration, ICPPInternalBinding, ICPPBi
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
*/
public boolean isSameType( IType type ) {
if( type == this )
return true;
if( type instanceof ITypedef )
return ((ITypedef)type).isSameType( this );
return false;
}
}

View file

@ -17,6 +17,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
/**
* @author aniefer
@ -34,7 +35,9 @@ public class CPPFunctionType implements IFunctionType {
this.parameters = types;
}
public boolean equals( Object o ){
public boolean isSameType( IType o ){
if( o instanceof ITypedef )
return o.isSameType( this );
if( o instanceof IFunctionType ){
IFunctionType ft = (IFunctionType) o;
IType [] fps;
@ -50,13 +53,13 @@ public class CPPFunctionType implements IFunctionType {
//constructors & destructors have null return type
if( ( returnType == null ) ^ ( ft.getReturnType() == null ) )
return false;
else if( returnType != null && ! returnType.equals( ft.getReturnType() ) )
else if( returnType != null && ! returnType.isSameType( ft.getReturnType() ) )
return false;
} catch ( DOMException e1 ) {
return false;
}
for( int i = 0; i < parameters.length; i++ )
if( ! parameters[i].equals( fps[i] ) )
if( ! parameters[i].isSameType( fps[i] ) )
return false;
return true;
}

View file

@ -198,7 +198,7 @@ public class CPPImplicitMethod extends CPPMethod {
if( ps.length == params.length ){
int idx = 0;
for( ; idx < ps.length && ps[idx] != null; idx++ ){
if( !ps[idx].equals(params[idx]) )
if( !ps[idx].isSameType(params[idx]) )
break;
}
if( idx == ps.length ){

View file

@ -39,22 +39,17 @@ public class CPPPointerToMemberType extends CPPPointerType implements
this.operator = operator;
}
public boolean equals( Object o ){
if( !super.equals( o ) )
public boolean isSameType( IType o ){
if( !super.isSameType( o ) )
return false;
if( !( o instanceof CPPPointerToMemberType ) )
return false;
if( o instanceof ITypedef )
return o.equals( this );
return false;
CPPPointerToMemberType pt = (CPPPointerToMemberType) o;
IBinding cls = pt.getMemberOfClass();
ICPPClassType cls = pt.getMemberOfClass();
if( cls != null )
return cls.equals( getMemberOfClass() );
return cls.isSameType( getMemberOfClass() );
return false;
}

View file

@ -49,9 +49,12 @@ public class CPPPointerType implements IPointerType, ITypeContainer {
this.type = type;
}
public boolean equals( Object o ){
if( o instanceof ITypedef )
return o.equals( this );
public boolean isSameType( IType o ){
if( o == this )
return true;
if( o instanceof ITypedef )
return ((ITypedef)o).isSameType( this );
if( !( o instanceof CPPPointerType ) )
return false;
@ -60,7 +63,7 @@ public class CPPPointerType implements IPointerType, ITypeContainer {
CPPPointerType pt = (CPPPointerType) o;
if( isConst == pt.isConst && isVolatile == pt.isVolatile )
return type.equals( pt.getType() );
return type.isSameType( pt.getType() );
return false;
}

View file

@ -34,15 +34,15 @@ public class CPPQualifierType implements IQualifierType, ITypeContainer {
this.isVolatile = isVolatile;
}
public boolean equals( Object o ){
public boolean isSameType( IType o ){
if( o instanceof ITypedef )
return o.equals( this );
return o.isSameType( this );
if( !( o instanceof CPPQualifierType ) )
return false;
CPPQualifierType pt = (CPPQualifierType) o;
if( isConst() == pt.isConst() && isVolatile() == pt.isVolatile() )
return type.equals( pt.getType() );
return type.isSameType( pt.getType() );
return false;
}

View file

@ -16,6 +16,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
@ -43,13 +44,18 @@ public class CPPReferenceType implements ICPPReferenceType, ITypeContainer {
type = t;
}
public boolean equals(Object obj) {
public boolean isSameType(IType obj) {
if( obj == this )
return true;
if( obj instanceof ITypedef )
return ((ITypedef)obj).isSameType( this );
if( type == null )
return (obj == null);
if( obj instanceof ICPPReferenceType ){
try {
return type.equals( ((ICPPReferenceType) obj).getType() );
return type.isSameType( ((ICPPReferenceType) obj).getType() );
} catch ( DOMException e ) {
return false;
}

View file

@ -1761,7 +1761,7 @@ public class CPPSemantics {
if( varArgs ){
cost = new Cost( source, null );
cost.rank = Cost.ELLIPSIS_CONVERSION;
} else if( source.equals( target ) ){
} else if( source.isSameType( target ) ){
cost = new Cost( source, target );
cost.rank = Cost.IDENTITY_RANK; //exact match, no cost
} else {
@ -1872,7 +1872,7 @@ public class CPPSemantics {
} catch ( DOMException e ) {
ft = e.getProblem();
}
if( type.equals( ft ) ){
if( type.isSameType( ft ) ){
if( result == null )
result = fn;
else
@ -2056,7 +2056,7 @@ public class CPPSemantics {
return cost;
}
if( cost.source.equals( cost.target ) ){
if( cost.source.isSameType( cost.target ) ){
cost.rank = Cost.IDENTITY_RANK;
return cost;
}
@ -2077,7 +2077,7 @@ public class CPPSemantics {
return cost;
}
if( s.equals( t ) ){
if( s.isSameType( t ) ){
return cost;
}
@ -2326,7 +2326,7 @@ public class CPPSemantics {
IType src = getUltimateType( cost.source, true );
IType trg = getUltimateType( cost.target, true );
if( src.equals( trg ) )
if( src.isSameType( trg ) )
return;
if( src instanceof IBasicType && trg instanceof IBasicType ){
@ -2390,7 +2390,7 @@ public class CPPSemantics {
//derived class of B
ICPPPointerToMemberType spm = (ICPPPointerToMemberType) s;
ICPPPointerToMemberType tpm = (ICPPPointerToMemberType) t;
if( spm.getType().equals( tpm.getType() ) ){
if( spm.getType().isSameType( tpm.getType() ) ){
temp = hasBaseClass( tpm.getMemberOfClass(), spm.getMemberOfClass(), false );
cost.rank = ( temp > -1 ) ? Cost.CONVERSION_RANK : Cost.NO_MATCH_RANK;
cost.conversion = ( temp > -1 ) ? temp : 0;
@ -2565,7 +2565,7 @@ public class CPPSemantics {
IType type = null;
try {
type = function.getType();
return type.equals( CPPVisitor.createType( declarator ) );
return type.isSameType( CPPVisitor.createType( declarator ) );
} catch (DOMException e) {
}
return false;

View file

@ -17,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
@ -140,4 +141,15 @@ public class CPPTemplateParameter implements ICPPTemplateParameter, IType, ICPPI
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
*/
public boolean isSameType( IType type ) {
if( type == this )
return true;
if( type instanceof ITypedef )
return ((ITypedef)type).isSameType( this );
return false;
}
}

View file

@ -356,7 +356,7 @@ public class CPPTemplates {
IType type = CPPVisitor.createType( (IASTDeclarator) parent );
try {
IType ftype = ((ICPPFunction)definition).getType();
if( ftype.equals( type ) )
if( ftype.isSameType( type ) )
result = true;
} catch (DOMException e) {
}
@ -370,7 +370,7 @@ public class CPPTemplates {
for (; i < args.length; i++) {
IType t1 = CPPVisitor.createType( spec.getArguments()[i] );
IType t2 = CPPVisitor.createType( args[i] );
if( t1 != null && t2 != null && t1.equals( t2 ) )
if( t1 != null && t2 != null && t1.isSameType( t2 ) )
continue;
break;
}

View file

@ -45,6 +45,9 @@ public class CPPTypedef implements ITypedef, ITypeContainer, ICPPInternalBinding
}
return null;
}
public boolean isSameType( IType type ) {
return ((ITypedef)getBinding()).isSameType( type );
}
}
private IASTName [] declarations = null;
private IType type = null;
@ -71,25 +74,22 @@ public class CPPTypedef implements ITypedef, ITypeContainer, ICPPInternalBinding
return declarations[0];
}
public boolean equals( Object o ){
public boolean isSameType( IType o ){
if( o == this )
return true;
if( o instanceof ITypedef )
try {
IType t = getType();
if( t != null )
return t.equals( ((ITypedef)o).getType());
return t.isSameType( ((ITypedef)o).getType());
return false;
} catch ( DOMException e ) {
return false;
}
if( !( o instanceof IType ) )
return false;
IType t = getType();
if( t != null )
return t.equals( o );
return t.isSameType( o );
return false;
}

View file

@ -485,7 +485,7 @@ public class CPPVisitor {
try {
IType t1 = ((ITypedef)binding).getType();
IType t2 = createType( declarator );
if( t1 != null && t2 != null && t1.equals( t2 ) ){
if( t1 != null && t2 != null && t1.isSameType( t2 ) ){
((ICPPInternalBinding)binding).addDeclaration( name );
return binding;
}
@ -533,7 +533,7 @@ public class CPPVisitor {
}
}
if( t1 != null && t2 != null ){
if( t1.equals( t2 ) ){
if( t1.isSameType( t2 ) ){
if( binding instanceof ICPPInternalBinding )
((ICPPInternalBinding)binding).addDeclaration( name );
} else {

View file

@ -41,8 +41,8 @@ public class GPPPointerToMemberType extends CPPPointerToMemberType implements
return isRestrict;
}
public boolean equals( Object o ){
if( !super.equals( o ) ) return false;
public boolean isSameType( IType o ){
if( !super.isSameType( o ) ) return false;
if( o instanceof IGPPPointerToMemberType ){
return (isRestrict == ((IGPPPointerToMemberType) o).isRestrict());

View file

@ -52,8 +52,8 @@ public class GPPPointerType extends CPPPointerType implements IGPPPointerType {
}
public boolean equals( Object o ){
if( !super.equals( o ) ) return false;
public boolean isSameType( IType o ){
if( !super.isSameType( o ) ) return false;
if( o instanceof IGPPPointerType ){
return (isRestrict == ((IGPPPointerType) o).isRestrict());