Debugger: Rework expression parsing API.
ExpressionInfo: - No longer stores an explicit result type (this is inferred from evaluation of the expression itself now). - Introduce class ExpressionResult for returning the result of an expression computation. This can currently take the form of either a primitive value, or a value node object. - Adjust UserInterfaceListener and ExpressionInfo::Listener to take the above changes into account, and correspondingly adjust all callers/listeners. CLanguageExpressionEvaluator: - Introduce child class Operand. This subsumes the functionality that was previously in the separate Number class, and can represent a primitive value, a value node or a type. Also has functionality to implicity handle type promotion/inferring when performing calculations between operands. - Adjust expression parser to operate in terms of Operands rather than Numbers. This allows a number of improvements, most notably that an expression can now return a value node as a result rather than only a primitive number. This capability isn't yet fully used, but paves the way for future uses such as an expression that evaluates to a data member, a global variable, or an arbitrary pointer of a particular type. - Various cleanups/simplifications that were possible as a result of the above changes. ExpressionEvaluationWindow/ExpressionPromptWindow: - Remove type menu field, since the expression API no longer uses it. Adding/removing expressions in the VariablesView is temporarily disabled, pending some further rework there to properly handle the new result object.
This commit is contained in:
@@ -222,7 +222,6 @@ Application Debugger :
|
|||||||
|
|
||||||
# types
|
# types
|
||||||
ArrayIndexPath.cpp
|
ArrayIndexPath.cpp
|
||||||
Number.cpp
|
|
||||||
TargetAddressRangeList.cpp
|
TargetAddressRangeList.cpp
|
||||||
ValueLocation.cpp
|
ValueLocation.cpp
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
#include "Team.h"
|
#include "Team.h"
|
||||||
#include "Tracing.h"
|
#include "Tracing.h"
|
||||||
#include "Value.h"
|
#include "Value.h"
|
||||||
|
#include "ValueLocation.h"
|
||||||
#include "Worker.h"
|
#include "Worker.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -63,7 +64,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual void ExpressionEvaluated(ExpressionInfo* info, status_t result,
|
virtual void ExpressionEvaluated(ExpressionInfo* info, status_t result,
|
||||||
Value* value)
|
ExpressionResult* value)
|
||||||
{
|
{
|
||||||
fHandler->_HandleBreakpointConditionEvaluated(value);
|
fHandler->_HandleBreakpointConditionEvaluated(value);
|
||||||
}
|
}
|
||||||
@@ -888,14 +889,8 @@ ThreadHandler::_HandleBreakpointConditionIfNeeded(CpuState* cpuState)
|
|||||||
if (listener == NULL)
|
if (listener == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Type* type = new(std::nothrow) SyntheticPrimitiveType(B_UINT64_TYPE);
|
|
||||||
if (type == NULL)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
BReference<Type> typeReference(type, true);
|
|
||||||
|
|
||||||
ExpressionInfo* expressionInfo = new(std::nothrow) ExpressionInfo(
|
ExpressionInfo* expressionInfo = new(std::nothrow) ExpressionInfo(
|
||||||
userBreakpoint->Condition(), type);
|
userBreakpoint->Condition());
|
||||||
|
|
||||||
if (expressionInfo == NULL)
|
if (expressionInfo == NULL)
|
||||||
return false;
|
return false;
|
||||||
@@ -921,23 +916,13 @@ ThreadHandler::_HandleBreakpointConditionIfNeeded(CpuState* cpuState)
|
|||||||
|
|
||||||
teamLocker.Lock();
|
teamLocker.Lock();
|
||||||
|
|
||||||
bool stop = false;
|
if (_CheckStopCondition()) {
|
||||||
if (fConditionResult == NULL)
|
if (fConditionResult != NULL) {
|
||||||
stop = true;
|
fConditionResult->ReleaseReference();
|
||||||
else {
|
fConditionResult = NULL;
|
||||||
BVariant value;
|
}
|
||||||
if (!fConditionResult->ToVariant(value))
|
|
||||||
stop = true;
|
|
||||||
if (!value.TypeIsInteger(value.Type()))
|
|
||||||
stop = true;
|
|
||||||
stop = value.ToBool();
|
|
||||||
fConditionResult->ReleaseReference();
|
|
||||||
fConditionResult = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stop)
|
|
||||||
return false;
|
return false;
|
||||||
else {
|
} else {
|
||||||
_SetThreadState(THREAD_STATE_RUNNING, NULL,
|
_SetThreadState(THREAD_STATE_RUNNING, NULL,
|
||||||
THREAD_STOPPED_UNKNOWN, BString());
|
THREAD_STOPPED_UNKNOWN, BString());
|
||||||
fDebuggerInterface->ContinueThread(fThread->ID());
|
fDebuggerInterface->ContinueThread(fThread->ID());
|
||||||
@@ -951,7 +936,7 @@ ThreadHandler::_HandleBreakpointConditionIfNeeded(CpuState* cpuState)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ThreadHandler::_HandleBreakpointConditionEvaluated(Value* value)
|
ThreadHandler::_HandleBreakpointConditionEvaluated(ExpressionResult* value)
|
||||||
{
|
{
|
||||||
fConditionResult = value;
|
fConditionResult = value;
|
||||||
if (fConditionResult != NULL)
|
if (fConditionResult != NULL)
|
||||||
@@ -960,6 +945,25 @@ ThreadHandler::_HandleBreakpointConditionEvaluated(Value* value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
ThreadHandler::_CheckStopCondition()
|
||||||
|
{
|
||||||
|
// if we we're unable to properly assess the expression result
|
||||||
|
// in any way, fall back to behaving like an unconditional breakpoint.
|
||||||
|
if (fConditionResult == NULL)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (fConditionResult->Kind() != EXPRESSION_RESULT_KIND_PRIMITIVE)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
BVariant value;
|
||||||
|
if (!fConditionResult->PrimitiveValue()->ToVariant(value))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return value.ToBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ThreadHandler::_HasExitedFrame(target_addr_t framePointer) const
|
ThreadHandler::_HasExitedFrame(target_addr_t framePointer) const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,10 +18,10 @@
|
|||||||
|
|
||||||
class BreakpointManager;
|
class BreakpointManager;
|
||||||
class DebuggerInterface;
|
class DebuggerInterface;
|
||||||
|
class ExpressionResult;
|
||||||
class ImageDebugInfoJobListener;
|
class ImageDebugInfoJobListener;
|
||||||
class StackFrame;
|
class StackFrame;
|
||||||
class Statement;
|
class Statement;
|
||||||
class Value;
|
|
||||||
class Worker;
|
class Worker;
|
||||||
|
|
||||||
|
|
||||||
@@ -102,7 +102,8 @@ private:
|
|||||||
bool _HandleBreakpointConditionIfNeeded(
|
bool _HandleBreakpointConditionIfNeeded(
|
||||||
CpuState* cpuState);
|
CpuState* cpuState);
|
||||||
void _HandleBreakpointConditionEvaluated(
|
void _HandleBreakpointConditionEvaluated(
|
||||||
Value* value);
|
ExpressionResult* value);
|
||||||
|
bool _CheckStopCondition();
|
||||||
|
|
||||||
bool _HandleBreakpointHitStep(CpuState* cpuState);
|
bool _HandleBreakpointHitStep(CpuState* cpuState);
|
||||||
bool _HandleSingleStepStep(CpuState* cpuState);
|
bool _HandleSingleStepStep(CpuState* cpuState);
|
||||||
@@ -124,7 +125,7 @@ private:
|
|||||||
target_addr_t fPreviousFrameAddress;
|
target_addr_t fPreviousFrameAddress;
|
||||||
bool fSingleStepping;
|
bool fSingleStepping;
|
||||||
sem_id fConditionWaitSem;
|
sem_id fConditionWaitSem;
|
||||||
Value* fConditionResult;
|
ExpressionResult* fConditionResult;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ThreadHandler* fNext;
|
ThreadHandler* fNext;
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include "Value.h"
|
#include "Value.h"
|
||||||
#include "ValueNode.h"
|
#include "ValueNode.h"
|
||||||
#include "ValueNodeManager.h"
|
#include "ValueNodeManager.h"
|
||||||
|
#include "Variable.h"
|
||||||
|
|
||||||
|
|
||||||
ExpressionEvaluationJob::ExpressionEvaluationJob(Team* team,
|
ExpressionEvaluationJob::ExpressionEvaluationJob(Team* team,
|
||||||
@@ -89,10 +90,8 @@ ExpressionEvaluationJob::Do()
|
|||||||
}
|
}
|
||||||
|
|
||||||
ValueNode* neededNode = NULL;
|
ValueNode* neededNode = NULL;
|
||||||
PrimitiveType* type = dynamic_cast<PrimitiveType*>(
|
|
||||||
fExpressionInfo->ResultType());
|
|
||||||
result = fLanguage->EvaluateExpression(fExpressionInfo->Expression(),
|
result = fLanguage->EvaluateExpression(fExpressionInfo->Expression(),
|
||||||
type->TypeConstant(), fManager, fResultValue, neededNode);
|
fManager, fResultValue, neededNode);
|
||||||
if (neededNode != NULL) {
|
if (neededNode != NULL) {
|
||||||
result = ResolveNodeValue(neededNode);
|
result = ResolveNodeValue(neededNode);
|
||||||
if (State() == JOB_STATE_WAITING)
|
if (State() == JOB_STATE_WAITING)
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class BVariant;
|
|||||||
class CpuState;
|
class CpuState;
|
||||||
class DebuggerInterface;
|
class DebuggerInterface;
|
||||||
class ExpressionInfo;
|
class ExpressionInfo;
|
||||||
|
class ExpressionResult;
|
||||||
class Function;
|
class Function;
|
||||||
class FunctionInstance;
|
class FunctionInstance;
|
||||||
class Image;
|
class Image;
|
||||||
@@ -245,7 +246,7 @@ public:
|
|||||||
virtual const JobKey& Key() const;
|
virtual const JobKey& Key() const;
|
||||||
virtual status_t Do();
|
virtual status_t Do();
|
||||||
|
|
||||||
Value* GetResultValue() const { return fResultValue; }
|
ExpressionResult* GetResult() const { return fResultValue; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
status_t ResolveNodeValue(ValueNode* node);
|
status_t ResolveNodeValue(ValueNode* node);
|
||||||
@@ -261,7 +262,7 @@ private:
|
|||||||
StackFrame* fFrame;
|
StackFrame* fFrame;
|
||||||
Thread* fThread;
|
Thread* fThread;
|
||||||
ValueNodeManager* fManager;
|
ValueNodeManager* fManager;
|
||||||
Value* fResultValue;
|
ExpressionResult* fResultValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,70 +6,123 @@
|
|||||||
|
|
||||||
#include "ExpressionInfo.h"
|
#include "ExpressionInfo.h"
|
||||||
|
|
||||||
#include "Type.h"
|
#include "Value.h"
|
||||||
|
#include "ValueNode.h"
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - ExpressionResult
|
||||||
|
|
||||||
|
|
||||||
|
ExpressionResult::ExpressionResult()
|
||||||
|
:
|
||||||
|
fResultKind(EXPRESSION_RESULT_KIND_UNKNOWN),
|
||||||
|
fPrimitiveValue(NULL),
|
||||||
|
fValueNodeValue(NULL)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ExpressionResult::~ExpressionResult()
|
||||||
|
{
|
||||||
|
if (fPrimitiveValue != NULL)
|
||||||
|
fPrimitiveValue->ReleaseReference();
|
||||||
|
|
||||||
|
if (fValueNodeValue != NULL)
|
||||||
|
fValueNodeValue->ReleaseReference();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ExpressionResult::SetToPrimitive(Value* value)
|
||||||
|
{
|
||||||
|
_Unset();
|
||||||
|
|
||||||
|
fPrimitiveValue = value;
|
||||||
|
if (fPrimitiveValue != NULL) {
|
||||||
|
fPrimitiveValue->AcquireReference();
|
||||||
|
fResultKind = EXPRESSION_RESULT_KIND_PRIMITIVE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ExpressionResult::SetToValueNode(ValueNodeChild* child)
|
||||||
|
{
|
||||||
|
_Unset();
|
||||||
|
|
||||||
|
fValueNodeValue = child;
|
||||||
|
if (fValueNodeValue != NULL) {
|
||||||
|
fValueNodeValue->AcquireReference();
|
||||||
|
fResultKind = EXPRESSION_RESULT_KIND_VALUE_NODE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if the child has a node with a resolved value, store
|
||||||
|
// it as a primitive, so the consumer of the expression
|
||||||
|
// can use it as-is if desired.
|
||||||
|
|
||||||
|
ValueNode* node = child->Node();
|
||||||
|
if (node == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
fPrimitiveValue = node->GetValue();
|
||||||
|
if (fPrimitiveValue != NULL)
|
||||||
|
fPrimitiveValue->AcquireReference();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ExpressionResult::_Unset()
|
||||||
|
{
|
||||||
|
if (fPrimitiveValue != NULL) {
|
||||||
|
fPrimitiveValue->ReleaseReference();
|
||||||
|
fPrimitiveValue = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fValueNodeValue != NULL) {
|
||||||
|
fValueNodeValue->ReleaseReference();
|
||||||
|
fValueNodeValue = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
fResultKind = EXPRESSION_RESULT_KIND_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - ExpressionInfo
|
||||||
|
|
||||||
|
|
||||||
ExpressionInfo::ExpressionInfo()
|
ExpressionInfo::ExpressionInfo()
|
||||||
:
|
:
|
||||||
fExpression(),
|
fExpression()
|
||||||
fResultType(NULL)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ExpressionInfo::ExpressionInfo(const ExpressionInfo& other)
|
ExpressionInfo::ExpressionInfo(const ExpressionInfo& other)
|
||||||
:
|
:
|
||||||
fExpression(other.fExpression),
|
fExpression(other.fExpression)
|
||||||
fResultType(other.fResultType)
|
|
||||||
{
|
{
|
||||||
if (fResultType != NULL)
|
|
||||||
fResultType->AcquireReference();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ExpressionInfo::~ExpressionInfo()
|
ExpressionInfo::~ExpressionInfo()
|
||||||
{
|
{
|
||||||
SetResultType(NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ExpressionInfo::ExpressionInfo(const BString& expression, Type* resultType)
|
ExpressionInfo::ExpressionInfo(const BString& expression)
|
||||||
:
|
:
|
||||||
fExpression(expression),
|
fExpression(expression)
|
||||||
fResultType(resultType)
|
|
||||||
{
|
{
|
||||||
if (resultType != NULL)
|
|
||||||
resultType->AcquireReference();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ExpressionInfo::SetTo(const BString& expression, Type* resultType)
|
ExpressionInfo::SetTo(const BString& expression)
|
||||||
{
|
|
||||||
SetExpression(expression);
|
|
||||||
SetResultType(resultType);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ExpressionInfo::SetExpression(const BString& expression)
|
|
||||||
{
|
{
|
||||||
fExpression = expression;
|
fExpression = expression;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ExpressionInfo::SetResultType(Type* resultType)
|
|
||||||
{
|
|
||||||
if (fResultType != NULL)
|
|
||||||
fResultType->ReleaseReference();
|
|
||||||
|
|
||||||
fResultType = resultType;
|
|
||||||
if (fResultType != NULL)
|
|
||||||
fResultType->AcquireReference();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ExpressionInfo::AddListener(Listener* listener)
|
ExpressionInfo::AddListener(Listener* listener)
|
||||||
{
|
{
|
||||||
@@ -85,7 +138,8 @@ ExpressionInfo::RemoveListener(Listener* listener)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ExpressionInfo::NotifyExpressionEvaluated(status_t result, Value* value)
|
ExpressionInfo::NotifyExpressionEvaluated(status_t result,
|
||||||
|
ExpressionResult* value)
|
||||||
{
|
{
|
||||||
for (ListenerList::Iterator it = fListeners.GetIterator();
|
for (ListenerList::Iterator it = fListeners.GetIterator();
|
||||||
Listener* listener = it.Next();) {
|
Listener* listener = it.Next();) {
|
||||||
|
|||||||
@@ -10,9 +10,44 @@
|
|||||||
|
|
||||||
#include <Referenceable.h>
|
#include <Referenceable.h>
|
||||||
#include <util/DoublyLinkedList.h>
|
#include <util/DoublyLinkedList.h>
|
||||||
|
#include <Variant.h>
|
||||||
|
|
||||||
|
|
||||||
class Type;
|
|
||||||
class Value;
|
class Value;
|
||||||
|
class ValueNodeChild;
|
||||||
|
|
||||||
|
|
||||||
|
enum expression_result_kind {
|
||||||
|
EXPRESSION_RESULT_KIND_UNKNOWN = 0,
|
||||||
|
EXPRESSION_RESULT_KIND_PRIMITIVE,
|
||||||
|
EXPRESSION_RESULT_KIND_VALUE_NODE
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class ExpressionResult : public BReferenceable {
|
||||||
|
public:
|
||||||
|
ExpressionResult();
|
||||||
|
virtual ~ExpressionResult();
|
||||||
|
|
||||||
|
|
||||||
|
expression_result_kind Kind() const { return fResultKind; }
|
||||||
|
|
||||||
|
Value* PrimitiveValue() const
|
||||||
|
{ return fPrimitiveValue; }
|
||||||
|
ValueNodeChild* ValueNodeValue() const
|
||||||
|
{ return fValueNodeValue; }
|
||||||
|
|
||||||
|
void SetToPrimitive(Value* value);
|
||||||
|
void SetToValueNode(ValueNodeChild* child);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void _Unset();
|
||||||
|
|
||||||
|
private:
|
||||||
|
expression_result_kind fResultKind;
|
||||||
|
Value* fPrimitiveValue;
|
||||||
|
ValueNodeChild* fValueNodeValue;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class ExpressionInfo : public BReferenceable {
|
class ExpressionInfo : public BReferenceable {
|
||||||
@@ -22,31 +57,24 @@ public:
|
|||||||
public:
|
public:
|
||||||
ExpressionInfo();
|
ExpressionInfo();
|
||||||
ExpressionInfo(const ExpressionInfo& other);
|
ExpressionInfo(const ExpressionInfo& other);
|
||||||
ExpressionInfo(const BString& expression,
|
ExpressionInfo(const BString& expression);
|
||||||
Type* resultType);
|
|
||||||
virtual ~ExpressionInfo();
|
virtual ~ExpressionInfo();
|
||||||
|
|
||||||
void SetTo(const BString& expression,
|
void SetTo(const BString& expression);
|
||||||
Type* resultType);
|
|
||||||
|
|
||||||
const BString& Expression() const { return fExpression; }
|
const BString& Expression() const { return fExpression; }
|
||||||
void SetExpression(const BString& expression);
|
|
||||||
|
|
||||||
Type* ResultType() const { return fResultType; }
|
|
||||||
void SetResultType(Type* resultType);
|
|
||||||
|
|
||||||
void AddListener(Listener* listener);
|
void AddListener(Listener* listener);
|
||||||
void RemoveListener(Listener* listener);
|
void RemoveListener(Listener* listener);
|
||||||
|
|
||||||
void NotifyExpressionEvaluated(status_t result,
|
void NotifyExpressionEvaluated(status_t result,
|
||||||
Value* value);
|
ExpressionResult* value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef DoublyLinkedList<Listener> ListenerList;
|
typedef DoublyLinkedList<Listener> ListenerList;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BString fExpression;
|
BString fExpression;
|
||||||
Type* fResultType;
|
|
||||||
ListenerList fListeners;
|
ListenerList fListeners;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -56,7 +84,8 @@ public:
|
|||||||
virtual ~Listener();
|
virtual ~Listener();
|
||||||
|
|
||||||
virtual void ExpressionEvaluated(ExpressionInfo* info,
|
virtual void ExpressionEvaluated(ExpressionInfo* info,
|
||||||
status_t result, Value* value) = 0;
|
status_t result,
|
||||||
|
ExpressionResult* value) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,11 +11,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "CLanguageExpressionEvaluator.h"
|
#include "CLanguageExpressionEvaluator.h"
|
||||||
#include "FloatValue.h"
|
#include "ExpressionInfo.h"
|
||||||
#include "IntegerValue.h"
|
|
||||||
#include "Number.h"
|
|
||||||
#include "StringValue.h"
|
|
||||||
#include "TeamTypeInformation.h"
|
#include "TeamTypeInformation.h"
|
||||||
|
#include "StringValue.h"
|
||||||
#include "Type.h"
|
#include "Type.h"
|
||||||
#include "TypeLookupConstraints.h"
|
#include "TypeLookupConstraints.h"
|
||||||
|
|
||||||
@@ -167,46 +165,28 @@ CLanguageFamily::ParseTypeExpression(const BString& expression,
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
CLanguageFamily::EvaluateExpression(const BString& expression, type_code type,
|
CLanguageFamily::EvaluateExpression(const BString& expression,
|
||||||
ValueNodeManager* manager, Value*& _output, ValueNode*& _neededNode)
|
ValueNodeManager* manager, ExpressionResult*& _output,
|
||||||
|
ValueNode*& _neededNode)
|
||||||
{
|
{
|
||||||
_output = NULL;
|
_output = NULL;
|
||||||
_neededNode = NULL;
|
_neededNode = NULL;
|
||||||
CLanguageExpressionEvaluator evaluator;
|
CLanguageExpressionEvaluator evaluator;
|
||||||
Number result;
|
|
||||||
try {
|
try {
|
||||||
result = evaluator.Evaluate(expression, type, manager);
|
_output = evaluator.Evaluate(expression, manager);
|
||||||
BVariant resultValue = result.GetValue();
|
|
||||||
switch (type) {
|
|
||||||
case B_INT8_TYPE:
|
|
||||||
case B_UINT8_TYPE:
|
|
||||||
case B_INT16_TYPE:
|
|
||||||
case B_UINT16_TYPE:
|
|
||||||
case B_INT32_TYPE:
|
|
||||||
case B_UINT32_TYPE:
|
|
||||||
case B_INT64_TYPE:
|
|
||||||
case B_UINT64_TYPE:
|
|
||||||
_output = new(std::nothrow) IntegerValue(resultValue);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case B_FLOAT_TYPE:
|
|
||||||
_output = new(std::nothrow) FloatValue(resultValue.ToFloat());
|
|
||||||
break;
|
|
||||||
|
|
||||||
case B_DOUBLE_TYPE:
|
|
||||||
_output = new(std::nothrow) FloatValue(resultValue.ToDouble());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_output == NULL)
|
|
||||||
return B_NO_MEMORY;
|
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
} catch (ParseException ex) {
|
} catch (ParseException ex) {
|
||||||
BString stringValue;
|
BString error;
|
||||||
stringValue.SetToFormat("Parse error at position %" B_PRId32 ": %s",
|
error.SetToFormat("Parse error at position %" B_PRId32 ": %s",
|
||||||
ex.position, ex.message.String());
|
ex.position, ex.message.String());
|
||||||
_output = new(std::nothrow) StringValue(stringValue);
|
StringValue* value = new(std::nothrow) StringValue(error.String());
|
||||||
|
if (value == NULL)
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
BReference<Value> valueReference(value, true);
|
||||||
|
_output = new(std::nothrow) ExpressionResult();
|
||||||
|
if (_output == NULL)
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
_output->SetToPrimitive(value);
|
||||||
return B_BAD_DATA;
|
return B_BAD_DATA;
|
||||||
} catch (ValueNeededException ex) {
|
} catch (ValueNeededException ex) {
|
||||||
_neededNode = ex.value;
|
_neededNode = ex.value;
|
||||||
|
|||||||
@@ -22,8 +22,9 @@ public:
|
|||||||
Type*& _resultType) const;
|
Type*& _resultType) const;
|
||||||
|
|
||||||
virtual status_t EvaluateExpression(const BString& expression,
|
virtual status_t EvaluateExpression(const BString& expression,
|
||||||
type_code type, ValueNodeManager* manager,
|
ValueNodeManager* manager,
|
||||||
Value*& _output, ValueNode*& _neededNode);
|
ExpressionResult*& _output,
|
||||||
|
ValueNode*& _neededNode);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool IsModifierValid(char modifier) const = 0;
|
virtual bool IsModifierValid(char modifier) const = 0;
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ SourceLanguage::ParseTypeExpression(const BString& expression,
|
|||||||
|
|
||||||
status_t
|
status_t
|
||||||
SourceLanguage::EvaluateExpression(const BString& expression,
|
SourceLanguage::EvaluateExpression(const BString& expression,
|
||||||
type_code type, ValueNodeManager* manager, Value*& _resultValue,
|
ValueNodeManager* manager, ExpressionResult*& _resultValue,
|
||||||
ValueNode*& _neededNode)
|
ValueNode*& _neededNode)
|
||||||
{
|
{
|
||||||
return B_NOT_SUPPORTED;
|
return B_NOT_SUPPORTED;
|
||||||
|
|||||||
@@ -11,10 +11,10 @@
|
|||||||
|
|
||||||
|
|
||||||
class BString;
|
class BString;
|
||||||
|
class ExpressionResult;
|
||||||
class SyntaxHighlighter;
|
class SyntaxHighlighter;
|
||||||
class TeamTypeInformation;
|
class TeamTypeInformation;
|
||||||
class Type;
|
class Type;
|
||||||
class Value;
|
|
||||||
class ValueNode;
|
class ValueNode;
|
||||||
class ValueNodeManager;
|
class ValueNodeManager;
|
||||||
|
|
||||||
@@ -34,8 +34,9 @@ public:
|
|||||||
Type*& _resultType) const;
|
Type*& _resultType) const;
|
||||||
|
|
||||||
virtual status_t EvaluateExpression(const BString& expression,
|
virtual status_t EvaluateExpression(const BString& expression,
|
||||||
type_code type, ValueNodeManager* manager,
|
ValueNodeManager* manager,
|
||||||
Value*& _output, ValueNode*& _neededNode);
|
ExpressionResult*& _output,
|
||||||
|
ValueNode*& _neededNode);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1361
-170
File diff suppressed because it is too large
Load Diff
+12
-12
@@ -18,6 +18,7 @@
|
|||||||
class ValueNode;
|
class ValueNode;
|
||||||
class ValueNodeChild;
|
class ValueNodeChild;
|
||||||
class ValueNodeManager;
|
class ValueNodeManager;
|
||||||
|
class Variable;
|
||||||
|
|
||||||
|
|
||||||
class ParseException {
|
class ParseException {
|
||||||
@@ -38,6 +39,7 @@ class ParseException {
|
|||||||
int32 position;
|
int32 position;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class ValueNeededException {
|
class ValueNeededException {
|
||||||
public:
|
public:
|
||||||
ValueNeededException(ValueNode* node)
|
ValueNeededException(ValueNode* node)
|
||||||
@@ -50,6 +52,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class ExpressionResult;
|
||||||
class Number;
|
class Number;
|
||||||
|
|
||||||
|
|
||||||
@@ -59,31 +62,28 @@ class CLanguageExpressionEvaluator {
|
|||||||
CLanguageExpressionEvaluator();
|
CLanguageExpressionEvaluator();
|
||||||
~CLanguageExpressionEvaluator();
|
~CLanguageExpressionEvaluator();
|
||||||
|
|
||||||
Number Evaluate(const char* expressionString,
|
ExpressionResult* Evaluate(const char* expressionString,
|
||||||
type_code type, ValueNodeManager* manager);
|
ValueNodeManager* manager);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
class Operand;
|
||||||
struct Token;
|
struct Token;
|
||||||
class Tokenizer;
|
class Tokenizer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Number _ParseSum();
|
Operand _ParseSum();
|
||||||
Number _ParseProduct();
|
Operand _ParseProduct();
|
||||||
Number _ParsePower();
|
Operand _ParsePower();
|
||||||
Number _ParseUnary();
|
Operand _ParseUnary();
|
||||||
Number _ParseIdentifier(ValueNode* parentNode = NULL);
|
Operand _ParseIdentifier(ValueNode* parentNode = NULL);
|
||||||
Number _ParseAtom();
|
Operand _ParseAtom();
|
||||||
|
|
||||||
void _EatToken(int32 type);
|
void _EatToken(int32 type);
|
||||||
|
|
||||||
void _RequestValueIfNeeded(const Token& token,
|
void _RequestValueIfNeeded(const Token& token,
|
||||||
ValueNodeChild* child);
|
ValueNodeChild* child);
|
||||||
|
|
||||||
void _CoerceTypeIfNeeded(const Token& token,
|
|
||||||
Number& _number);
|
|
||||||
|
|
||||||
Tokenizer* fTokenizer;
|
Tokenizer* fTokenizer;
|
||||||
type_code fCurrentType;
|
|
||||||
ValueNodeManager* fNodeManager;
|
ValueNodeManager* fNodeManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Rene Gollent, rene@gollent.com.
|
|
||||||
* Distributed under the terms of the MIT License.
|
|
||||||
*/
|
|
||||||
#ifndef NUMBER_H
|
|
||||||
#define NUMBER_H
|
|
||||||
|
|
||||||
#include <TypeConstants.h>
|
|
||||||
|
|
||||||
#include "Variant.h"
|
|
||||||
|
|
||||||
|
|
||||||
class BString;
|
|
||||||
|
|
||||||
|
|
||||||
class Number {
|
|
||||||
public:
|
|
||||||
Number();
|
|
||||||
virtual ~Number();
|
|
||||||
Number(type_code type, const BString& value);
|
|
||||||
Number(const BVariant& value);
|
|
||||||
Number(const Number& other);
|
|
||||||
|
|
||||||
void SetTo(type_code type, const BString& value,
|
|
||||||
int32 base = 10);
|
|
||||||
void SetTo(const BVariant& value);
|
|
||||||
|
|
||||||
type_code Type() const { return fValue.Type(); }
|
|
||||||
|
|
||||||
Number& operator=(const Number& rhs);
|
|
||||||
Number& operator+=(const Number& rhs);
|
|
||||||
Number& operator-=(const Number& rhs);
|
|
||||||
Number& operator/=(const Number& rhs);
|
|
||||||
Number& operator*=(const Number& rhs);
|
|
||||||
Number& operator%=(const Number& rhs);
|
|
||||||
|
|
||||||
Number& operator&=(const Number& rhs);
|
|
||||||
Number& operator|=(const Number& rhs);
|
|
||||||
Number& operator^=(const Number& rhs);
|
|
||||||
|
|
||||||
Number operator-() const;
|
|
||||||
Number operator~() const;
|
|
||||||
|
|
||||||
int operator<(const Number& rhs) const;
|
|
||||||
int operator<=(const Number& rhs) const;
|
|
||||||
int operator>(const Number& rhs) const;
|
|
||||||
int operator>=(const Number& rhs) const;
|
|
||||||
int operator==(const Number& rhs) const;
|
|
||||||
int operator!=(const Number& rhs) const;
|
|
||||||
|
|
||||||
BVariant GetValue() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
BVariant fValue;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif // NUMBER_H
|
|
||||||
@@ -12,8 +12,9 @@
|
|||||||
|
|
||||||
#include "StackTrace.h"
|
#include "StackTrace.h"
|
||||||
#include "UserInterface.h"
|
#include "UserInterface.h"
|
||||||
#include "Value.h"
|
|
||||||
#include "ValueNodeManager.h"
|
#include "ValueNodeManager.h"
|
||||||
|
#include "Variable.h"
|
||||||
|
|
||||||
|
|
||||||
// NOTE: This is a simple work-around for EditLine not having any kind of user
|
// NOTE: This is a simple work-around for EditLine not having any kind of user
|
||||||
// data field. Hence in _GetPrompt() we don't have access to the context object.
|
// data field. Hence in _GetPrompt() we don't have access to the context object.
|
||||||
@@ -29,7 +30,7 @@ static CliContext* sCurrentContext;
|
|||||||
struct CliContext::Event : DoublyLinkedListLinkImpl<CliContext::Event> {
|
struct CliContext::Event : DoublyLinkedListLinkImpl<CliContext::Event> {
|
||||||
Event(int type, Thread* thread = NULL, TeamMemoryBlock* block = NULL,
|
Event(int type, Thread* thread = NULL, TeamMemoryBlock* block = NULL,
|
||||||
ExpressionInfo* info = NULL, status_t expressionResult = B_OK,
|
ExpressionInfo* info = NULL, status_t expressionResult = B_OK,
|
||||||
Value* expressionValue = NULL)
|
ExpressionResult* expressionValue = NULL)
|
||||||
:
|
:
|
||||||
fType(type),
|
fType(type),
|
||||||
fThreadReference(thread),
|
fThreadReference(thread),
|
||||||
@@ -65,7 +66,7 @@ struct CliContext::Event : DoublyLinkedListLinkImpl<CliContext::Event> {
|
|||||||
return fExpressionResult;
|
return fExpressionResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value* GetExpressionValue() const
|
ExpressionResult* GetExpressionValue() const
|
||||||
{
|
{
|
||||||
return fExpressionValue.Get();
|
return fExpressionValue.Get();
|
||||||
}
|
}
|
||||||
@@ -77,7 +78,7 @@ private:
|
|||||||
BReference<TeamMemoryBlock> fMemoryBlockReference;
|
BReference<TeamMemoryBlock> fMemoryBlockReference;
|
||||||
BReference<ExpressionInfo> fExpressionInfo;
|
BReference<ExpressionInfo> fExpressionInfo;
|
||||||
status_t fExpressionResult;
|
status_t fExpressionResult;
|
||||||
BReference<Value> fExpressionValue;
|
BReference<ExpressionResult> fExpressionValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -509,7 +510,7 @@ CliContext::ThreadStackTraceChanged(const Team::ThreadEvent& threadEvent)
|
|||||||
|
|
||||||
void
|
void
|
||||||
CliContext::ExpressionEvaluated(ExpressionInfo* info, status_t result,
|
CliContext::ExpressionEvaluated(ExpressionInfo* info, status_t result,
|
||||||
Value* value)
|
ExpressionResult* value)
|
||||||
{
|
{
|
||||||
_QueueEvent(
|
_QueueEvent(
|
||||||
new(std::nothrow) Event(EVENT_EXPRESSION_EVALUATED,
|
new(std::nothrow) Event(EVENT_EXPRESSION_EVALUATED,
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public:
|
|||||||
{ return fExpressionInfo; }
|
{ return fExpressionInfo; }
|
||||||
status_t GetExpressionResult() const
|
status_t GetExpressionResult() const
|
||||||
{ return fExpressionResult; }
|
{ return fExpressionResult; }
|
||||||
Value* GetExpressionValue() const
|
ExpressionResult* GetExpressionValue() const
|
||||||
{ return fExpressionValue; }
|
{ return fExpressionValue; }
|
||||||
|
|
||||||
const char* PromptUser(const char* prompt);
|
const char* PromptUser(const char* prompt);
|
||||||
@@ -120,7 +120,7 @@ private:
|
|||||||
|
|
||||||
// ExpressionInfo::Listener
|
// ExpressionInfo::Listener
|
||||||
virtual void ExpressionEvaluated(ExpressionInfo* info,
|
virtual void ExpressionEvaluated(ExpressionInfo* info,
|
||||||
status_t result, Value* value);
|
status_t result, ExpressionResult* value);
|
||||||
|
|
||||||
// ValueNodeContainer::Listener
|
// ValueNodeContainer::Listener
|
||||||
virtual void ValueNodeChanged(ValueNodeChild* nodeChild,
|
virtual void ValueNodeChanged(ValueNodeChild* nodeChild,
|
||||||
@@ -160,7 +160,7 @@ private:
|
|||||||
|
|
||||||
ExpressionInfo* fExpressionInfo;
|
ExpressionInfo* fExpressionInfo;
|
||||||
status_t fExpressionResult;
|
status_t fExpressionResult;
|
||||||
Value* fExpressionValue;
|
ExpressionResult* fExpressionValue;
|
||||||
|
|
||||||
EventList fPendingEvents;
|
EventList fPendingEvents;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -18,12 +18,12 @@
|
|||||||
|
|
||||||
#include "CliContext.h"
|
#include "CliContext.h"
|
||||||
#include "CppLanguage.h"
|
#include "CppLanguage.h"
|
||||||
#include "SyntheticPrimitiveType.h"
|
|
||||||
#include "Team.h"
|
#include "Team.h"
|
||||||
#include "TeamMemoryBlock.h"
|
#include "TeamMemoryBlock.h"
|
||||||
#include "UiUtils.h"
|
#include "UiUtils.h"
|
||||||
#include "UserInterface.h"
|
#include "UserInterface.h"
|
||||||
#include "Value.h"
|
#include "Value.h"
|
||||||
|
#include "Variable.h"
|
||||||
|
|
||||||
|
|
||||||
CliDumpMemoryCommand::CliDumpMemoryCommand()
|
CliDumpMemoryCommand::CliDumpMemoryCommand()
|
||||||
@@ -60,22 +60,7 @@ CliDumpMemoryCommand::Execute(int argc, const char* const* argv,
|
|||||||
ExpressionInfo* info = context.GetExpressionInfo();
|
ExpressionInfo* info = context.GetExpressionInfo();
|
||||||
|
|
||||||
target_addr_t address = 0;
|
target_addr_t address = 0;
|
||||||
|
info->SetTo(argv[1]);
|
||||||
PrimitiveType* type = dynamic_cast<PrimitiveType*>(info->ResultType());
|
|
||||||
if (type == NULL || type->TypeConstant() != B_UINT64_TYPE) {
|
|
||||||
type = new(std::nothrow) SyntheticPrimitiveType(
|
|
||||||
B_UINT64_TYPE);
|
|
||||||
if (type == NULL) {
|
|
||||||
printf("Unable to evaluate expression: %s\n", strerror(B_NO_MEMORY));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
BReference<Type> typeReference(type, true);
|
|
||||||
|
|
||||||
info->SetResultType(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
info->SetExpression(argv[1]);
|
|
||||||
|
|
||||||
context.GetUserInterfaceListener()->ExpressionEvaluationRequested(
|
context.GetUserInterfaceListener()->ExpressionEvaluationRequested(
|
||||||
fLanguage, info);
|
fLanguage, info);
|
||||||
@@ -84,14 +69,17 @@ CliDumpMemoryCommand::Execute(int argc, const char* const* argv,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
BString errorMessage;
|
BString errorMessage;
|
||||||
Value* value = context.GetExpressionValue();
|
ExpressionResult* result = context.GetExpressionValue();
|
||||||
if (value != NULL) {
|
if (result != NULL) {
|
||||||
BVariant variantValue;
|
if (result->Kind() == EXPRESSION_RESULT_KIND_PRIMITIVE) {
|
||||||
value->ToVariant(variantValue);
|
Value* value = result->PrimitiveValue();
|
||||||
if (variantValue.Type() == B_UINT64_TYPE)
|
BVariant variantValue;
|
||||||
address = variantValue.ToUInt64();
|
value->ToVariant(variantValue);
|
||||||
else
|
if (variantValue.Type() == B_STRING_TYPE)
|
||||||
value->ToString(errorMessage);
|
errorMessage.SetTo(variantValue.ToString());
|
||||||
|
else
|
||||||
|
address = variantValue.ToUInt64();
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
errorMessage = strerror(context.GetExpressionResult());
|
errorMessage = strerror(context.GetExpressionResult());
|
||||||
|
|
||||||
|
|||||||
@@ -19,12 +19,11 @@
|
|||||||
#include "Architecture.h"
|
#include "Architecture.h"
|
||||||
#include "CppLanguage.h"
|
#include "CppLanguage.h"
|
||||||
#include "GuiTeamUiSettings.h"
|
#include "GuiTeamUiSettings.h"
|
||||||
|
#include "IntegerValue.h"
|
||||||
#include "MemoryView.h"
|
#include "MemoryView.h"
|
||||||
#include "MessageCodes.h"
|
#include "MessageCodes.h"
|
||||||
#include "SyntheticPrimitiveType.h"
|
|
||||||
#include "Team.h"
|
#include "Team.h"
|
||||||
#include "UserInterface.h"
|
#include "UserInterface.h"
|
||||||
#include "Value.h"
|
|
||||||
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@@ -94,9 +93,7 @@ void
|
|||||||
InspectorWindow::_Init()
|
InspectorWindow::_Init()
|
||||||
{
|
{
|
||||||
fLanguage = new CppLanguage();
|
fLanguage = new CppLanguage();
|
||||||
::Type* type = new SyntheticPrimitiveType(B_UINT64_TYPE);
|
fExpressionInfo = new ExpressionInfo();
|
||||||
BReference< ::Type> typeReference(type);
|
|
||||||
fExpressionInfo = new ExpressionInfo(NULL, type);
|
|
||||||
fExpressionInfo->AddListener(this);
|
fExpressionInfo->AddListener(this);
|
||||||
|
|
||||||
BScrollView* scrollView;
|
BScrollView* scrollView;
|
||||||
@@ -236,7 +233,7 @@ InspectorWindow::MessageReceived(BMessage* message)
|
|||||||
if (fAddressInput->TextView()->TextLength() == 0)
|
if (fAddressInput->TextView()->TextLength() == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
fExpressionInfo->SetExpression(fAddressInput->Text());
|
fExpressionInfo->SetTo(fAddressInput->Text());
|
||||||
|
|
||||||
fListener->ExpressionEvaluationRequested(fLanguage,
|
fListener->ExpressionEvaluationRequested(fLanguage,
|
||||||
fExpressionInfo);
|
fExpressionInfo);
|
||||||
@@ -247,18 +244,22 @@ InspectorWindow::MessageReceived(BMessage* message)
|
|||||||
case MSG_EXPRESSION_EVALUATED:
|
case MSG_EXPRESSION_EVALUATED:
|
||||||
{
|
{
|
||||||
BString errorMessage;
|
BString errorMessage;
|
||||||
BReference<Value> reference;
|
BReference<ExpressionResult> reference;
|
||||||
Value* value = NULL;
|
ExpressionResult* value = NULL;
|
||||||
if (message->FindPointer("value",
|
if (message->FindPointer("value",
|
||||||
reinterpret_cast<void**>(&value)) == B_OK) {
|
reinterpret_cast<void**>(&value)) == B_OK) {
|
||||||
reference.SetTo(value, true);
|
reference.SetTo(value, true);
|
||||||
BVariant variant;
|
if (value->Kind() == EXPRESSION_RESULT_KIND_PRIMITIVE) {
|
||||||
value->ToVariant(variant);
|
Value* primitive = value->PrimitiveValue();
|
||||||
if (variant.Type() == B_UINT64_TYPE) {
|
BVariant variantValue;
|
||||||
_SetToAddress(variant.ToUInt64());
|
primitive->ToVariant(variantValue);
|
||||||
break;
|
if (variantValue.Type() == B_STRING_TYPE) {
|
||||||
} else
|
errorMessage.SetTo(variantValue.ToString());
|
||||||
value->ToString(errorMessage);
|
} else {
|
||||||
|
_SetToAddress(variantValue.ToUInt64());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
status_t result = message->FindInt32("result");
|
status_t result = message->FindInt32("result");
|
||||||
errorMessage.SetToFormat("Failed to evaluate expression: %s",
|
errorMessage.SetToFormat("Failed to evaluate expression: %s",
|
||||||
@@ -385,11 +386,11 @@ InspectorWindow::TargetAddressChanged(target_addr_t address)
|
|||||||
|
|
||||||
void
|
void
|
||||||
InspectorWindow::ExpressionEvaluated(ExpressionInfo* info, status_t result,
|
InspectorWindow::ExpressionEvaluated(ExpressionInfo* info, status_t result,
|
||||||
Value* value)
|
ExpressionResult* value)
|
||||||
{
|
{
|
||||||
BMessage message(MSG_EXPRESSION_EVALUATED);
|
BMessage message(MSG_EXPRESSION_EVALUATED);
|
||||||
message.AddInt32("result", result);
|
message.AddInt32("result", result);
|
||||||
BReference<Value> reference;
|
BReference<ExpressionResult> reference;
|
||||||
if (value != NULL) {
|
if (value != NULL) {
|
||||||
reference.SetTo(value);
|
reference.SetTo(value);
|
||||||
message.AddPointer("value", value);
|
message.AddPointer("value", value);
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public:
|
|||||||
|
|
||||||
// ExpressionInfo::Listener
|
// ExpressionInfo::Listener
|
||||||
virtual void ExpressionEvaluated(ExpressionInfo* info,
|
virtual void ExpressionEvaluated(ExpressionInfo* info,
|
||||||
status_t result, Value* value);
|
status_t result, ExpressionResult* value);
|
||||||
|
|
||||||
status_t LoadSettings(
|
status_t LoadSettings(
|
||||||
const GuiTeamUiSettings& settings);
|
const GuiTeamUiSettings& settings);
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include "AutoLocker.h"
|
#include "AutoLocker.h"
|
||||||
|
|
||||||
|
#include "IntegerValue.h"
|
||||||
#include "MessageCodes.h"
|
#include "MessageCodes.h"
|
||||||
#include "SourceLanguage.h"
|
#include "SourceLanguage.h"
|
||||||
#include "StackFrame.h"
|
#include "StackFrame.h"
|
||||||
@@ -21,12 +22,6 @@
|
|||||||
#include "Thread.h"
|
#include "Thread.h"
|
||||||
#include "UiUtils.h"
|
#include "UiUtils.h"
|
||||||
#include "UserInterface.h"
|
#include "UserInterface.h"
|
||||||
#include "Value.h"
|
|
||||||
|
|
||||||
|
|
||||||
enum {
|
|
||||||
MSG_CHANGE_EVALUATION_TYPE = 'chet'
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
ExpressionEvaluationWindow::ExpressionEvaluationWindow(
|
ExpressionEvaluationWindow::ExpressionEvaluationWindow(
|
||||||
@@ -91,9 +86,8 @@ ExpressionEvaluationWindow::Create(SourceLanguage* language, StackFrame* frame,
|
|||||||
void
|
void
|
||||||
ExpressionEvaluationWindow::_Init()
|
ExpressionEvaluationWindow::_Init()
|
||||||
{
|
{
|
||||||
::Type* type = new SyntheticPrimitiveType(B_INT64_TYPE);
|
fExpressionInfo = new ExpressionInfo;
|
||||||
BReference< ::Type> typeReference(type, true);
|
fExpressionInfo->AddListener(this);
|
||||||
fExpressionInfo = new ExpressionInfo(NULL, type);
|
|
||||||
|
|
||||||
fExpressionInput = new BTextControl("Expression:", NULL,
|
fExpressionInput = new BTextControl("Expression:", NULL,
|
||||||
new BMessage(MSG_EVALUATE_EXPRESSION));
|
new BMessage(MSG_EVALUATE_EXPRESSION));
|
||||||
@@ -107,16 +101,11 @@ ExpressionEvaluationWindow::_Init()
|
|||||||
fExpressionOutput->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED,
|
fExpressionOutput->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED,
|
||||||
B_SIZE_UNSET));
|
B_SIZE_UNSET));
|
||||||
|
|
||||||
BMenuField* typeField = new BMenuField("Type:", _BuildTypesMenu());
|
|
||||||
typeField->Menu()->SetTargetForItems(this);
|
|
||||||
|
|
||||||
BLayoutBuilder::Group<>(this, B_VERTICAL)
|
BLayoutBuilder::Group<>(this, B_VERTICAL)
|
||||||
.SetInsets(B_USE_DEFAULT_SPACING)
|
.SetInsets(B_USE_DEFAULT_SPACING)
|
||||||
.AddGroup(B_HORIZONTAL, 4.0f)
|
.AddGroup(B_HORIZONTAL, 4.0f)
|
||||||
.Add(labelItem)
|
.Add(labelItem)
|
||||||
.Add(inputItem)
|
.Add(inputItem)
|
||||||
.Add(typeField->CreateLabelLayoutItem())
|
|
||||||
.Add(typeField->CreateMenuBarLayoutItem())
|
|
||||||
.End()
|
.End()
|
||||||
.AddGroup(B_HORIZONTAL, 4.0f)
|
.AddGroup(B_HORIZONTAL, 4.0f)
|
||||||
.Add(new BStringView("OutputLabelView", "Result:"))
|
.Add(new BStringView("OutputLabelView", "Result:"))
|
||||||
@@ -130,54 +119,18 @@ ExpressionEvaluationWindow::_Init()
|
|||||||
|
|
||||||
fExpressionInput->SetTarget(this);
|
fExpressionInput->SetTarget(this);
|
||||||
fEvaluateButton->SetTarget(this);
|
fEvaluateButton->SetTarget(this);
|
||||||
|
fEvaluateButton->MakeDefault(true);
|
||||||
fExpressionInput->TextView()->MakeFocus(true);
|
fExpressionInput->TextView()->MakeFocus(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BMenu*
|
|
||||||
ExpressionEvaluationWindow::_BuildTypesMenu()
|
|
||||||
{
|
|
||||||
BMenu* menu = new BMenu("Types");
|
|
||||||
menu->SetLabelFromMarked(true);
|
|
||||||
|
|
||||||
_AddMenuItemForType(menu, B_INT8_TYPE);
|
|
||||||
_AddMenuItemForType(menu, B_UINT8_TYPE);
|
|
||||||
_AddMenuItemForType(menu, B_INT16_TYPE);
|
|
||||||
_AddMenuItemForType(menu, B_UINT16_TYPE);
|
|
||||||
_AddMenuItemForType(menu, B_INT32_TYPE);
|
|
||||||
_AddMenuItemForType(menu, B_UINT32_TYPE);
|
|
||||||
BMenuItem* item = _AddMenuItemForType(menu, B_INT64_TYPE);
|
|
||||||
if (item != NULL)
|
|
||||||
item->SetMarked(true);
|
|
||||||
|
|
||||||
_AddMenuItemForType(menu, B_UINT64_TYPE);
|
|
||||||
_AddMenuItemForType(menu, B_FLOAT_TYPE);
|
|
||||||
_AddMenuItemForType(menu, B_DOUBLE_TYPE);
|
|
||||||
|
|
||||||
return menu;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BMenuItem*
|
|
||||||
ExpressionEvaluationWindow::_AddMenuItemForType(BMenu* menu, type_code type)
|
|
||||||
{
|
|
||||||
BMessage *message = new BMessage(MSG_CHANGE_EVALUATION_TYPE);
|
|
||||||
message->AddInt32("type", type);
|
|
||||||
|
|
||||||
BMenuItem* item = new BMenuItem(UiUtils::TypeCodeToString(type), message);
|
|
||||||
menu->AddItem(item);
|
|
||||||
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ExpressionEvaluationWindow::ExpressionEvaluated(ExpressionInfo* info,
|
ExpressionEvaluationWindow::ExpressionEvaluated(ExpressionInfo* info,
|
||||||
status_t result, Value* value)
|
status_t result, ExpressionResult* value)
|
||||||
{
|
{
|
||||||
BMessage message(MSG_EXPRESSION_EVALUATED);
|
BMessage message(MSG_EXPRESSION_EVALUATED);
|
||||||
message.AddInt32("result", result);
|
message.AddInt32("result", result);
|
||||||
BReference<Value> reference;
|
BReference<ExpressionResult> reference;
|
||||||
if (value != NULL) {
|
if (value != NULL) {
|
||||||
message.AddPointer("value", value);
|
message.AddPointer("value", value);
|
||||||
reference.SetTo(value);
|
reference.SetTo(value);
|
||||||
@@ -215,35 +168,16 @@ ExpressionEvaluationWindow::MessageReceived(BMessage* message)
|
|||||||
if (fExpressionInput->TextView()->TextLength() == 0)
|
if (fExpressionInput->TextView()->TextLength() == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
fExpressionInfo->SetExpression(fExpressionInput->Text());
|
fExpressionInfo->SetTo(fExpressionInput->Text());
|
||||||
|
|
||||||
fListener->ExpressionEvaluationRequested(fLanguage,
|
fListener->ExpressionEvaluationRequested(fLanguage,
|
||||||
fExpressionInfo, fStackFrame, fThread);
|
fExpressionInfo, fStackFrame, fThread);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case MSG_CHANGE_EVALUATION_TYPE:
|
|
||||||
{
|
|
||||||
uint32 typeConstant = message->FindInt32("type");
|
|
||||||
PrimitiveType* type = dynamic_cast<PrimitiveType*>(
|
|
||||||
fExpressionInfo->ResultType());
|
|
||||||
if (type->TypeConstant() == typeConstant)
|
|
||||||
break;
|
|
||||||
|
|
||||||
type = new(std::nothrow) SyntheticPrimitiveType(
|
|
||||||
typeConstant);
|
|
||||||
if (type == NULL)
|
|
||||||
break;
|
|
||||||
|
|
||||||
BReference< ::Type> typeReference(type, true);
|
|
||||||
fExpressionInfo->SetResultType(type);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case MSG_EXPRESSION_EVALUATED:
|
case MSG_EXPRESSION_EVALUATED:
|
||||||
{
|
{
|
||||||
Value* value = NULL;
|
ExpressionResult* value = NULL;
|
||||||
BReference<Value> reference;
|
BReference<ExpressionResult> reference;
|
||||||
if (message->FindPointer("value",
|
if (message->FindPointer("value",
|
||||||
reinterpret_cast<void**>(&value)) == B_OK) {
|
reinterpret_cast<void**>(&value)) == B_OK) {
|
||||||
reference.SetTo(value, true);
|
reference.SetTo(value, true);
|
||||||
@@ -251,14 +185,20 @@ ExpressionEvaluationWindow::MessageReceived(BMessage* message)
|
|||||||
|
|
||||||
BString outputText;
|
BString outputText;
|
||||||
if (value != NULL) {
|
if (value != NULL) {
|
||||||
BVariant variantValue;
|
if (value->Kind() == EXPRESSION_RESULT_KIND_PRIMITIVE) {
|
||||||
value->ToVariant(variantValue);
|
Value* primitive = value->PrimitiveValue();
|
||||||
if (variantValue.TypeIsInteger(variantValue.Type())) {
|
if (dynamic_cast<IntegerValue*>(primitive) != NULL) {
|
||||||
value->ToString(outputText);
|
BVariant variantValue;
|
||||||
outputText.SetToFormat("%#" B_PRIx64 " (%s)",
|
primitive->ToVariant(variantValue);
|
||||||
variantValue.ToUInt64(), outputText.String());
|
primitive->ToString(outputText);
|
||||||
} else
|
outputText.SetToFormat("%#" B_PRIx64 " (%s)",
|
||||||
value->ToString(outputText);
|
variantValue.ToUInt64(), outputText.String());
|
||||||
|
} else
|
||||||
|
primitive->ToString(outputText);
|
||||||
|
} else {
|
||||||
|
outputText.SetToFormat("Unsupported result type: %d",
|
||||||
|
value->Kind());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
status_t result;
|
status_t result;
|
||||||
if (message->FindInt32("result", &result) != B_OK)
|
if (message->FindInt32("result", &result) != B_OK)
|
||||||
@@ -271,8 +211,6 @@ ExpressionEvaluationWindow::MessageReceived(BMessage* message)
|
|||||||
fExpressionOutput->SetText(outputText);
|
fExpressionOutput->SetText(outputText);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BWindow::MessageReceived(message);
|
BWindow::MessageReceived(message);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -9,16 +9,12 @@
|
|||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
#include "ExpressionInfo.h"
|
#include "ExpressionInfo.h"
|
||||||
#include "types/Types.h"
|
|
||||||
|
|
||||||
|
|
||||||
class BMenu;
|
|
||||||
class BMenuItem;
|
|
||||||
class BButton;
|
class BButton;
|
||||||
class BStringView;
|
class BStringView;
|
||||||
class BTextControl;
|
class BTextControl;
|
||||||
class Thread;
|
class Thread;
|
||||||
class PrimitiveType;
|
|
||||||
class SourceLanguage;
|
class SourceLanguage;
|
||||||
class StackFrame;
|
class StackFrame;
|
||||||
class UserInterfaceListener;
|
class UserInterfaceListener;
|
||||||
@@ -53,13 +49,10 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void _Init();
|
void _Init();
|
||||||
BMenu* _BuildTypesMenu();
|
|
||||||
BMenuItem* _AddMenuItemForType(BMenu* menu,
|
|
||||||
type_code type);
|
|
||||||
|
|
||||||
// ExpressionInfo::Listener
|
// ExpressionInfo::Listener
|
||||||
virtual void ExpressionEvaluated(ExpressionInfo* info,
|
virtual void ExpressionEvaluated(ExpressionInfo* info,
|
||||||
status_t result, Value* value);
|
status_t result, ExpressionResult* value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SourceLanguage* fLanguage;
|
SourceLanguage* fLanguage;
|
||||||
|
|||||||
@@ -6,17 +6,10 @@
|
|||||||
|
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
#include <LayoutBuilder.h>
|
#include <LayoutBuilder.h>
|
||||||
#include <MenuField.h>
|
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <TextControl.h>
|
#include <TextControl.h>
|
||||||
|
|
||||||
#include "MessageCodes.h"
|
#include "MessageCodes.h"
|
||||||
#include "UiUtils.h"
|
|
||||||
|
|
||||||
|
|
||||||
enum {
|
|
||||||
MSG_CHANGE_EVALUATION_TYPE = 'chet',
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
ExpressionPromptWindow::ExpressionPromptWindow(BHandler* addTarget,
|
ExpressionPromptWindow::ExpressionPromptWindow(BHandler* addTarget,
|
||||||
@@ -28,8 +21,7 @@ ExpressionPromptWindow::ExpressionPromptWindow(BHandler* addTarget,
|
|||||||
fCancelButton(NULL),
|
fCancelButton(NULL),
|
||||||
fAddButton(NULL),
|
fAddButton(NULL),
|
||||||
fAddTarget(addTarget),
|
fAddTarget(addTarget),
|
||||||
fCloseTarget(closeTarget),
|
fCloseTarget(closeTarget)
|
||||||
fCurrentType(B_INT64_TYPE)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,16 +60,11 @@ ExpressionPromptWindow::_Init()
|
|||||||
inputItem->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
|
inputItem->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
|
||||||
labelItem->View()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
labelItem->View()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
|
||||||
BMenuField* typeField = new BMenuField("Type:", _BuildTypesMenu());
|
|
||||||
typeField->Menu()->SetTargetForItems(this);
|
|
||||||
|
|
||||||
BLayoutBuilder::Group<>(this, B_VERTICAL)
|
BLayoutBuilder::Group<>(this, B_VERTICAL)
|
||||||
.SetInsets(B_USE_DEFAULT_SPACING)
|
.SetInsets(B_USE_DEFAULT_SPACING)
|
||||||
.AddGroup(B_HORIZONTAL, 4.0f)
|
.AddGroup(B_HORIZONTAL, 4.0f)
|
||||||
.Add(labelItem)
|
.Add(labelItem)
|
||||||
.Add(inputItem)
|
.Add(inputItem)
|
||||||
.Add(typeField->CreateLabelLayoutItem())
|
|
||||||
.Add(typeField->CreateMenuBarLayoutItem())
|
|
||||||
.End()
|
.End()
|
||||||
.AddGroup(B_HORIZONTAL, 4.0f)
|
.AddGroup(B_HORIZONTAL, 4.0f)
|
||||||
.AddGlue()
|
.AddGlue()
|
||||||
@@ -95,43 +82,6 @@ ExpressionPromptWindow::_Init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BMenu*
|
|
||||||
ExpressionPromptWindow::_BuildTypesMenu()
|
|
||||||
{
|
|
||||||
BMenu* menu = new BMenu("Types");
|
|
||||||
menu->SetLabelFromMarked(true);
|
|
||||||
|
|
||||||
_AddMenuItemForType(menu, B_INT8_TYPE);
|
|
||||||
_AddMenuItemForType(menu, B_UINT8_TYPE);
|
|
||||||
_AddMenuItemForType(menu, B_INT16_TYPE);
|
|
||||||
_AddMenuItemForType(menu, B_UINT16_TYPE);
|
|
||||||
_AddMenuItemForType(menu, B_INT32_TYPE);
|
|
||||||
_AddMenuItemForType(menu, B_UINT32_TYPE);
|
|
||||||
BMenuItem* item = _AddMenuItemForType(menu, B_INT64_TYPE);
|
|
||||||
if (item != NULL)
|
|
||||||
item->SetMarked(true);
|
|
||||||
|
|
||||||
_AddMenuItemForType(menu, B_UINT64_TYPE);
|
|
||||||
_AddMenuItemForType(menu, B_FLOAT_TYPE);
|
|
||||||
_AddMenuItemForType(menu, B_DOUBLE_TYPE);
|
|
||||||
|
|
||||||
return menu;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BMenuItem*
|
|
||||||
ExpressionPromptWindow::_AddMenuItemForType(BMenu* menu, type_code type)
|
|
||||||
{
|
|
||||||
BMessage *message = new BMessage(MSG_CHANGE_EVALUATION_TYPE);
|
|
||||||
message->AddInt32("type", type);
|
|
||||||
|
|
||||||
BMenuItem* item = new BMenuItem(UiUtils::TypeCodeToString(type), message);
|
|
||||||
menu->AddItem(item);
|
|
||||||
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ExpressionPromptWindow::Show()
|
ExpressionPromptWindow::Show()
|
||||||
{
|
{
|
||||||
@@ -154,17 +104,10 @@ void
|
|||||||
ExpressionPromptWindow::MessageReceived(BMessage* message)
|
ExpressionPromptWindow::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
case MSG_CHANGE_EVALUATION_TYPE:
|
|
||||||
{
|
|
||||||
fCurrentType = message->FindInt32("type");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case MSG_ADD_NEW_EXPRESSION:
|
case MSG_ADD_NEW_EXPRESSION:
|
||||||
{
|
{
|
||||||
BMessage addMessage(MSG_EXPRESSION_PROMPT_WINDOW_CLOSED);
|
BMessage addMessage(MSG_EXPRESSION_PROMPT_WINDOW_CLOSED);
|
||||||
addMessage.AddString("expression", fExpressionInput->Text());
|
addMessage.AddString("expression", fExpressionInput->Text());
|
||||||
addMessage.AddInt32("type", fCurrentType);
|
|
||||||
addMessage.AddMessenger("target", BMessenger(fAddTarget));
|
addMessage.AddMessenger("target", BMessenger(fAddTarget));
|
||||||
|
|
||||||
BMessenger(fCloseTarget).SendMessage(&addMessage);
|
BMessenger(fCloseTarget).SendMessage(&addMessage);
|
||||||
|
|||||||
@@ -10,8 +10,6 @@
|
|||||||
|
|
||||||
|
|
||||||
class BButton;
|
class BButton;
|
||||||
class BMenu;
|
|
||||||
class BMenuItem;
|
|
||||||
class BTextControl;
|
class BTextControl;
|
||||||
|
|
||||||
|
|
||||||
@@ -35,9 +33,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void _Init();
|
void _Init();
|
||||||
BMenu* _BuildTypesMenu();
|
|
||||||
BMenuItem* _AddMenuItemForType(BMenu* menu,
|
|
||||||
type_code type);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BTextControl* fExpressionInput;
|
BTextControl* fExpressionInput;
|
||||||
@@ -45,7 +40,6 @@ private:
|
|||||||
BButton* fAddButton;
|
BButton* fAddButton;
|
||||||
BHandler* fAddTarget;
|
BHandler* fAddTarget;
|
||||||
BHandler* fCloseTarget;
|
BHandler* fCloseTarget;
|
||||||
type_code fCurrentType;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EXPRESSION_PROMPT_WINDOW_H
|
#endif // EXPRESSION_PROMPT_WINDOW_H
|
||||||
|
|||||||
@@ -406,15 +406,12 @@ TeamWindow::MessageReceived(BMessage* message)
|
|||||||
fExpressionPromptWindow = NULL;
|
fExpressionPromptWindow = NULL;
|
||||||
|
|
||||||
const char* expression;
|
const char* expression;
|
||||||
int32 type;
|
|
||||||
BMessenger targetMessenger;
|
BMessenger targetMessenger;
|
||||||
if (message->FindString("expression", &expression) == B_OK
|
if (message->FindString("expression", &expression) == B_OK
|
||||||
&& message->FindInt32("type", &type) == B_OK
|
|
||||||
&& message->FindMessenger("target", &targetMessenger)
|
&& message->FindMessenger("target", &targetMessenger)
|
||||||
== B_OK) {
|
== B_OK) {
|
||||||
BMessage addMessage(MSG_ADD_NEW_EXPRESSION);
|
BMessage addMessage(MSG_ADD_NEW_EXPRESSION);
|
||||||
addMessage.AddString("expression", expression);
|
addMessage.AddString("expression", expression);
|
||||||
addMessage.AddInt32("type", type);
|
|
||||||
|
|
||||||
targetMessenger.SendMessage(&addMessage);
|
targetMessenger.SendMessage(&addMessage);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1944,18 +1944,11 @@ VariablesView::MessageReceived(BMessage* message)
|
|||||||
case MSG_ADD_NEW_EXPRESSION:
|
case MSG_ADD_NEW_EXPRESSION:
|
||||||
{
|
{
|
||||||
const char* expression;
|
const char* expression;
|
||||||
int32 type;
|
if (message->FindString("expression", &expression) != B_OK)
|
||||||
Type* resultType;
|
|
||||||
if (message->FindString("expression", &expression) != B_OK
|
|
||||||
|| message->FindInt32("type", &type) != B_OK
|
|
||||||
|| _GetTypeForTypeCode(type, resultType) != B_OK) {
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
BReference<Type> typeReference(resultType, true);
|
|
||||||
|
|
||||||
ExpressionInfo* info;
|
ExpressionInfo* info;
|
||||||
status_t error = _AddExpression(expression, resultType, info);
|
status_t error = _AddExpression(expression, info);
|
||||||
if (error != B_OK) {
|
if (error != B_OK) {
|
||||||
// TODO: notify user of failure
|
// TODO: notify user of failure
|
||||||
break;
|
break;
|
||||||
@@ -1969,14 +1962,14 @@ VariablesView::MessageReceived(BMessage* message)
|
|||||||
{
|
{
|
||||||
ExpressionInfo* info;
|
ExpressionInfo* info;
|
||||||
status_t result;
|
status_t result;
|
||||||
Value* value = NULL;
|
ExpressionResult* value = NULL;
|
||||||
if (message->FindPointer("info",
|
if (message->FindPointer("info",
|
||||||
reinterpret_cast<void**>(&info)) != B_OK
|
reinterpret_cast<void**>(&info)) != B_OK
|
||||||
|| message->FindInt32("result", &result) != B_OK) {
|
|| message->FindInt32("result", &result) != B_OK) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
BReference<Value> valueReference;
|
BReference<ExpressionResult> valueReference;
|
||||||
if (message->FindPointer("value", reinterpret_cast<void**>(&value))
|
if (message->FindPointer("value", reinterpret_cast<void**>(&value))
|
||||||
== B_OK) {
|
== B_OK) {
|
||||||
valueReference.SetTo(value, true);
|
valueReference.SetTo(value, true);
|
||||||
@@ -2231,12 +2224,12 @@ VariablesView::TreeTableCellMouseDown(TreeTable* table,
|
|||||||
|
|
||||||
void
|
void
|
||||||
VariablesView::ExpressionEvaluated(ExpressionInfo* info, status_t result,
|
VariablesView::ExpressionEvaluated(ExpressionInfo* info, status_t result,
|
||||||
Value* value)
|
ExpressionResult* value)
|
||||||
{
|
{
|
||||||
BMessage message(MSG_EXPRESSION_EVALUATED);
|
BMessage message(MSG_EXPRESSION_EVALUATED);
|
||||||
message.AddPointer("info", info);
|
message.AddPointer("info", info);
|
||||||
message.AddInt32("result", result);
|
message.AddInt32("result", result);
|
||||||
BReference<Value> valueReference;
|
BReference<ExpressionResult> valueReference;
|
||||||
|
|
||||||
if (value != NULL) {
|
if (value != NULL) {
|
||||||
valueReference.SetTo(value);
|
valueReference.SetTo(value);
|
||||||
@@ -2417,6 +2410,7 @@ VariablesView::_GetContextActionsForNode(ModelNode* node,
|
|||||||
BPrivate::ObjectDeleter<ContextActionList> postActionListDeleter(
|
BPrivate::ObjectDeleter<ContextActionList> postActionListDeleter(
|
||||||
_postActions);
|
_postActions);
|
||||||
|
|
||||||
|
#if 0
|
||||||
result = _AddContextAction("Add watch expression" B_UTF8_ELLIPSIS,
|
result = _AddContextAction("Add watch expression" B_UTF8_ELLIPSIS,
|
||||||
MSG_ADD_WATCH_EXPRESSION, _postActions, message);
|
MSG_ADD_WATCH_EXPRESSION, _postActions, message);
|
||||||
if (result != B_OK)
|
if (result != B_OK)
|
||||||
@@ -2429,6 +2423,7 @@ VariablesView::_GetContextActionsForNode(ModelNode* node,
|
|||||||
return result;
|
return result;
|
||||||
message->AddPointer("node", node);
|
message->AddPointer("node", node);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
preActionListDeleter.Detach();
|
preActionListDeleter.Detach();
|
||||||
postActionListDeleter.Detach();
|
postActionListDeleter.Detach();
|
||||||
@@ -2748,8 +2743,7 @@ VariablesView::_CopyVariableValueToClipboard()
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
VariablesView::_AddExpression(const char* expression, Type* resultType,
|
VariablesView::_AddExpression(const char* expression, ExpressionInfo*& _info)
|
||||||
ExpressionInfo*& _info)
|
|
||||||
{
|
{
|
||||||
// if our stack frame doesn't have an associated function,
|
// if our stack frame doesn't have an associated function,
|
||||||
// we can't add an expression
|
// we can't add an expression
|
||||||
@@ -2775,8 +2769,7 @@ VariablesView::_AddExpression(const char* expression, Type* resultType,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ExpressionInfo* info = new(std::nothrow) ExpressionInfo(expression,
|
ExpressionInfo* info = new(std::nothrow) ExpressionInfo(expression);
|
||||||
resultType);
|
|
||||||
|
|
||||||
if (info == NULL)
|
if (info == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
@@ -2829,7 +2822,7 @@ VariablesView::_RemoveExpression(ModelNode* node)
|
|||||||
status_t
|
status_t
|
||||||
VariablesView::_AddExpressionNode(ExpressionInfo* info)
|
VariablesView::_AddExpressionNode(ExpressionInfo* info)
|
||||||
{
|
{
|
||||||
Type* type = info->ResultType();
|
#if 0
|
||||||
ExpressionValueNodeChild* child
|
ExpressionValueNodeChild* child
|
||||||
= new(std::nothrow) ExpressionValueNodeChild(info->Expression(), type);
|
= new(std::nothrow) ExpressionValueNodeChild(info->Expression(), type);
|
||||||
if (child == NULL)
|
if (child == NULL)
|
||||||
@@ -2859,7 +2852,10 @@ VariablesView::_AddExpressionNode(ExpressionInfo* info)
|
|||||||
|
|
||||||
expressionNodeReference.Detach();
|
expressionNodeReference.Detach();
|
||||||
modelNodeReference.Detach();
|
modelNodeReference.Detach();
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
#endif
|
||||||
|
return B_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2890,7 +2886,7 @@ VariablesView::_RestoreExpressionNodes()
|
|||||||
|
|
||||||
void
|
void
|
||||||
VariablesView::_SetExpressionNodeValue(ExpressionInfo* info, status_t result,
|
VariablesView::_SetExpressionNodeValue(ExpressionInfo* info, status_t result,
|
||||||
Value* value)
|
ExpressionResult* value)
|
||||||
{
|
{
|
||||||
FunctionInstance* instance = fStackFrame->Function();
|
FunctionInstance* instance = fStackFrame->Function();
|
||||||
if (instance == NULL)
|
if (instance == NULL)
|
||||||
@@ -2918,7 +2914,8 @@ VariablesView::_SetExpressionNodeValue(ExpressionInfo* info, status_t result,
|
|||||||
if (child->GetExpression() != info->Expression())
|
if (child->GetExpression() != info->Expression())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
child->Node()->SetLocationAndValue(NULL, value, result);
|
child->Node()->SetLocationAndValue(NULL, value->PrimitiveValue(),
|
||||||
|
result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ private:
|
|||||||
|
|
||||||
// ExpressionInfo::Listener
|
// ExpressionInfo::Listener
|
||||||
virtual void ExpressionEvaluated(ExpressionInfo* info,
|
virtual void ExpressionEvaluated(ExpressionInfo* info,
|
||||||
status_t result, Value* value);
|
status_t result, ExpressionResult* value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class ContainerListener;
|
class ContainerListener;
|
||||||
@@ -110,7 +110,6 @@ private:
|
|||||||
void _CopyVariableValueToClipboard();
|
void _CopyVariableValueToClipboard();
|
||||||
|
|
||||||
status_t _AddExpression(const char* expression,
|
status_t _AddExpression(const char* expression,
|
||||||
Type* resultType,
|
|
||||||
ExpressionInfo*& _info);
|
ExpressionInfo*& _info);
|
||||||
void _RemoveExpression(ModelNode* node);
|
void _RemoveExpression(ModelNode* node);
|
||||||
|
|
||||||
@@ -118,7 +117,7 @@ private:
|
|||||||
void _RestoreExpressionNodes();
|
void _RestoreExpressionNodes();
|
||||||
|
|
||||||
void _SetExpressionNodeValue(ExpressionInfo* info,
|
void _SetExpressionNodeValue(ExpressionInfo* info,
|
||||||
status_t result, Value* value);
|
status_t result, ExpressionResult* value);
|
||||||
|
|
||||||
status_t _GetTypeForTypeCode(int32 typeCode,
|
status_t _GetTypeForTypeCode(int32 typeCode,
|
||||||
Type*& _resultType) const;
|
Type*& _resultType) const;
|
||||||
|
|||||||
@@ -17,10 +17,10 @@
|
|||||||
|
|
||||||
#include "Architecture.h"
|
#include "Architecture.h"
|
||||||
#include "CppLanguage.h"
|
#include "CppLanguage.h"
|
||||||
|
#include "IntegerValue.h"
|
||||||
#include "MessageCodes.h"
|
#include "MessageCodes.h"
|
||||||
#include "SyntheticPrimitiveType.h"
|
#include "SyntheticPrimitiveType.h"
|
||||||
#include "UserInterface.h"
|
#include "UserInterface.h"
|
||||||
#include "Value.h"
|
|
||||||
#include "Watchpoint.h"
|
#include "Watchpoint.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -91,21 +91,15 @@ WatchPromptWindow::_Init()
|
|||||||
{
|
{
|
||||||
fLanguage = new CppLanguage();
|
fLanguage = new CppLanguage();
|
||||||
|
|
||||||
PrimitiveType* type = new SyntheticPrimitiveType(B_UINT64_TYPE);
|
|
||||||
BReference<PrimitiveType> typeReference(type, true);
|
|
||||||
|
|
||||||
BString text;
|
BString text;
|
||||||
text.SetToFormat("0x%" B_PRIx64, fInitialAddress);
|
text.SetToFormat("0x%" B_PRIx64, fInitialAddress);
|
||||||
fAddressInput = new BTextControl("Address:", text, NULL);
|
fAddressInput = new BTextControl("Address:", text, NULL);
|
||||||
fAddressExpressionInfo = new ExpressionInfo(text, type);
|
fAddressExpressionInfo = new ExpressionInfo(text);
|
||||||
fAddressExpressionInfo->AddListener(this);
|
fAddressExpressionInfo->AddListener(this);
|
||||||
|
|
||||||
type = new SyntheticPrimitiveType(B_INT32_TYPE);
|
|
||||||
typeReference.SetTo(type, true);
|
|
||||||
|
|
||||||
text.SetToFormat("%" B_PRId32, fInitialLength);
|
text.SetToFormat("%" B_PRId32, fInitialLength);
|
||||||
fLengthInput = new BTextControl("Length:", text, NULL);
|
fLengthInput = new BTextControl("Length:", text, NULL);
|
||||||
fLengthExpressionInfo = new ExpressionInfo(text, type);
|
fLengthExpressionInfo = new ExpressionInfo(text);
|
||||||
fLengthExpressionInfo->AddListener(this);
|
fLengthExpressionInfo->AddListener(this);
|
||||||
|
|
||||||
int32 maxDebugRegisters = 0;
|
int32 maxDebugRegisters = 0;
|
||||||
@@ -170,11 +164,12 @@ WatchPromptWindow::Show()
|
|||||||
|
|
||||||
void
|
void
|
||||||
WatchPromptWindow::ExpressionEvaluated(ExpressionInfo* info, status_t result,
|
WatchPromptWindow::ExpressionEvaluated(ExpressionInfo* info, status_t result,
|
||||||
Value* value)
|
ExpressionResult* value)
|
||||||
{
|
{
|
||||||
BMessage message(MSG_EXPRESSION_EVALUATED);
|
BMessage message(MSG_EXPRESSION_EVALUATED);
|
||||||
message.AddInt32("result", result);
|
message.AddInt32("result", result);
|
||||||
BReference<Value> reference;
|
message.AddPointer("info", info);
|
||||||
|
BReference<ExpressionResult> reference;
|
||||||
if (value != NULL) {
|
if (value != NULL) {
|
||||||
reference.SetTo(value);
|
reference.SetTo(value);
|
||||||
message.AddPointer("value", value);
|
message.AddPointer("value", value);
|
||||||
@@ -192,20 +187,32 @@ WatchPromptWindow::MessageReceived(BMessage* message)
|
|||||||
case MSG_EXPRESSION_EVALUATED:
|
case MSG_EXPRESSION_EVALUATED:
|
||||||
{
|
{
|
||||||
BString errorMessage;
|
BString errorMessage;
|
||||||
BReference<Value> reference;
|
BReference<ExpressionResult> reference;
|
||||||
Value* value = NULL;
|
ExpressionResult* value = NULL;
|
||||||
|
ExpressionInfo* info = NULL;
|
||||||
|
if (message->FindPointer("info",
|
||||||
|
reinterpret_cast<void**>(&info)) != B_OK) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (message->FindPointer("value",
|
if (message->FindPointer("value",
|
||||||
reinterpret_cast<void**>(&value)) == B_OK) {
|
reinterpret_cast<void**>(&value)) == B_OK) {
|
||||||
reference.SetTo(value, true);
|
reference.SetTo(value, true);
|
||||||
BVariant variant;
|
if (value->Kind() == EXPRESSION_RESULT_KIND_PRIMITIVE) {
|
||||||
value->ToVariant(variant);
|
Value* primitive = value->PrimitiveValue();
|
||||||
if (variant.Type() == B_UINT64_TYPE) {
|
if (dynamic_cast<IntegerValue*>(primitive) != NULL) {
|
||||||
fRequestedAddress = variant.ToUInt64();
|
BVariant resultVariant;
|
||||||
break;
|
primitive->ToVariant(resultVariant);
|
||||||
} else if (variant.Type() == B_INT32_TYPE)
|
if (info == fAddressExpressionInfo) {
|
||||||
fRequestedLength = variant.ToInt32();
|
fRequestedAddress = resultVariant.ToUInt64();
|
||||||
else
|
break;
|
||||||
value->ToString(errorMessage);
|
} else
|
||||||
|
fRequestedLength = resultVariant.ToInt32();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
primitive->ToString(errorMessage);
|
||||||
|
} else
|
||||||
|
errorMessage.SetTo("Unsupported expression result.");
|
||||||
} else {
|
} else {
|
||||||
status_t result = message->FindInt32("result");
|
status_t result = message->FindInt32("result");
|
||||||
errorMessage.SetToFormat("Failed to evaluate expression: %s",
|
errorMessage.SetToFormat("Failed to evaluate expression: %s",
|
||||||
@@ -237,11 +244,11 @@ WatchPromptWindow::MessageReceived(BMessage* message)
|
|||||||
fRequestedAddress = 0;
|
fRequestedAddress = 0;
|
||||||
fRequestedLength = 0;
|
fRequestedLength = 0;
|
||||||
|
|
||||||
fAddressExpressionInfo->SetExpression(fAddressInput->Text());
|
fAddressExpressionInfo->SetTo(fAddressInput->Text());
|
||||||
fListener->ExpressionEvaluationRequested(fLanguage,
|
fListener->ExpressionEvaluationRequested(fLanguage,
|
||||||
fAddressExpressionInfo);
|
fAddressExpressionInfo);
|
||||||
|
|
||||||
fLengthExpressionInfo->SetExpression(fLengthInput->Text());
|
fLengthExpressionInfo->SetTo(fLengthInput->Text());
|
||||||
fListener->ExpressionEvaluationRequested(fLanguage,
|
fListener->ExpressionEvaluationRequested(fLanguage,
|
||||||
fLengthExpressionInfo);
|
fLengthExpressionInfo);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public:
|
|||||||
|
|
||||||
// ExpressionInfo::Listener
|
// ExpressionInfo::Listener
|
||||||
virtual void ExpressionEvaluated(ExpressionInfo* info,
|
virtual void ExpressionEvaluated(ExpressionInfo* info,
|
||||||
status_t result, Value* value);
|
status_t result, ExpressionResult* value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _Init();
|
void _Init();
|
||||||
|
|||||||
Reference in New Issue
Block a user