From 40ded579bd977dc8fc41aaa1cdfca36822d14fc6 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 4 Jul 2019 13:18:55 +0200 Subject: 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 throwError methods in favor of an explicit compilation result. Change-Id: Ie228490aad8efb7885083f6485f931299567f54c Reviewed-by: Fabian Kosmale Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4script.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'src/qml/jsruntime/qv4script.cpp') 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; } -- cgit v1.2.3