mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Added toString() method to type classes to make debugging easier.
This commit is contained in:
parent
4303b04ddb
commit
8f15241d85
9 changed files with 72 additions and 25 deletions
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
|
@ -25,15 +26,15 @@ import org.eclipse.cdt.internal.core.index.IIndexType;
|
|||
* @author aniefer
|
||||
*/
|
||||
public class CPPBasicType implements ICPPBasicType {
|
||||
|
||||
|
||||
protected int qualifierBits = 0;
|
||||
protected int type;
|
||||
protected IASTExpression value = null;
|
||||
|
||||
|
||||
public CPPBasicType( int t, int bits ){
|
||||
type = t;
|
||||
qualifierBits = bits;
|
||||
|
||||
|
||||
if( type == IBasicType.t_unspecified ){
|
||||
if( (qualifierBits & ( IS_LONG | IS_SHORT | IS_SIGNED | IS_UNSIGNED )) != 0 )
|
||||
type = IBasicType.t_int;
|
||||
|
@ -45,24 +46,24 @@ public class CPPBasicType implements ICPPBasicType {
|
|||
qualifierBits = bits;
|
||||
value = val;
|
||||
}
|
||||
|
||||
|
||||
public boolean isSameType( IType object ) {
|
||||
if( object == this )
|
||||
return true;
|
||||
|
||||
|
||||
if( object instanceof ITypedef || object instanceof IIndexType)
|
||||
return object.isSameType( this );
|
||||
|
||||
|
||||
if( !(object instanceof CPPBasicType) )
|
||||
return false;
|
||||
|
||||
if( type == -1 )
|
||||
|
||||
if( type == -1 )
|
||||
return false;
|
||||
|
||||
|
||||
CPPBasicType t = (CPPBasicType) object;
|
||||
if( type != t.type )
|
||||
return false;
|
||||
|
||||
|
||||
if( type == IBasicType.t_int ){
|
||||
//signed int and int are equivalent
|
||||
return (qualifierBits & ~IS_SIGNED ) == (t.qualifierBits & ~IS_SIGNED );
|
||||
|
@ -103,7 +104,7 @@ public class CPPBasicType implements ICPPBasicType {
|
|||
public boolean isLong() {
|
||||
return ( qualifierBits & IS_LONG ) != 0;
|
||||
}
|
||||
|
||||
|
||||
public Object clone(){
|
||||
IType t = null;
|
||||
try {
|
||||
|
@ -120,7 +121,7 @@ public class CPPBasicType implements ICPPBasicType {
|
|||
public IASTExpression getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
public void setValue( IASTExpression val ){
|
||||
value = val;
|
||||
}
|
||||
|
@ -128,4 +129,8 @@ public class CPPBasicType implements ICPPBasicType {
|
|||
public int getQualifierBits() {
|
||||
return qualifierBits;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return ASTTypeUtil.getType(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTPointer;
|
||||
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
|
@ -113,4 +114,8 @@ public class CPPPointerType implements IPointerType, ITypeContainer {
|
|||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return ASTTypeUtil.getType(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
package org.eclipse.cdt.internal.core.index.composite;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||
|
@ -26,4 +27,11 @@ public class CompositeTypeContainer extends CompositeType implements ITypeContai
|
|||
return cf.getCompositeType((IIndexType)((ITypeContainer)type).getType());
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
try {
|
||||
return ASTTypeUtil.getType(getType());
|
||||
} catch (DOMException e) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
package org.eclipse.cdt.internal.core.pdom.dom;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
|
@ -144,4 +145,8 @@ public class PDOMPointerType extends PDOMNode implements IPointerType,
|
|||
linkage.deleteType(getType(), record);
|
||||
super.delete(linkage);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return ASTTypeUtil.getType(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
package org.eclipse.cdt.internal.core.pdom.dom;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IQualifierType;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
|
@ -158,4 +159,8 @@ public class PDOMQualifierType extends PDOMNode implements IQualifierType, ICQua
|
|||
linkage.deleteType(getType(), record);
|
||||
super.delete(linkage);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return ASTTypeUtil.getType(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||
|
@ -34,11 +35,11 @@ class PDOMCPPBasicType extends PDOMNode implements ICPPBasicType, IIndexType {
|
|||
|
||||
public static final int TYPE_ID = PDOMNode.RECORD_SIZE + 0; // short
|
||||
public static final int FLAGS = PDOMNode.RECORD_SIZE + 2; // short
|
||||
|
||||
|
||||
public static final int RECORD_SIZE = PDOMNode.RECORD_SIZE + 4;
|
||||
|
||||
|
||||
protected short fFlags= -1;
|
||||
|
||||
|
||||
public PDOMCPPBasicType(PDOM pdom, int record) {
|
||||
super(pdom, record);
|
||||
}
|
||||
|
@ -46,10 +47,10 @@ class PDOMCPPBasicType extends PDOMNode implements ICPPBasicType, IIndexType {
|
|||
public PDOMCPPBasicType(PDOM pdom, PDOMNode parent, ICPPBasicType type) throws CoreException {
|
||||
this(pdom, parent, type, encodeFlags(type));
|
||||
}
|
||||
|
||||
|
||||
protected PDOMCPPBasicType(PDOM pdom, PDOMNode parent, ICPPBasicType type, final short flags) throws CoreException {
|
||||
super(pdom, parent);
|
||||
|
||||
|
||||
fFlags= flags;
|
||||
Database db = pdom.getDB();
|
||||
db.putShort(record + TYPE_ID, getTypeCode(type));
|
||||
|
@ -64,7 +65,7 @@ class PDOMCPPBasicType extends PDOMNode implements ICPPBasicType, IIndexType {
|
|||
}
|
||||
return tc;
|
||||
}
|
||||
|
||||
|
||||
protected static short encodeFlags(ICPPBasicType type) {
|
||||
short flags = 0;
|
||||
try {
|
||||
|
@ -84,7 +85,7 @@ class PDOMCPPBasicType extends PDOMNode implements ICPPBasicType, IIndexType {
|
|||
protected int getRecordSize() {
|
||||
return RECORD_SIZE;
|
||||
}
|
||||
|
||||
|
||||
public int getNodeType() {
|
||||
return IIndexCPPBindingConstants.CPPBASICTYPE;
|
||||
}
|
||||
|
@ -116,7 +117,7 @@ class PDOMCPPBasicType extends PDOMNode implements ICPPBasicType, IIndexType {
|
|||
}
|
||||
return fFlags;
|
||||
}
|
||||
|
||||
|
||||
public boolean isLong() throws DOMException {
|
||||
return (getQualifierBits() & IS_LONG) != 0;
|
||||
}
|
||||
|
@ -136,17 +137,17 @@ class PDOMCPPBasicType extends PDOMNode implements ICPPBasicType, IIndexType {
|
|||
public boolean isSameType(IType rhs) {
|
||||
if( rhs instanceof ITypedef )
|
||||
return rhs.isSameType( this );
|
||||
|
||||
|
||||
if( !(rhs instanceof ICPPBasicType))
|
||||
return false;
|
||||
|
||||
|
||||
ICPPBasicType rhs1= (ICPPBasicType) rhs;
|
||||
int type;
|
||||
try {
|
||||
type = this.getType();
|
||||
if (type == -1 || type != rhs1.getType())
|
||||
if (type == -1 || type != rhs1.getType())
|
||||
return false;
|
||||
|
||||
|
||||
if( type == IBasicType.t_int ){
|
||||
//signed int and int are equivalent
|
||||
return (this.getQualifierBits() & ~ICPPBasicType.IS_SIGNED ) == (rhs1.getQualifierBits() & ~ICPPBasicType.IS_SIGNED );
|
||||
|
@ -164,4 +165,8 @@ class PDOMCPPBasicType extends PDOMNode implements ICPPBasicType, IIndexType {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return ASTTypeUtil.getType(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.Set;
|
|||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMNode;
|
||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
|
@ -430,5 +431,8 @@ class PDOMCPPClassType extends PDOMCPPBinding implements ICPPClassType,
|
|||
public ICPPDelegate createDelegate(IASTName name) {
|
||||
return new CPPClassTypeDelegate(name, this);
|
||||
}
|
||||
|
||||
|
||||
public String toString() {
|
||||
return ASTTypeUtil.getType(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
|
@ -68,4 +69,8 @@ public class PDOMCPPFunctionType extends PDOMCFunctionType implements ICPPFuncti
|
|||
public int getNodeType() {
|
||||
return PDOMCPPLinkage.CPP_FUNCTION_TYPE;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return ASTTypeUtil.getType(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
|
@ -108,4 +109,8 @@ class PDOMCPPReferenceType extends PDOMNode implements ICPPReferenceType,
|
|||
linkage.deleteType(getType(), record);
|
||||
super.delete(linkage);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return ASTTypeUtil.getType(this);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue