aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4codegen.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-08-08 16:59:32 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-20 14:20:44 +0200
commite43b6bd9c7a3d584e488cd3c84f9deb2d8955b64 (patch)
tree0d1a33571d2f75630db3dfe84b1a4ead23f87958 /src/qml/compiler/qv4codegen.cpp
parent42b2685d0069e746dee344054831b6f08e482860 (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 <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/compiler/qv4codegen.cpp')
-rw-r--r--src/qml/compiler/qv4codegen.cpp62
1 files changed, 23 insertions, 39 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index 8c751246db..b91e3ccd26 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -445,7 +445,7 @@ private: // fields:
bool _allowFuncDecls;
};
-Codegen::Codegen(QV4::ExecutionContext *context, bool strict)
+Codegen::Codegen(bool strict)
: _module(0)
, _function(0)
, _block(0)
@@ -457,27 +457,7 @@ Codegen::Codegen(QV4::ExecutionContext *context, bool strict)
, _loop(0)
, _labelledStatement(0)
, _scopeAndFinally(0)
- , _context(context)
, _strictMode(strict)
- , _errorHandler(0)
-{
-}
-
-Codegen::Codegen(ErrorHandler *errorHandler, bool strictMode)
- : _module(0)
- , _function(0)
- , _block(0)
- , _exitBlock(0)
- , _throwBlock(0)
- , _returnAddress(0)
- , _mode(GlobalCode)
- , _env(0)
- , _loop(0)
- , _labelledStatement(0)
- , _scopeAndFinally(0)
- , _context(0)
- , _strictMode(strictMode)
- , _errorHandler(errorHandler)
{
}
@@ -2594,26 +2574,30 @@ void Codegen::throwSyntaxErrorOnEvalOrArgumentsInStrictMode(V4IR::Expr *expr, co
void Codegen::throwSyntaxError(const SourceLocation &loc, const QString &detail)
{
- QV4::DiagnosticMessage *msg = new QV4::DiagnosticMessage;
- msg->fileName = _fileName;
- msg->offset = loc.begin();
- msg->startLine = loc.startLine;
- msg->startColumn = loc.startColumn;
- msg->message = detail;
- if (_context)
- _context->throwSyntaxError(msg);
- else if (_errorHandler)
- _errorHandler->syntaxError(msg);
- else
- Q_ASSERT(!"No error handler available.");
+ QQmlError error;
+ error.setUrl(QUrl::fromLocalFile(_fileName));
+ error.setDescription(detail);
+ error.setLine(loc.startLine);
+ error.setColumn(loc.startColumn);
+ _errors << error;
}
void Codegen::throwReferenceError(const SourceLocation &loc, const QString &detail)
{
- if (_context)
- _context->throwReferenceError(QV4::Value::fromString(_context, detail), _fileName, loc.startLine);
- else if (_errorHandler)
- throwSyntaxError(loc, detail);
- else
- Q_ASSERT(!"No error handler available.");
+ QQmlError error;
+ error.setUrl(QUrl::fromLocalFile(_fileName));
+ error.setDescription(detail);
+ error.setLine(loc.startLine);
+ error.setColumn(loc.startColumn);
+ _errors << error;
+}
+
+void RuntimeCodegen::throwSyntaxError(const AST::SourceLocation &loc, const QString &detail)
+{
+ context->throwSyntaxError(detail, _fileName, loc.startLine, loc.startColumn);
+}
+
+void RuntimeCodegen::throwReferenceError(const AST::SourceLocation &loc, const QString &detail)
+{
+ context->throwReferenceError(detail, _fileName, loc.startLine, loc.startColumn);
}