diff options
author | Lars Knoll <[email protected]> | 2013-08-08 16:59:32 +0200 |
---|---|---|
committer | The Qt Project <[email protected]> | 2013-08-20 14:20:44 +0200 |
commit | e43b6bd9c7a3d584e488cd3c84f9deb2d8955b64 (patch) | |
tree | 0d1a33571d2f75630db3dfe84b1a4ead23f87958 /src/qml/jsruntime/qv4context.cpp | |
parent | 42b2685d0069e746dee344054831b6f08e482860 (diff) |
Remove QV4::DiagnosticMessage
QQmlError provides the same functionality, so let's rather
use that where required. Remove the dependency of
codegen onto the ExecutionContext that was only
required for error handling.
Change-Id: Ib0b61c0e138f89ff989c32996c93c339e4b62223
Reviewed-by: Simon Hausmann <[email protected]>
Diffstat (limited to 'src/qml/jsruntime/qv4context.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4context.cpp | 50 |
1 files changed, 14 insertions, 36 deletions
diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index c67b10592e..ffada86859 100644 --- a/src/qml/jsruntime/qv4context.cpp +++ b/src/qml/jsruntime/qv4context.cpp @@ -47,38 +47,10 @@ #include "qv4mm_p.h" #include <qv4argumentsobject_p.h> #include "qv4function_p.h" +#include "qv4errorobject_p.h" using namespace QV4; -DiagnosticMessage::DiagnosticMessage() - : offset(0) - , length(0) - , startLine(0) - , startColumn(0) - , type(0) - , next(0) -{} - -DiagnosticMessage::~DiagnosticMessage() -{ - delete next; -} - -String *DiagnosticMessage::buildFullMessage(ExecutionContext *ctx) const -{ - QString msg; - if (!fileName.isEmpty()) - msg = fileName + QLatin1Char(':'); - msg += QString::number(startLine) + QLatin1Char(':') + QString::number(startColumn) + QLatin1String(": "); - if (type == QV4::DiagnosticMessage::Error) - msg += QLatin1String("error"); - else - msg += QLatin1String("warning"); - msg += ": " + message; - - return ctx->engine->newString(msg); -} - void ExecutionContext::createMutableBinding(String *name, bool deletable) { @@ -254,7 +226,7 @@ bool ExecutionContext::deleteProperty(String *name) } if (strictMode) - throwSyntaxError(0); + throwSyntaxError(QString("Can't delete property %1").arg(name->toQString())); return true; } @@ -551,9 +523,16 @@ void ExecutionContext::throwError(const QString &message) throwError(Value::fromObject(engine->newErrorObject(v))); } -void ExecutionContext::throwSyntaxError(DiagnosticMessage *message) +void ExecutionContext::throwSyntaxError(const QString &message, const QString &fileName, int line, int column) +{ + Object *error = engine->newSyntaxErrorObject(message, fileName, line, column); + throwError(Value::fromObject(error)); +} + +void ExecutionContext::throwSyntaxError(const QString &message) { - throwError(Value::fromObject(engine->newSyntaxErrorObject(this, message))); + Object *error = engine->newSyntaxErrorObject(message); + throwError(Value::fromObject(error)); } void ExecutionContext::throwTypeError() @@ -579,11 +558,10 @@ void ExecutionContext::throwReferenceError(Value value) throwError(Value::fromObject(engine->newReferenceErrorObject(msg))); } -void ExecutionContext::throwReferenceError(Value value, const QString &fileName, int line) +void ExecutionContext::throwReferenceError(const QString &message, const QString &fileName, int line, int column) { - String *s = value.toString(this); - QString msg = s->toQString() + QStringLiteral(" is not defined"); - throwError(Value::fromObject(engine->newReferenceErrorObject(msg, fileName, line))); + QString msg = message + QStringLiteral(" is not defined"); + throwError(Value::fromObject(engine->newReferenceErrorObject(msg, fileName, line, column))); } void ExecutionContext::throwRangeError(Value value) |