Debugger: Add type results to ExpressionInfo.

- In addition to a primitive or value node, expressions can potentially
  result in types as well. As such, extend ExpressionInfo to be able to
  return one, and indicate such a result kind appropriately.
This commit is contained in:
Rene Gollent 2014-12-08 21:16:26 -05:00
parent 042bb68ed6
commit 5a4887a0db
2 changed files with 39 additions and 11 deletions

View File

@ -6,6 +6,7 @@
#include "ExpressionInfo.h" #include "ExpressionInfo.h"
#include "Type.h"
#include "Value.h" #include "Value.h"
#include "ValueNode.h" #include "ValueNode.h"
@ -17,7 +18,8 @@ ExpressionResult::ExpressionResult()
: :
fResultKind(EXPRESSION_RESULT_KIND_UNKNOWN), fResultKind(EXPRESSION_RESULT_KIND_UNKNOWN),
fPrimitiveValue(NULL), fPrimitiveValue(NULL),
fValueNodeValue(NULL) fValueNodeValue(NULL),
fTypeResult(NULL)
{ {
} }
@ -29,6 +31,9 @@ ExpressionResult::~ExpressionResult()
if (fValueNodeValue != NULL) if (fValueNodeValue != NULL)
fValueNodeValue->ReleaseReference(); fValueNodeValue->ReleaseReference();
if (fTypeResult != NULL)
fTypeResult->ReleaseReference();
} }
@ -70,6 +75,19 @@ ExpressionResult::SetToValueNode(ValueNodeChild* child)
} }
void
ExpressionResult::SetToType(Type* type)
{
_Unset();
fTypeResult = type;
if (fTypeResult != NULL) {
fTypeResult->AcquireReference();
fResultKind = EXPRESSION_RESULT_KIND_TYPE;
}
}
void void
ExpressionResult::_Unset() ExpressionResult::_Unset()
{ {
@ -83,6 +101,11 @@ ExpressionResult::_Unset()
fValueNodeValue = NULL; fValueNodeValue = NULL;
} }
if (fTypeResult != NULL) {
fTypeResult->ReleaseReference();
fTypeResult = NULL;
}
fResultKind = EXPRESSION_RESULT_KIND_UNKNOWN; fResultKind = EXPRESSION_RESULT_KIND_UNKNOWN;
} }

View File

@ -13,6 +13,7 @@
#include <Variant.h> #include <Variant.h>
class Type;
class Value; class Value;
class ValueNodeChild; class ValueNodeChild;
@ -20,7 +21,8 @@ class ValueNodeChild;
enum expression_result_kind { enum expression_result_kind {
EXPRESSION_RESULT_KIND_UNKNOWN = 0, EXPRESSION_RESULT_KIND_UNKNOWN = 0,
EXPRESSION_RESULT_KIND_PRIMITIVE, EXPRESSION_RESULT_KIND_PRIMITIVE,
EXPRESSION_RESULT_KIND_VALUE_NODE EXPRESSION_RESULT_KIND_VALUE_NODE,
EXPRESSION_RESULT_KIND_TYPE
}; };
@ -30,23 +32,26 @@ public:
virtual ~ExpressionResult(); virtual ~ExpressionResult();
expression_result_kind Kind() const { return fResultKind; } expression_result_kind Kind() const { return fResultKind; }
Value* PrimitiveValue() const Value* PrimitiveValue() const
{ return fPrimitiveValue; } { return fPrimitiveValue; }
ValueNodeChild* ValueNodeValue() const ValueNodeChild* ValueNodeValue() const
{ return fValueNodeValue; } { return fValueNodeValue; }
Type* GetType() const
{ return fTypeResult; }
void SetToPrimitive(Value* value); void SetToPrimitive(Value* value);
void SetToValueNode(ValueNodeChild* child); void SetToValueNode(ValueNodeChild* child);
void SetToType(Type* type);
private:
void _Unset();
private: private:
void _Unset(); expression_result_kind fResultKind;
Value* fPrimitiveValue;
private: ValueNodeChild* fValueNodeValue;
expression_result_kind fResultKind; Type* fTypeResult;
Value* fPrimitiveValue;
ValueNodeChild* fValueNodeValue;
}; };