Delay conversion of v8 exceptions to QQmlErrors.
[profile/ivi/qtdeclarative.git] / src / qml / qml / qqmlexpression.cpp
index ecdbf21..8c24c4a 100644 (file)
 
 QT_BEGIN_NAMESPACE
 
-bool QQmlDelayedError::addError(QQmlEnginePrivate *e)
-{
-    if (!e) return false;
-
-    if (e->inProgressCreations == 0) return false; // Not in construction
-
-    if (prevError) return true; // Already in error chain
-
-    prevError = &e->erroredBindings;
-    nextError = e->erroredBindings;
-    e->erroredBindings = this;
-    if (nextError) nextError->prevError = &nextError;
-
-    return true;
-}
-
-QQmlJavaScriptExpression::QQmlJavaScriptExpression(VTable *v)
-: m_vtable(v)
-{
-}
-
-QQmlJavaScriptExpression::~QQmlJavaScriptExpression()
-{
-    clearGuards();
-}
-
 static QQmlJavaScriptExpression::VTable QQmlExpressionPrivate_jsvtable = {
     QQmlExpressionPrivate::expressionIdentifier,
     QQmlExpressionPrivate::expressionChanged
@@ -86,7 +60,7 @@ static QQmlJavaScriptExpression::VTable QQmlExpressionPrivate_jsvtable = {
 QQmlExpressionPrivate::QQmlExpressionPrivate()
 : QQmlJavaScriptExpression(&QQmlExpressionPrivate_jsvtable),
   expressionFunctionValid(true), expressionFunctionRewritten(false),
-  extractExpressionFromFunction(false), line(-1), dataRef(0)
+  line(-1)
 {
 }
 
@@ -94,12 +68,9 @@ QQmlExpressionPrivate::~QQmlExpressionPrivate()
 {
     qPersistentDispose(v8qmlscope);
     qPersistentDispose(v8function);
-    if (dataRef) dataRef->release();
-    dataRef = 0;
 }
 
-void QQmlExpressionPrivate::init(QQmlContextData *ctxt, const QString &expr, 
-                                         QObject *me)
+void QQmlExpressionPrivate::init(QQmlContextData *ctxt, const QString &expr, QObject *me)
 {
     expression = expr;
 
@@ -109,22 +80,9 @@ void QQmlExpressionPrivate::init(QQmlContextData *ctxt, const QString &expr,
     expressionFunctionRewritten = false;
 }
 
-void QQmlExpressionPrivate::init(QQmlContextData *ctxt, v8::Handle<v8::Function> func,
-                                         QObject *me)
-{
-    QQmlAbstractExpression::setContext(ctxt);
-    setScopeObject(me);
-
-    v8function = qPersistentNew<v8::Function>(func);
-    setUseSharedContext(false);
-    expressionFunctionValid = true;
-    expressionFunctionRewritten = false;
-    extractExpressionFromFunction = true;
-}
-
 void QQmlExpressionPrivate::init(QQmlContextData *ctxt, const QString &expr,
-                                         bool isRewritten, QObject *me, const QString &srcUrl,
-                                         int lineNumber, int columnNumber)
+                                 bool isRewritten, QObject *me, const QString &srcUrl,
+                                 int lineNumber, int columnNumber)
 {
     url = srcUrl;
     line = lineNumber;
@@ -140,8 +98,8 @@ void QQmlExpressionPrivate::init(QQmlContextData *ctxt, const QString &expr,
 }
 
 void QQmlExpressionPrivate::init(QQmlContextData *ctxt, const QByteArray &expr,
-                                         bool isRewritten, QObject *me, const QString &srcUrl,
-                                         int lineNumber, int columnNumber)
+                                 bool isRewritten, QObject *me, const QString &srcUrl,
+                                 int lineNumber, int columnNumber)
 {
     url = srcUrl;
     line = lineNumber;
@@ -166,102 +124,19 @@ void QQmlExpressionPrivate::init(QQmlContextData *ctxt, const QByteArray &expr,
     setScopeObject(me);
 }
 
-// Callee owns the persistent handle
-v8::Persistent<v8::Function>
-QQmlExpressionPrivate::evalFunction(QQmlContextData *ctxt, QObject *scope,
-                                            const char *code, int codeLength,
-                                            const QString &filename, int line,
-                                            v8::Persistent<v8::Object> *qmlscope)
-{
-    QQmlEngine *engine = ctxt->engine;
-    QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine);
-
-    v8::HandleScope handle_scope;
-    v8::Context::Scope ctxtscope(ep->v8engine()->context());
-
-    v8::TryCatch tc;
-    v8::Local<v8::Object> scopeobject = ep->v8engine()->qmlScope(ctxt, scope);
-    v8::Local<v8::Script> script = ep->v8engine()->qmlModeCompile(code, codeLength, filename, line);
-    if (tc.HasCaught()) {
-        QQmlError error;
-        error.setDescription(QLatin1String("Exception occurred during function compilation"));
-        error.setLine(line);
-        error.setUrl(QUrl::fromLocalFile(filename));
-        v8::Local<v8::Message> message = tc.Message();
-        if (!message.IsEmpty())
-            QQmlExpressionPrivate::exceptionToError(message, error);
-        ep->warning(error);
-        return v8::Persistent<v8::Function>();
-    }
-    v8::Local<v8::Value> result = script->Run(scopeobject);
-    if (tc.HasCaught()) {
-        QQmlError error;
-        error.setDescription(QLatin1String("Exception occurred during function evaluation"));
-        error.setLine(line);
-        error.setUrl(QUrl::fromLocalFile(filename));
-        v8::Local<v8::Message> message = tc.Message();
-        if (!message.IsEmpty())
-            QQmlExpressionPrivate::exceptionToError(message, error);
-        ep->warning(error);
-        return v8::Persistent<v8::Function>();
-    }
-    if (qmlscope) *qmlscope = qPersistentNew<v8::Object>(scopeobject);
-    return qPersistentNew<v8::Function>(v8::Local<v8::Function>::Cast(result));
-}
-
-// Callee owns the persistent handle
-v8::Persistent<v8::Function> 
-QQmlExpressionPrivate::evalFunction(QQmlContextData *ctxt, QObject *scope, 
-                                            const QString &code, const QString &filename, int line,
-                                            v8::Persistent<v8::Object> *qmlscope)
-{
-    QQmlEngine *engine = ctxt->engine;
-    QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine);
-
-    v8::HandleScope handle_scope;
-    v8::Context::Scope ctxtscope(ep->v8engine()->context());
-
-    v8::TryCatch tc;
-    v8::Local<v8::Object> scopeobject = ep->v8engine()->qmlScope(ctxt, scope);
-    v8::Local<v8::Script> script = ep->v8engine()->qmlModeCompile(code, filename, line);
-    if (tc.HasCaught()) {
-        QQmlError error;
-        error.setDescription(QLatin1String("Exception occurred during function compilation"));
-        error.setLine(line);
-        error.setUrl(QUrl::fromLocalFile(filename));
-        v8::Local<v8::Message> message = tc.Message();
-        if (!message.IsEmpty())
-            QQmlExpressionPrivate::exceptionToError(message, error);
-        ep->warning(error);
-        return v8::Persistent<v8::Function>();
-    }
-    v8::Local<v8::Value> result = script->Run(scopeobject);
-    if (tc.HasCaught()) {
-        QQmlError error;
-        error.setDescription(QLatin1String("Exception occurred during function evaluation"));
-        error.setLine(line);
-        error.setUrl(QUrl::fromLocalFile(filename));
-        v8::Local<v8::Message> message = tc.Message();
-        if (!message.IsEmpty())
-            QQmlExpressionPrivate::exceptionToError(message, error);
-        ep->warning(error);
-        return v8::Persistent<v8::Function>();
-    }
-    if (qmlscope) *qmlscope = qPersistentNew<v8::Object>(scopeobject);
-    return qPersistentNew<v8::Function>(v8::Local<v8::Function>::Cast(result));
-}
-
 QQmlExpression *
 QQmlExpressionPrivate::create(QQmlContextData *ctxt, QObject *object,
-                                      const QString &expr, bool isRewritten,
-                                      const QString &url, int lineNumber, int columnNumber)
+                              const QString &expr, bool isRewritten,
+                              const QString &url, int lineNumber, int columnNumber)
 {
-    return new QQmlExpression(ctxt, object, expr, isRewritten, url, lineNumber, columnNumber, *new QQmlExpressionPrivate);
+    return new QQmlExpression(ctxt, object, expr, isRewritten, url, lineNumber, columnNumber,
+                              *new QQmlExpressionPrivate);
 }
 
 /*!
     \class QQmlExpression
-    \since 4.7
+    \since 5.0
+    \inmodule QtQml
     \brief The QQmlExpression class evaluates JavaScript in a QML context.
 
     For example, given a file \c main.qml like this:
@@ -285,6 +160,8 @@ QQmlExpressionPrivate::create(QQmlContextData *ctxt, QObject *object,
     QQmlExpression *expr = new QQmlExpression(engine->rootContext(), myObject, "width * 2");
     int result = expr->evaluate().toInt();  // result = 400
     \endcode
+
+    Note that the QtQuick 1 version is called QDeclarativeExpression.
 */
 
 /*!
@@ -299,7 +176,7 @@ QQmlExpression::QQmlExpression()
 }
 
 /*!  \internal */
-QQmlExpression::QQmlExpression(QQmlContextData *ctxt, 
+QQmlExpression::QQmlExpression(QQmlContextData *ctxt,
                                                QObject *object, const QString &expr, bool isRewritten,
                                                const QString &url, int lineNumber, int columnNumber,
                                                QQmlExpressionPrivate &dd)
@@ -324,7 +201,7 @@ QQmlExpression::QQmlExpression(QQmlContextData *ctxt,
 /*!
     Create a QQmlExpression object that is a child of \a parent.
 
-    The \script provides the expression to be evaluated, the context to evaluate it in,
+    The \script provides the expression to be evaluated, the context to evaluate it in,
     and the scope object to evaluate it with.
 
     This constructor is functionally equivalent to the following, but in most cases
@@ -339,32 +216,28 @@ QQmlExpression::QQmlExpression(const QQmlScriptString &script, QObject *parent)
 : QObject(*new QQmlExpressionPrivate, parent)
 {
     Q_D(QQmlExpression);
-    bool defaultConstruction = false;
+
+    if (!script.context()->isValid())
+        return;
+
+    bool defaultConstruction = true;
 
     int id = script.d.data()->bindingId;
-    if (id < 0) {
-        defaultConstruction = true;
-    } else {
+    if (id >= 0) {
         QQmlContextData *ctxtdata = QQmlContextData::get(script.context());
-
         QQmlEnginePrivate *engine = QQmlEnginePrivate::get(script.context()->engine());
-        QQmlCompiledData *cdata = 0;
-        QQmlTypeData *typeData = 0;
         if (engine && ctxtdata && !ctxtdata->url.isEmpty()) {
-            typeData = engine->typeLoader.get(ctxtdata->url);
-            cdata = typeData->compiledData();
-        }
+            QQmlTypeData *typeData = engine->typeLoader.getType(ctxtdata->url);
+            Q_ASSERT(typeData);
 
-        if (cdata)
-            d->init(ctxtdata, cdata->primitives.at(id), true, script.scopeObject(),
-                    cdata->name, script.d.data()->lineNumber, script.d.data()->columnNumber);
-        else
-           defaultConstruction = true;
+            if (QQmlCompiledData *cdata = typeData->compiledData()) {
+                defaultConstruction = false;
+                d->init(ctxtdata, cdata->primitives.at(id), true, script.scopeObject(),
+                        cdata->name, script.d.data()->lineNumber, script.d.data()->columnNumber);
+            }
 
-        if (cdata)
-            cdata->release();
-        if (typeData)
             typeData->release();
+        }
     }
 
     if (defaultConstruction)
@@ -388,7 +261,7 @@ QQmlExpression::QQmlExpression(QQmlContext *ctxt,
     d->init(QQmlContextData::get(ctxt), expression, scope);
 }
 
-/*! 
+/*!
     \internal
 */
 QQmlExpression::QQmlExpression(QQmlContextData *ctxt, QObject *scope,
@@ -408,24 +281,6 @@ QQmlExpression::QQmlExpression(QQmlContextData *ctxt, QObject *scope,
     d->init(ctxt, expression, scope);
 }
 
-/*!  
-    \internal 
-
-    To avoid exposing v8 in the public API, functionPtr must be a pointer to a v8::Handle<v8::Function>.  
-    For example:
-        v8::Handle<v8::Function> function;
-        new QQmlExpression(ctxt, scope, &function, ...);
- */
-QQmlExpression::QQmlExpression(QQmlContextData *ctxt, QObject *scope, void *functionPtr,
-                                               QQmlExpressionPrivate &dd)
-: QObject(dd, 0)
-{
-    v8::Handle<v8::Function> function = *(v8::Handle<v8::Function> *)functionPtr;
-
-    Q_D(QQmlExpression);
-    d->init(ctxt, function, scope);
-}
-
 /*!
     Destroy the QQmlExpression instance.
 */
@@ -460,13 +315,7 @@ QQmlContext *QQmlExpression::context() const
 QString QQmlExpression::expression() const
 {
     Q_D(const QQmlExpression);
-    if (d->extractExpressionFromFunction && context()->engine()) {
-        QV8Engine *v8engine = QQmlEnginePrivate::getV8Engine(context()->engine());
-        v8::HandleScope handle_scope;
-        v8::Context::Scope scope(v8engine->context());
-
-        return v8engine->toString(v8::Handle<v8::Value>(d->v8function));
-    } else if (!d->expressionUtf8.isEmpty()) {
+    if (!d->expressionUtf8.isEmpty()) {
         return QString::fromUtf8(d->expressionUtf8);
     } else {
         return d->expression;
@@ -489,219 +338,8 @@ void QQmlExpression::setExpression(const QString &expression)
     qPersistentDispose(d->v8qmlscope);
 }
 
-void QQmlExpressionPrivate::exceptionToError(v8::Handle<v8::Message> message, 
-                                                     QQmlError &error)
-{
-    Q_ASSERT(!message.IsEmpty());
-
-    v8::Handle<v8::Value> name = message->GetScriptResourceName();
-    v8::Handle<v8::String> description = message->Get();
-    int lineNumber = message->GetLineNumber();
-
-    v8::Local<v8::String> file = name->IsString()?name->ToString():v8::Local<v8::String>();
-    if (file.IsEmpty() || file->Length() == 0) 
-        error.setUrl(QUrl(QLatin1String("<Unknown File>")));
-    else 
-        error.setUrl(QUrl(QV8Engine::toStringStatic(file)));
-
-    error.setLine(lineNumber);
-    error.setColumn(-1);
-
-    QString qDescription = QV8Engine::toStringStatic(description);
-    if (qDescription.startsWith(QLatin1String("Uncaught ")))
-        qDescription = qDescription.mid(9 /* strlen("Uncaught ") */);
-
-    error.setDescription(qDescription);
-}
-
-void QQmlJavaScriptExpression::setNotifyOnValueChanged(bool v)
-{
-    activeGuards.setFlagValue(v);
-    if (!v) clearGuards();
-}
-
-void QQmlJavaScriptExpression::resetNotifyOnValueChanged()
-{
-    clearGuards();
-}
-
-v8::Local<v8::Value>
-QQmlJavaScriptExpression::evaluate(QQmlContextData *context,
-                                           v8::Handle<v8::Function> function, bool *isUndefined)
-{
-    Q_ASSERT(context && context->engine);
-
-    if (function.IsEmpty() || function->IsUndefined()) {
-        if (isUndefined) *isUndefined = true;
-        return v8::Local<v8::Value>();
-    }
-
-    QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context->engine);
-
-    Q_ASSERT(notifyOnValueChanged() || activeGuards.isEmpty());
-    GuardCapture capture(context->engine, this);
-
-    QQmlEnginePrivate::PropertyCapture *lastPropertyCapture = ep->propertyCapture;
-    ep->propertyCapture = notifyOnValueChanged()?&capture:0;
-
-
-    if (notifyOnValueChanged())
-        capture.guards.copyAndClearPrepend(activeGuards);
-
-    QQmlContextData *lastSharedContext = 0;
-    QObject *lastSharedScope = 0;
-
-    bool sharedContext = useSharedContext();
-
-    // All code that follows must check with watcher before it accesses data members 
-    // incase we have been deleted.
-    DeleteWatcher watcher(this);
-
-    if (sharedContext) {
-        lastSharedContext = ep->sharedContext;
-        lastSharedScope = ep->sharedScope;
-        ep->sharedContext = context;
-        ep->sharedScope = scopeObject();
-    }
-
-    v8::Local<v8::Value> result;
-    {
-        v8::TryCatch try_catch;
-        v8::Handle<v8::Object> This = ep->v8engine()->global();
-        if (scopeObject() && requiresThisObject()) {
-            v8::Handle<v8::Value> value = ep->v8engine()->newQObject(scopeObject());
-            if (value->IsObject()) This = v8::Handle<v8::Object>::Cast(value);
-        }
-
-        result = function->Call(This, 0, 0);
-
-        if (isUndefined)
-            *isUndefined = try_catch.HasCaught() || result->IsUndefined();
-
-        if (watcher.wasDeleted()) {
-        } else if (try_catch.HasCaught()) {
-            v8::Context::Scope scope(ep->v8engine()->context());
-            v8::Local<v8::Message> message = try_catch.Message();
-            if (!message.IsEmpty()) {
-                QQmlExpressionPrivate::exceptionToError(message, delayedError()->error);
-            } else {
-                if (hasDelayedError()) delayedError()->error = QQmlError();
-            }
-        } else {
-            if (hasDelayedError()) delayedError()->error = QQmlError();
-        }
-    }
-
-    if (sharedContext) {
-        ep->sharedContext = lastSharedContext;
-        ep->sharedScope = lastSharedScope;
-    }
-
-    if (capture.errorString) {
-        for (int ii = 0; ii < capture.errorString->count(); ++ii)
-            qWarning("%s", qPrintable(capture.errorString->at(ii)));
-        delete capture.errorString;
-        capture.errorString = 0;
-    }
-
-    while (Guard *g = capture.guards.takeFirst())
-        g->Delete();
-
-    ep->propertyCapture = lastPropertyCapture;
-
-    return result;
-}
-
-void QQmlJavaScriptExpression::GuardCapture::captureProperty(QQmlNotifier *n)
-{
-    if (expression) {
-
-        // Try and find a matching guard
-        while (!guards.isEmpty() && !guards.first()->isConnected(n))
-            guards.takeFirst()->Delete();
-
-        Guard *g = 0;
-        if (!guards.isEmpty()) {
-            g = guards.takeFirst();
-            g->cancelNotify();
-            Q_ASSERT(g->isConnected(n));
-        } else {
-            g = Guard::New(expression, engine);
-            g->connect(n);
-        }
-
-        expression->activeGuards.prepend(g);
-    }
-}
-
-void QQmlJavaScriptExpression::GuardCapture::captureProperty(QObject *o, int c, int n)
-{
-    if (expression) {
-        if (n == -1) {
-            if (!errorString) {
-                errorString = new QStringList;
-                QString preamble = QLatin1String("QQmlExpression: Expression ") +
-                                   expression->m_vtable->expressionIdentifier(expression) +
-                                   QLatin1String(" depends on non-NOTIFYable properties:");
-                errorString->append(preamble);
-            }
-
-            const QMetaObject *metaObj = o->metaObject();
-            QMetaProperty metaProp = metaObj->property(c);
-
-            QString error = QLatin1String("    ") +
-                            QString::fromUtf8(metaObj->className()) +
-                            QLatin1String("::") +
-                            QString::fromUtf8(metaProp.name());
-            errorString->append(error);
-        } else {
-
-            // Try and find a matching guard
-            while (!guards.isEmpty() && !guards.first()->isConnected(o, n))
-                guards.takeFirst()->Delete();
-
-            Guard *g = 0;
-            if (!guards.isEmpty()) {
-                g = guards.takeFirst();
-                g->cancelNotify();
-                Q_ASSERT(g->isConnected(o, n));
-            } else {
-                g = Guard::New(expression, engine);
-                g->connect(o, n);
-            }
-
-            expression->activeGuards.prepend(g);
-        }
-    }
-}
-
-void QQmlJavaScriptExpression::clearError()
-{
-    if (m_vtable.hasValue()) {
-        m_vtable.value().error = QQmlError();
-        m_vtable.value().removeError();
-    }
-}
-
-QQmlError QQmlJavaScriptExpression::error() const
-{
-    if (m_vtable.hasValue()) return m_vtable.constValue()->error;
-    else return QQmlError();
-}
-
-QQmlDelayedError *QQmlJavaScriptExpression::delayedError()
-{
-    return &m_vtable.value();
-}
-
-void QQmlJavaScriptExpression::clearGuards()
-{
-    while (Guard *g = activeGuards.takeFirst())
-        g->Delete();
-}
-
 // Must be called with a valid handle scope
-v8::Local<v8::Value> QQmlExpressionPrivate::v8value(QObject *secondaryScope, bool *isUndefined)
+v8::Local<v8::Value> QQmlExpressionPrivate::v8value(bool *isUndefined)
 {
     if (!expressionFunctionValid) {
         bool ok = true;
@@ -719,21 +357,10 @@ v8::Local<v8::Value> QQmlExpressionPrivate::v8value(QObject *secondaryScope, boo
         expressionFunctionValid = true;
     }
 
-
-    if (secondaryScope) {
-        v8::Local<v8::Value> result;
-        QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context()->engine);
-        QObject *restoreSecondaryScope = 0;
-        restoreSecondaryScope = ep->v8engine()->contextWrapper()->setSecondaryScope(v8qmlscope, secondaryScope);
-        result = evaluate(context(), v8function, isUndefined);
-        ep->v8engine()->contextWrapper()->setSecondaryScope(v8qmlscope, restoreSecondaryScope);
-        return result;
-    } else {
-        return evaluate(context(), v8function, isUndefined);
-    }
+    return evaluate(context(), v8function, isUndefined);
 }
 
-QVariant QQmlExpressionPrivate::value(QObject *secondaryScope, bool *isUndefined)
+QVariant QQmlExpressionPrivate::value(bool *isUndefined)
 {
     Q_Q(QQmlExpression);
 
@@ -750,7 +377,7 @@ QVariant QQmlExpressionPrivate::value(QObject *secondaryScope, bool *isUndefined
     {
         v8::HandleScope handle_scope;
         v8::Context::Scope context_scope(ep->v8engine()->context());
-        v8::Local<v8::Value> result = v8value(secondaryScope, isUndefined);
+        v8::Local<v8::Value> result = v8value(isUndefined);
         rv = ep->v8engine()->toVariant(result, qMetaTypeId<QList<QObject*> >());
     }
 
@@ -771,7 +398,7 @@ QVariant QQmlExpressionPrivate::value(QObject *secondaryScope, bool *isUndefined
 QVariant QQmlExpression::evaluate(bool *valueIsUndefined)
 {
     Q_D(QQmlExpression);
-    return d->value(0, valueIsUndefined);
+    return d->value(valueIsUndefined);
 }
 
 /*!
@@ -817,7 +444,7 @@ QString QQmlExpression::sourceFile() const
 }
 
 /*!
-    Returns the source file line number for this expression.  The source location 
+    Returns the source file line number for this expression.  The source location
     must have been previously set by calling setSourceLocation().
 */
 int QQmlExpression::lineNumber() const
@@ -863,7 +490,7 @@ QObject *QQmlExpression::scopeObject() const
 /*!
     Returns true if the last call to evaluate() resulted in an error,
     otherwise false.
-    
+
     \sa error(), clearError()
 */
 bool QQmlExpression::hasError() const
@@ -894,7 +521,7 @@ void QQmlExpression::clearError()
 QQmlError QQmlExpression::error() const
 {
     Q_D(const QQmlExpression);
-    return d->error();
+    return d->error(engine());
 }
 
 /*!
@@ -920,61 +547,7 @@ void QQmlExpressionPrivate::expressionChanged()
 QString QQmlExpressionPrivate::expressionIdentifier(QQmlJavaScriptExpression *e)
 {
     QQmlExpressionPrivate *This = static_cast<QQmlExpressionPrivate *>(e);
-    return QLatin1String("\"") + This->expression + QLatin1String("\"");
-}
-
-QQmlAbstractExpression::QQmlAbstractExpression()
-: m_prevExpression(0), m_nextExpression(0)
-{
-}
-
-QQmlAbstractExpression::~QQmlAbstractExpression()
-{
-    if (m_prevExpression) {
-        *m_prevExpression = m_nextExpression;
-        if (m_nextExpression) 
-            m_nextExpression->m_prevExpression = m_prevExpression;
-    }
-
-    if (m_context.isT2())
-        m_context.asT2()->_s = 0;
-}
-
-QQmlContextData *QQmlAbstractExpression::context() const
-{
-    if (m_context.isT1()) return m_context.asT1();
-    else return m_context.asT2()->_c;
-}
-
-void QQmlAbstractExpression::setContext(QQmlContextData *context)
-{
-    if (m_prevExpression) {
-        *m_prevExpression = m_nextExpression;
-        if (m_nextExpression) 
-            m_nextExpression->m_prevExpression = m_prevExpression;
-        m_prevExpression = 0;
-        m_nextExpression = 0;
-    }
-
-    if (m_context.isT1()) m_context = context;
-    else m_context.asT2()->_c = context;
-
-    if (context) {
-        m_nextExpression = context->expressions;
-        if (m_nextExpression) 
-            m_nextExpression->m_prevExpression = &m_nextExpression;
-        m_prevExpression = &context->expressions;
-        context->expressions = this;
-    }
-}
-
-void QQmlAbstractExpression::refresh()
-{
-}
-
-bool QQmlAbstractExpression::isValid() const
-{
-    return context() != 0;
+    return QLatin1Char('"') + This->expression + QLatin1Char('"');
 }
 
 QT_END_NAMESPACE