diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2013-09-09 13:51:31 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-12 23:00:34 +0200 |
commit | 1e17eb6cbd3c38e95c994ff00e529aecb6d530eb (patch) | |
tree | ab0ba8c75db5992f803e738e538e71106fb761fa /src/qml/compiler | |
parent | 346662cb011b7962a8cabf6d55742cd050a6ba6c (diff) |
[new compiler] Improve error reporting
Re-enable COMPILE_EXCEPTION calls that were commented out due to missing
location information (that this patch also adds).
Change-Id: I0d584f474cc7e879350c8aae2869a9603ba415aa
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/compiler')
-rw-r--r-- | src/qml/compiler/qqmlcodegenerator.cpp | 4 | ||||
-rw-r--r-- | src/qml/compiler/qv4codegen.cpp | 4 | ||||
-rw-r--r-- | src/qml/compiler/qv4compileddata_p.h | 14 | ||||
-rw-r--r-- | src/qml/compiler/qv4compiler.cpp | 3 | ||||
-rw-r--r-- | src/qml/compiler/qv4jsir_p.h | 6 |
5 files changed, 25 insertions, 6 deletions
diff --git a/src/qml/compiler/qqmlcodegenerator.cpp b/src/qml/compiler/qqmlcodegenerator.cpp index 48e21278da..008f62d2e4 100644 --- a/src/qml/compiler/qqmlcodegenerator.cpp +++ b/src/qml/compiler/qqmlcodegenerator.cpp @@ -474,6 +474,10 @@ bool QQmlCodeGenerator::visit(AST::UiPublicMember *node) property->nameIndex = registerString(name.toString()); + AST::SourceLocation loc = node->firstSourceLocation(); + property->location.line = loc.startLine; + property->location.column = loc.startColumn; + if (node->statement) appendBinding(property->nameIndex, node->statement); diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index f4822fe26e..52875ce41a 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -1770,6 +1770,10 @@ V4IR::Function *Codegen::defineFunction(const QString &name, AST::Node *ast, function->isStrict = _env->isStrict; function->isNamedExpression = _env->isNamedFunctionExpression; + AST::SourceLocation loc = ast->firstSourceLocation(); + function->line = loc.startLine; + function->column = loc.startColumn; + if (function->usesArgumentsObject) _env->enter("arguments", Environment::VariableDeclaration); diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index 1308469564..7833097325 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -67,6 +67,12 @@ struct Function; struct Lookup; struct RegExp; +struct Location +{ + int line; + int column; +}; + struct RegExp { enum Flags { @@ -207,6 +213,7 @@ struct Function quint32 lineNumberMappingOffset; // Array of uint pairs (offset and line number) quint32 nInnerFunctions; quint32 innerFunctionsOffset; + Location location; // quint32 formalsIndex[nFormals] // quint32 localsIndex[nLocals] // quint32 offsetForInnerFunctions[nInnerFunctions] @@ -223,12 +230,6 @@ struct Function // Qml data structures -struct Location -{ - int line; - int column; -}; - struct Value { enum ValueType { @@ -297,6 +298,7 @@ struct Property quint32 type; quint32 customTypeNameIndex; quint32 flags; // readonly + Location location; }; struct Object diff --git a/src/qml/compiler/qv4compiler.cpp b/src/qml/compiler/qv4compiler.cpp index 6781fdfe72..8cd4c8e2d8 100644 --- a/src/qml/compiler/qv4compiler.cpp +++ b/src/qml/compiler/qv4compiler.cpp @@ -293,6 +293,9 @@ int QV4::Compiler::JSUnitGenerator::writeFunction(char *f, int index, QQmlJS::V4 function->nInnerFunctions = irFunction->nestedFunctions.size(); function->innerFunctionsOffset = function->lineNumberMappingOffset + function->nLineNumberMappingEntries * 2 * sizeof(quint32); + function->location.line = irFunction->line; + function->location.column = irFunction->column; + // write formals quint32 *formals = (quint32 *)(f + function->formalsOffset); for (int i = 0; i < irFunction->formals.size(); ++i) diff --git a/src/qml/compiler/qv4jsir_p.h b/src/qml/compiler/qv4jsir_p.h index 12f69ac92e..812a5eba94 100644 --- a/src/qml/compiler/qv4jsir_p.h +++ b/src/qml/compiler/qv4jsir_p.h @@ -716,6 +716,10 @@ struct Function { uint hasWith: 1; uint unused : 26; + // Location of declaration in source code (-1 if not specified) + int line; + int column; + template <typename _Tp> _Tp *New() { return new (pool->allocate(sizeof(_Tp))) _Tp(); } Function(Module *module, Function *outer, const QString &name) @@ -732,6 +736,8 @@ struct Function { , hasTry(false) , hasWith(false) , unused(0) + , line(-1) + , column(-1) { this->name = newString(name); } ~Function(); |