Fix incorrect debug hints for nested attributes

fixes #8604
This commit is contained in:
Gunnar Beutner 2015-03-05 13:18:15 +01:00
parent 4b15ec7774
commit 4a2a6d999a
2 changed files with 41 additions and 21 deletions

View File

@ -598,12 +598,17 @@ bool IndexerExpression::GetReference(ScriptFrame& frame, bool init_dict, Value *
Value vparent; Value vparent;
String vindex; String vindex;
DebugHint *psdhint = NULL; DebugHint *psdhint = NULL;
bool free_psd = false;
if (dhint)
psdhint = *dhint;
if (m_Operand1->GetReference(frame, init_dict, &vparent, &vindex, &psdhint)) { if (m_Operand1->GetReference(frame, init_dict, &vparent, &vindex, &psdhint)) {
if (init_dict && VMOps::GetField(vparent, vindex, m_Operand1->GetDebugInfo()).IsEmpty()) if (init_dict && VMOps::GetField(vparent, vindex, m_Operand1->GetDebugInfo()).IsEmpty())
VMOps::SetField(vparent, vindex, new Dictionary(), m_Operand1->GetDebugInfo()); VMOps::SetField(vparent, vindex, new Dictionary(), m_Operand1->GetDebugInfo());
*parent = VMOps::GetField(vparent, vindex, m_DebugInfo); *parent = VMOps::GetField(vparent, vindex, m_DebugInfo);
free_psd = true;
} else { } else {
ExpressionResult operand1 = m_Operand1->Evaluate(frame); ExpressionResult operand1 = m_Operand1->Evaluate(frame);
*parent = operand1.GetValue(); *parent = operand1.GetValue();
@ -615,7 +620,8 @@ bool IndexerExpression::GetReference(ScriptFrame& frame, bool init_dict, Value *
if (dhint && psdhint) if (dhint && psdhint)
*dhint = new DebugHint(psdhint->GetChild(*index)); *dhint = new DebugHint(psdhint->GetChild(*index));
delete psdhint; if (free_psd)
delete psdhint;
return true; return true;
} }

View File

@ -44,14 +44,6 @@ public:
inline void AddMessage(const String& message, const DebugInfo& di) inline void AddMessage(const String& message, const DebugInfo& di)
{ {
if (!m_Hints)
m_Hints = new Dictionary();
if (!m_Messages) {
m_Messages = new Array();
m_Hints->Set("messages", m_Messages);
}
Array::Ptr amsg = new Array(); Array::Ptr amsg = new Array();
amsg->Add(message); amsg->Add(message);
amsg->Add(di.Path); amsg->Add(di.Path);
@ -59,24 +51,18 @@ public:
amsg->Add(di.FirstColumn); amsg->Add(di.FirstColumn);
amsg->Add(di.LastLine); amsg->Add(di.LastLine);
amsg->Add(di.LastColumn); amsg->Add(di.LastColumn);
m_Messages->Add(amsg); GetMessages()->Add(amsg);
} }
inline DebugHint GetChild(const String& name) inline DebugHint GetChild(const String& name)
{ {
if (!m_Hints) Dictionary::Ptr children = GetChildren();
m_Hints = new Dictionary();
if (!m_Children) { Dictionary::Ptr child = children->Get(name);
m_Children = new Dictionary;
m_Hints->Set("properties", m_Children);
}
Dictionary::Ptr child = m_Children->Get(name);
if (!child) { if (!child) {
child = new Dictionary(); child = new Dictionary();
m_Children->Set(name, child); children->Set(name, child);
} }
return DebugHint(child); return DebugHint(child);
@ -89,8 +75,36 @@ public:
private: private:
Dictionary::Ptr m_Hints; Dictionary::Ptr m_Hints;
Array::Ptr m_Messages;
Dictionary::Ptr m_Children; Array::Ptr GetMessages(void)
{
if (!m_Hints)
m_Hints = new Dictionary();
Array::Ptr messages = m_Hints->Get("messages");
if (!messages) {
messages = new Array();
m_Hints->Set("messages", messages);
}
return messages;
}
Dictionary::Ptr GetChildren(void)
{
if (!m_Hints)
m_Hints = new Dictionary();
Dictionary::Ptr children = m_Hints->Get("properties");
if (!children) {
children = new Dictionary;
m_Hints->Set("properties", children);
}
return children;
}
}; };
enum CombinedSetOp enum CombinedSetOp