From 9471bc7bc1031ebbc86a539fc82664dcc677f758 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Thu, 5 Feb 2015 16:19:26 +0300 Subject: [PATCH] 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 --- .../cdt/dsf/mi/service/MIExpressions.java | 66 +++++++++++-------- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIExpressions.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIExpressions.java index eb42b12d362..cbf634920a0 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIExpressions.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIExpressions.java @@ -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. *