aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/corelib/language/value.cpp
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@digia.com>2014-03-21 12:24:22 +0100
committerChristian Kandeler <christian.kandeler@digia.com>2014-03-25 16:12:42 +0100
commitc0e86b13594631188d457e0a360799e7de73777d (patch)
tree07a1d0fde7f4287ba5c27bd6177798b1ffd5147c /src/lib/corelib/language/value.cpp
parent9ec57f633d8a8dabf75539d07c82617c28943162 (diff)
turn JSSourceValue::m_sourceCode into a QStringRef
Change-Id: Ie79c4dc2cc998558f826133a2a8bf08a73190f2d Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
Diffstat (limited to 'src/lib/corelib/language/value.cpp')
-rw-r--r--src/lib/corelib/language/value.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/lib/corelib/language/value.cpp b/src/lib/corelib/language/value.cpp
index f9e64182f..806905d5c 100644
--- a/src/lib/corelib/language/value.cpp
+++ b/src/lib/corelib/language/value.cpp
@@ -57,6 +57,25 @@ JSSourceValue::~JSSourceValue()
{
}
+QString JSSourceValue::sourceCodeForEvaluation() const
+{
+ if (!hasFunctionForm())
+ return m_sourceCode.toString();
+
+ // rewrite blocks to be able to use return statements in property assignments
+ static const QString prefix = "(function()";
+ static const QString suffix = ")()";
+ return prefix + m_sourceCode.toString() + suffix;
+}
+
+void JSSourceValue::setHasFunctionForm(bool b)
+{
+ if (b)
+ m_flags |= HasFunctionForm;
+ else
+ m_flags &= ~HasFunctionForm;
+}
+
ItemValue::ItemValue(Item *item)
: Value(ItemValueType)