[icinga-checkins] icinga.org: icinga2/master: Fix missing debug info for nested dictionaries

git at icinga.org git at icinga.org
Sat Nov 15 12:18:24 CET 2014


Module: icinga2
Branch: master
Commit: d8e1943671765e4d82b43b183c3cb630f2cec581
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=d8e1943671765e4d82b43b183c3cb630f2cec581

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Sat Nov 15 12:17:59 2014 +0100

Fix missing debug info for nested dictionaries

fixes #7688

---

 lib/config/expression.cpp |   25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/lib/config/expression.cpp b/lib/config/expression.cpp
index d3f6914..f80c0fc 100644
--- a/lib/config/expression.cpp
+++ b/lib/config/expression.cpp
@@ -291,24 +291,27 @@ Value SetExpression::DoEvaluate(const Object::Ptr& context, DebugHint *dhint) co
 		Expression *indexExpr = m_Indexer[i];
 		String tempindex = indexExpr->Evaluate(context, dhint);
 
-		if (i == m_Indexer.size() - 1)
-			index = tempindex;
+		if (sdhint)
+			sdhint = sdhint->GetChild(tempindex);
 
-		if (i == 0) {
+		if (i == 0)
 			parent = context;
-			object = GetField(context, tempindex);
-		} else {
+		else
 			parent = object;
 
-			LiteralExpression *eparent = MakeLiteral(parent);
-			LiteralExpression *eindex = MakeLiteral(tempindex);
+		if (i == m_Indexer.size() - 1) {
+			index = tempindex;
 
-			IndexerExpression eip(eparent, eindex, m_DebugInfo);
-			object = eip.Evaluate(context, dhint);
+			/* No need to look up the last indexer's value if this is a direct set */
+			if (m_Op == OpSetLiteral)
+				break;
 		}
 
-		if (sdhint)
-			sdhint = sdhint->GetChild(index);
+		LiteralExpression *eparent = MakeLiteral(parent);
+		LiteralExpression *eindex = MakeLiteral(tempindex);
+
+		IndexerExpression eip(eparent, eindex, m_DebugInfo);
+		object = eip.Evaluate(context, sdhint);
 
 		if (i != m_Indexer.size() - 1 && object.IsEmpty()) {
 			object = new Dictionary();



More information about the icinga-checkins mailing list