diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qml/main.cpp | 6 | ||||
-rw-r--r-- | tools/qml/qml.pro | 2 | ||||
-rw-r--r-- | tools/qmlcachegen/qmlcachegen.cpp | 10 | ||||
-rw-r--r-- | tools/qmljs/qmljs.cpp | 11 | ||||
-rw-r--r-- | tools/qmlmin/main.cpp | 104 | ||||
-rw-r--r-- | tools/qmlprofiler/qmlprofilerapplication.cpp | 6 | ||||
-rw-r--r-- | tools/qmlprofiler/qmlprofilerclient.cpp | 4 | ||||
-rw-r--r-- | tools/qmlprofiler/qmlprofilerclient.h | 2 | ||||
-rw-r--r-- | tools/tools.pro | 21 |
9 files changed, 106 insertions, 60 deletions
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index 73b2700ba4..6cf6ad3b2c 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -55,7 +55,9 @@ #include <QLibraryInfo> #include <qqml.h> #include <qqmldebug.h> -#if QT_CONFIG(animation) + +#include <private/qtqmlglobal_p.h> +#if QT_CONFIG(qml_animation) #include <private/qabstractanimation_p.h> #endif @@ -483,7 +485,7 @@ int main(int argc, char *argv[]) break; else if (arg == QLatin1String("-verbose")) verboseMode = true; -#if QT_CONFIG(animation) +#if QT_CONFIG(qml_animation) else if (arg == QLatin1String("-slow-animations")) QUnifiedTimer::instance()->setSlowModeEnabled(true); else if (arg == QLatin1String("-fixed-animations")) diff --git a/tools/qml/qml.pro b/tools/qml/qml.pro index 04704f9314..3f41707275 100644 --- a/tools/qml/qml.pro +++ b/tools/qml/qml.pro @@ -1,4 +1,4 @@ -QT = qml core-private +QT = qml-private core-private qtHaveModule(gui): QT += gui qtHaveModule(widgets): QT += widgets diff --git a/tools/qmlcachegen/qmlcachegen.cpp b/tools/qmlcachegen/qmlcachegen.cpp index 8a2776e808..b9a8763c97 100644 --- a/tools/qmlcachegen/qmlcachegen.cpp +++ b/tools/qmlcachegen/qmlcachegen.cpp @@ -37,6 +37,7 @@ #include <private/qqmlirbuilder_p.h> #include <private/qqmljsparser_p.h> +#include <private/qqmljslexer_p.h> #include "resourcefilemapper.h" @@ -236,7 +237,7 @@ static bool compileQmlFile(const QString &inputFileName, SaveFunction saveFuncti unit->flags |= QV4::CompiledData::Unit::PendingTypeCompilation; irDocument.javaScriptCompilationUnit->data = unit; - if (!saveFunction(irDocument.javaScriptCompilationUnit, &error->message)) + if (!saveFunction(irDocument.javaScriptCompilationUnit.data(), &error->message)) return false; free(unit); @@ -304,7 +305,7 @@ static bool compileJSFile(const QString &inputFileName, const QString &inputFile &irDocument.jsGenerator.stringTable, illegalNames); v4CodeGen.setUseFastLookups(false); // Disable lookups in non-standalone (aka QML) mode v4CodeGen.generateFromProgram(inputFileName, inputFileUrl, sourceCode, program, - &irDocument.jsModule, QV4::Compiler::GlobalCode); + &irDocument.jsModule, QV4::Compiler::ContextType::Global); QList<QQmlJS::DiagnosticMessage> jsErrors = v4CodeGen.errors(); if (!jsErrors.isEmpty()) { for (const QQmlJS::DiagnosticMessage &e: qAsConst(jsErrors)) { @@ -323,7 +324,7 @@ static bool compileJSFile(const QString &inputFileName, const QString &inputFile unit->flags |= QV4::CompiledData::Unit::StaticData; irDocument.javaScriptCompilationUnit->data = unit; - if (!saveFunction(irDocument.javaScriptCompilationUnit, &error->message)) { + if (!saveFunction(irDocument.javaScriptCompilationUnit.data(), &error->message)) { engine->setDirectives(oldDirs); return false; } @@ -434,9 +435,6 @@ int main(int argc, char **argv) QCommandLineOption outputFileOption(QStringLiteral("o"), QCoreApplication::translate("main", "Output file name"), QCoreApplication::translate("main", "file name")); parser.addOption(outputFileOption); - QCommandLineOption checkIfSupportedOption(QStringLiteral("check-if-supported"), QCoreApplication::translate("main", "Check if cache generate is supported on the specified target architecture")); - parser.addOption(checkIfSupportedOption); - parser.addPositionalArgument(QStringLiteral("[qml file]"), QStringLiteral("QML source file to generate cache for.")); diff --git a/tools/qmljs/qmljs.cpp b/tools/qmljs/qmljs.cpp index ea014f3beb..c8abb7330a 100644 --- a/tools/qmljs/qmljs.cpp +++ b/tools/qmljs/qmljs.cpp @@ -80,6 +80,15 @@ int main(int argc, char *argv[]) bool cache = false; if (!args.isEmpty()) { + if (args.constFirst() == QLatin1String("--jit")) { + qputenv("QV4_JIT_CALL_THRESHOLD", QByteArray("0")); + args.removeFirst(); + } + if (args.constFirst() == QLatin1String("--interpret")) { + qputenv("QV4_FORCE_INTERPRETER", QByteArray("1")); + args.removeFirst(); + } + if (args.constFirst() == QLatin1String("--qml")) { runAsQml = true; args.removeFirst(); @@ -120,7 +129,7 @@ int main(int argc, char *argv[]) const QString code = QString::fromUtf8(file.readAll()); file.close(); - script.reset(new QV4::Script(ctx, QV4::Compiler::GlobalCode, code, fn)); + script.reset(new QV4::Script(ctx, QV4::Compiler::ContextType::Global, code, fn)); script->parseAsBinding = runAsQml; script->parse(); } diff --git a/tools/qmlmin/main.cpp b/tools/qmlmin/main.cpp index 5641e6348e..26833d2a08 100644 --- a/tools/qmlmin/main.cpp +++ b/tools/qmlmin/main.cpp @@ -57,15 +57,48 @@ class QmlminLexer: protected Lexer, public Directives QString _fileName; QString _directives; +protected: + QVector<int> _stateStack; + QList<int> _tokens; + QList<QString> _tokenStrings; + int yytoken = -1; + QString yytokentext; + + void lex() { + if (_tokens.isEmpty()) { + _tokens.append(Lexer::lex()); + _tokenStrings.append(tokenText()); + } + + yytoken = _tokens.takeFirst(); + yytokentext = _tokenStrings.takeFirst(); + } + + int lookaheadToken() + { + if (yytoken < 0) + lex(); + return yytoken; + } + + void pushToken(int token) + { + _tokens.prepend(yytoken); + _tokenStrings.prepend(yytokentext); + yytoken = token; + yytokentext = QString(); + } + public: - QmlminLexer(): Lexer(&_engine) {} + QmlminLexer() + : Lexer(&_engine), _stateStack(128) {} virtual ~QmlminLexer() {} QString fileName() const { return _fileName; } bool operator()(const QString &fileName, const QString &code) { - int startToken = T_FEED_JS_PROGRAM; + int startToken = T_FEED_JS_SCRIPT; const QFileInfo fileInfo(fileName); if (fileInfo.suffix().toLower() == QLatin1String("qml")) startToken = T_FEED_UI_PROGRAM; @@ -154,6 +187,24 @@ protected: ruleno == J_SCRIPT_REGEXPLITERAL_RULE2; } + void handleLookaheads(int ruleno) { + if (ruleno == J_SCRIPT_EXPRESSIONSTATEMENTLOOKAHEAD_RULE) { + int token = lookaheadToken(); + if (token == T_LBRACE) + pushToken(T_FORCE_BLOCK); + else if (token == T_FUNCTION || token == T_CLASS || token == T_LET || token == T_CONST) + pushToken(T_FORCE_DECLARATION); + } else if (ruleno == J_SCRIPT_CONCISEBODYLOOKAHEAD_RULE) { + int token = lookaheadToken(); + if (token == T_LBRACE) + pushToken(T_FORCE_BLOCK); + } else if (ruleno == J_SCRIPT_EXPORTDECLARATIONLOOKAHEAD_RULE) { + int token = lookaheadToken(); + if (token == T_FUNCTION || token == T_CLASS) + pushToken(T_FORCE_DECLARATION); + } + } + bool scanRestOfRegExp(int ruleno, QString *restOfRegExp) { if (! scanRegExp(ruleno == J_SCRIPT_REGEXPLITERAL_RULE1 ? Lexer::NoPrefix : Lexer::EqualPrefix)) @@ -187,9 +238,6 @@ protected: class Minify: public QmlminLexer { - QVector<int> _stateStack; - QList<int> _tokens; - QList<QString> _tokenStrings; QString _minifiedCode; int _maxWidth; int _width; @@ -206,7 +254,7 @@ protected: }; Minify::Minify(int maxWidth) - : _stateStack(128), _maxWidth(maxWidth), _width(0) + : _maxWidth(maxWidth), _width(0) { } @@ -250,16 +298,14 @@ void Minify::escape(const QChar &ch, QString *out) bool Minify::parse(int startToken) { int yyaction = 0; - int yytoken = -1; int yytos = -1; - QString yytokentext; QString assembled; _minifiedCode.clear(); _tokens.append(startToken); _tokenStrings.append(QString()); - if (startToken == T_FEED_JS_PROGRAM) { + if (startToken == T_FEED_JS_SCRIPT) { // parse optional pragma directive DiagnosticMessage error; if (scanDirectives(this, &error)) { @@ -282,15 +328,8 @@ bool Minify::parse(int startToken) _stateStack[yytos] = yyaction; again: - if (yytoken == -1 && action_index[yyaction] != -TERMINAL_COUNT) { - if (_tokens.isEmpty()) { - _tokens.append(lex()); - _tokenStrings.append(tokenText()); - } - - yytoken = _tokens.takeFirst(); - yytokentext = _tokenStrings.takeFirst(); - } + if (yytoken == -1 && action_index[yyaction] != -TERMINAL_COUNT) + lex(); yyaction = t_action(yyaction, yytoken); if (yyaction > 0) { @@ -366,6 +405,8 @@ bool Minify::parse(int startToken) const int ruleno = -yyaction - 1; yytos -= rhs[ruleno]; + handleLookaheads(ruleno); + if (isRegExpRule(ruleno)) { QString restOfRegExp; @@ -398,13 +439,10 @@ bool Minify::parse(int startToken) class Tokenize: public QmlminLexer { - QVector<int> _stateStack; - QList<int> _tokens; - QList<QString> _tokenStrings; QStringList _minifiedCode; public: - Tokenize(); + Tokenize() {} QStringList tokenStream() const; @@ -412,11 +450,6 @@ protected: bool parse(int startToken) override; }; -Tokenize::Tokenize() - : _stateStack(128) -{ -} - QStringList Tokenize::tokenStream() const { return _minifiedCode; @@ -425,15 +458,13 @@ QStringList Tokenize::tokenStream() const bool Tokenize::parse(int startToken) { int yyaction = 0; - int yytoken = -1; int yytos = -1; - QString yytokentext; _minifiedCode.clear(); _tokens.append(startToken); _tokenStrings.append(QString()); - if (startToken == T_FEED_JS_PROGRAM) { + if (startToken == T_FEED_JS_SCRIPT) { // parse optional pragma directive DiagnosticMessage error; if (scanDirectives(this, &error)) { @@ -457,15 +488,8 @@ bool Tokenize::parse(int startToken) _stateStack[yytos] = yyaction; again: - if (yytoken == -1 && action_index[yyaction] != -TERMINAL_COUNT) { - if (_tokens.isEmpty()) { - _tokens.append(lex()); - _tokenStrings.append(tokenText()); - } - - yytoken = _tokens.takeFirst(); - yytokentext = _tokenStrings.takeFirst(); - } + if (yytoken == -1 && action_index[yyaction] != -TERMINAL_COUNT) + lex(); yyaction = t_action(yyaction, yytoken); if (yyaction > 0) { @@ -484,6 +508,8 @@ bool Tokenize::parse(int startToken) const int ruleno = -yyaction - 1; yytos -= rhs[ruleno]; + handleLookaheads(ruleno); + if (isRegExpRule(ruleno)) { QString restOfRegExp; diff --git a/tools/qmlprofiler/qmlprofilerapplication.cpp b/tools/qmlprofiler/qmlprofilerapplication.cpp index 0b63a91e5b..6732766b46 100644 --- a/tools/qmlprofiler/qmlprofilerapplication.cpp +++ b/tools/qmlprofiler/qmlprofilerapplication.cpp @@ -120,6 +120,10 @@ QmlProfilerApplication::~QmlProfilerApplication() logStatus("Killing process ..."); m_process->kill(); } + if (isInteractive()) { + QTextStream err(stderr); + err << endl; + } delete m_process; } @@ -366,7 +370,7 @@ void QmlProfilerApplication::userCommand(const QString &command) m_pendingRequest = REQUEST_NONE; prompt(); } else { - prompt(tr("The application is still generating data. Really quit (y/n)?")); + prompt(tr("Really quit (y/n)?")); } return; } diff --git a/tools/qmlprofiler/qmlprofilerclient.cpp b/tools/qmlprofiler/qmlprofilerclient.cpp index b69c7e73e1..f6cc6f39fe 100644 --- a/tools/qmlprofiler/qmlprofilerclient.cpp +++ b/tools/qmlprofiler/qmlprofilerclient.cpp @@ -57,6 +57,8 @@ QmlProfilerClient::QmlProfilerClient(QQmlDebugConnection *connection, QmlProfile { Q_D(QmlProfilerClient); setRequestedFeatures(std::numeric_limits<quint64>::max()); + connect(this, &QQmlDebugClient::stateChanged, + this, &QmlProfilerClient::onStateChanged); connect(this, &QQmlProfilerClient::traceStarted, d->data, &QmlProfilerData::setTraceStartTime); connect(this, &QQmlProfilerClient::traceFinished, @@ -65,7 +67,7 @@ QmlProfilerClient::QmlProfilerClient(QQmlDebugConnection *connection, QmlProfile d->data, &QmlProfilerData::complete); } -void QmlProfilerClient::stateChanged(State state) +void QmlProfilerClient::onStateChanged(State state) { Q_D(QmlProfilerClient); if ((d->enabled && state != Enabled) || (!d->enabled && state == Enabled)) { diff --git a/tools/qmlprofiler/qmlprofilerclient.h b/tools/qmlprofiler/qmlprofilerclient.h index 30f4a51751..7355688222 100644 --- a/tools/qmlprofiler/qmlprofilerclient.h +++ b/tools/qmlprofiler/qmlprofilerclient.h @@ -48,7 +48,7 @@ signals: void error(const QString &error); private: - void stateChanged(State state) override; + void onStateChanged(State state); }; #endif // QMLPROFILERCLIENT_H diff --git a/tools/tools.pro b/tools/tools.pro index 856906cc53..d35605b5ae 100644 --- a/tools/tools.pro +++ b/tools/tools.pro @@ -1,16 +1,19 @@ TEMPLATE = subdirs QT_FOR_CONFIG += qml-private -SUBDIRS += \ - qmlmin \ - qmlimportscanner -qtConfig(commandlineparser):qtConfig(xmlstreamwriter): SUBDIRS += qmlcachegen +qtConfig(qml-devtools) { + SUBDIRS += \ + qmlmin \ + qmlimportscanner + + qtConfig(commandlineparser):qtConfig(xmlstreamwriter): SUBDIRS += qmlcachegen +} !android|android_app { SUBDIRS += \ - qml \ - qmllint + qml + qtConfig(qml-devtools): SUBDIRS += qmllint qtConfig(qml-profiler): SUBDIRS += qmlprofiler qtHaveModule(quick) { @@ -30,8 +33,10 @@ qtConfig(commandlineparser):qtConfig(xmlstreamwriter): SUBDIRS += qmlcachegen qtConfig(private_tests): SUBDIRS += qmljs } -qml.depends = qmlimportscanner -qmleasing.depends = qmlimportscanner +qtConfig(qml-devtools) { + qml.depends = qmlimportscanner + qmleasing.depends = qmlimportscanner +} # qmlmin, qmlimportscanner & qmlcachegen are build tools. # qmlscene is needed by the autotests. |