diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2019-07-04 13:18:55 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-07-04 16:03:36 +0200 |
commit | 40ded579bd977dc8fc41aaa1cdfca36822d14fc6 (patch) | |
tree | 04069b8c15c05b2625dd45c869b45c37a6c62b3a /src/qml/jsruntime/qv4script.cpp | |
parent | c1546f8b7005a7cc0ed25f9dc1c762a9c929a25b (diff) |
Simplify codegen error handling
There can only ever be one error, either a syntax error or a reference
error. We record the error type as we want to get rid of the virtual
throw<X>Error methods in favor of an explicit compilation result.
Change-Id: Ie228490aad8efb7885083f6485f931299567f54c
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4script.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4script.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index 4dc5030fb0..c463812590 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -203,18 +203,15 @@ QV4::CompiledData::CompilationUnit Script::precompile( Codegen cg(unitGenerator, /*strict mode*/false); cg.generateFromProgram(fileName, finalUrl, source, program, module, contextType); - const auto v4Errors = cg.errors(); - if (!v4Errors.isEmpty()) { - const QUrl url = cg.url(); + if (cg.hasError()) { if (reportedErrors) { - for (const auto &v4Error : v4Errors) { - QQmlError error; - error.setUrl(url); - error.setLine(v4Error.line); - error.setColumn(v4Error.column); - error.setDescription(v4Error.message); - reportedErrors->append(error); - } + const auto v4Error = cg.error(); + QQmlError error; + error.setUrl(cg.url()); + error.setLine(v4Error.line); + error.setColumn(v4Error.column); + error.setDescription(v4Error.message); + reportedErrors->append(error); } return nullptr; } |