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

Extract MIExpressions.getBasicType.

This permits derived classes to reimplement the logic for getting
expression value without copy-pasting the logic for getting type.

Change-Id: I21b048afaee8433d17e873b7aaf4f7b118edd107
This commit is contained in:
Vladimir Prus 2015-02-05 16:19:26 +03:00
parent ae9445c5ae
commit 9471bc7bc1

View file

@ -1154,35 +1154,7 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions,
@Override
protected void handleSuccess() {
IExpressionDMData.BasicType basicType = null;
GDBType gdbType = getData().getGDBType();
if (gdbType != null) {
switch (gdbType.getType()) {
case GDBType.ARRAY:
basicType = IExpressionDMData.BasicType.array;
break;
case GDBType.FUNCTION:
basicType = IExpressionDMData.BasicType.function;
break;
case GDBType.POINTER:
case GDBType.REFERENCE:
basicType = IExpressionDMData.BasicType.pointer;
break;
case GDBType.GENERIC:
default:
// The interesting question is not hasChildren,
// but canHaveChildren. E.g. an empty
// collection still is a composite.
if (getData().hasChildren() || getData().getCollectionHint()) {
basicType = IExpressionDMData.BasicType.composite;
} else {
basicType = IExpressionDMData.BasicType.basic;
}
break;
}
}
IExpressionDMData.BasicType basicType = getBasicType(getData());
String relativeExpr = getData().getExpr();
String alias = fReturnValueAliases.getAlias(relativeExpr);
@ -1204,6 +1176,42 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions,
}
}
/**
* @since 4.6
*/
protected IExpressionDMData.BasicType getBasicType(ExprMetaGetVarInfo varInfo) {
IExpressionDMData.BasicType basicType = null;
GDBType gdbType = varInfo.getGDBType();
if (gdbType != null) {
switch (gdbType.getType()) {
case GDBType.ARRAY:
basicType = IExpressionDMData.BasicType.array;
break;
case GDBType.FUNCTION:
basicType = IExpressionDMData.BasicType.function;
break;
case GDBType.POINTER:
case GDBType.REFERENCE:
basicType = IExpressionDMData.BasicType.pointer;
break;
case GDBType.GENERIC:
default:
// The interesting question is not hasChildren,
// but canHaveChildren. E.g. an empty
// collection still is a composite.
if (varInfo.hasChildren() || varInfo.getCollectionHint()) {
basicType = IExpressionDMData.BasicType.composite;
} else {
basicType = IExpressionDMData.BasicType.basic;
}
break;
}
}
return basicType;
}
/**
* Obtains the address of an expression and the size of its type.
*