From 73becff81b714e6f3e19392ff32ec36b60bcb38c Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 20 May 2020 16:37:00 +0200 Subject: Prettify QV4_SHOW_BYTECODE output for JS classes Drop all the double spaces, force a line break after each class, and avoid converting empty strings to utf8. Coverity-Id: 190711 Change-Id: I789291e257aeac97c2a931bfc604f453c39906eb Reviewed-by: Fabian Kosmale (cherry picked from commit 512fde525ea5972bbae2796d6b2054fd370a5275) Reviewed-by: Qt Cherry-pick Bot --- src/qml/compiler/qv4compiler.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/qml/compiler/qv4compiler.cpp') diff --git a/src/qml/compiler/qv4compiler.cpp b/src/qml/compiler/qv4compiler.cpp index acc4b02e96..b6096c4ccd 100644 --- a/src/qml/compiler/qv4compiler.cpp +++ b/src/qml/compiler/qv4compiler.cpp @@ -524,25 +524,26 @@ void QV4::Compiler::JSUnitGenerator::writeClass(char *b, const QV4::Compiler::Cl static const bool showCode = qEnvironmentVariableIsSet("QV4_SHOW_BYTECODE"); if (showCode) { - qDebug() << "=== Class " << stringForIndex(cls->nameIndex) << "static methods" << cls->nStaticMethods << "methods" << cls->nMethods; + qDebug() << "=== Class" << stringForIndex(cls->nameIndex) << "static methods" + << cls->nStaticMethods << "methods" << cls->nMethods; qDebug() << " constructor:" << cls->constructorFunction; - const char *staticString = ": static "; for (uint i = 0; i < cls->nStaticMethods + cls->nMethods; ++i) { - if (i == cls->nStaticMethods) - staticString = ": "; - const char *type; + QDebug output = qDebug().nospace(); + output << " " << i << ": "; + if (i < cls->nStaticMethods) + output << "static "; switch (cls->methodTable()[i].type) { case CompiledData::Method::Getter: - type = "get "; break; + output << "get "; break; case CompiledData::Method::Setter: - type = "set "; break; + output << "set "; break; default: - type = ""; - + break; } - qDebug() << " " << i << staticString << type << stringForIndex(cls->methodTable()[i].name) << cls->methodTable()[i].function; + output << stringForIndex(cls->methodTable()[i].name) << " " + << cls->methodTable()[i].function; } - qDebug(); + qDebug().space(); } } -- cgit v1.2.3