diff --git a/src/qmljsc/CMakeLists.txt b/src/qmljsc/CMakeLists.txt index fc65b50..174d414 100644 --- a/src/qmljsc/CMakeLists.txt +++ b/src/qmljsc/CMakeLists.txt @@ -1,28 +1,28 @@ find_package(Qt5 COMPONENTS Core Qml) set(libqmljsc_srcs compiler.cpp error.h - parserstage.cpp + parserpass.cpp compilerpipeline.cpp compilerpass.cpp - prettygeneratorstage.cpp + prettygeneratorpass.cpp symboltable.cpp ir/symbol.cpp ir/type.cpp ir/class.cpp ir/object.cpp ir/component.cpp ) add_library(libqmljsc SHARED ${libqmljsc_srcs}) qt5_use_modules(libqmljsc Core Qml) include_directories(${Qt5Qml_PRIVATE_INCLUDE_DIRS}) set(qmljsc_srcs main.cpp ) add_executable(qmljsc ${qmljsc_srcs}) target_link_libraries(qmljsc libqmljsc) diff --git a/src/qmljsc/compilerpass.cpp b/src/qmljsc/compilerpass.cpp index 2d3650c..efd6a66 100644 --- a/src/qmljsc/compilerpass.cpp +++ b/src/qmljsc/compilerpass.cpp @@ -1,33 +1,33 @@ /* * Copyright (C) 2015 Jan Marker * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ #include "compilerpipeline.h" #include "compilerpass.h" using namespace QmlJSc; -CompilerPass::CompilerPass(): QObject() +CompilerPass::CompilerPass(QObject *parent): QObject(parent) { } void CompilerPass::failBecauseOfWrongType() { - Q_STATIC_ASSERT_X(1, "The type is not supported by this stage, is the stage order correct?"); + Q_STATIC_ASSERT_X(1, "The type is not supported by this compiler pass, is the compiler pass order correct?"); } diff --git a/src/qmljsc/compilerpass.h b/src/qmljsc/compilerpass.h index e8ed1f4..77b427a 100644 --- a/src/qmljsc/compilerpass.h +++ b/src/qmljsc/compilerpass.h @@ -1,61 +1,61 @@ /* * Copyright (C) 2015 Jan Marker * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ #ifndef PIPELINESTAGE_H #define PIPELINESTAGE_H #include #include #include "error.h" #include Q_DECLARE_METATYPE(QQmlJS::AST::UiProgram*) namespace QmlJSc { class CompilerPipeline; class CompilerPass : public QObject { Q_OBJECT public: - CompilerPass(); + CompilerPass(QObject *parent = 0); void connectToSuccessor(CompilerPass *successor) { connect(this, SIGNAL(finished(QString)), successor, SLOT(process(QString))); connect(this, SIGNAL(finished(QQmlJS::AST::UiProgram*)), successor, SLOT(process(QQmlJS::AST::UiProgram*))); } public slots: virtual void process(QString) { failBecauseOfWrongType(); }; virtual void process(QQmlJS::AST::UiProgram*) { failBecauseOfWrongType(); }; signals: void finished(QString); void finished(QQmlJS::AST::UiProgram*); private: void failBecauseOfWrongType(); }; } #endif // PIPELINESTAGE_H diff --git a/src/qmljsc/compilerpipeline.cpp b/src/qmljsc/compilerpipeline.cpp index 6b08854..e2c542e 100644 --- a/src/qmljsc/compilerpipeline.cpp +++ b/src/qmljsc/compilerpipeline.cpp @@ -1,79 +1,79 @@ /* * Copyright (C) 2015 Jan Marker * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ #include #include "compilerpass.h" #include "compilerpipeline.h" using namespace QmlJSc; -CompilerPipeline::CompilerPipeline() +CompilerPipeline::CompilerPipeline(QObject *parent) + : QObject(parent) { } CompilerPipeline::~CompilerPipeline() { - foreach (CompilerPass* compilerPass, m_pipeline) { - delete compilerPass; - } } QUrl CompilerPipeline::file() const { return m_file; } void CompilerPipeline::compile(QString& filePath) { m_file = filePath; QFile file(m_file); bool openSuccessful = file.open(QFile::ReadOnly); if (!openSuccessful) { Error error(Error::ReadFileError, file.errorString()); error.setFile(file.fileName()); throw error; } QTextStream stream(&file); QString qmlCode = stream.readAll(); Q_ASSERT(m_pipeline.count() > 0); m_pipeline.first()->process(qmlCode); } -void CompilerPipeline::appendCompilerPass(CompilerPass *stage) +void CompilerPipeline::appendCompilerPass(CompilerPass *compilerPass) { - Q_ASSERT(stage); + Q_ASSERT(compilerPass); + + compilerPass->setParent(this); - CompilerPass * lastStage = 0; + CompilerPass *lastCompilerPass = 0; if (m_pipeline.size() > 0) { - lastStage = m_pipeline.last(); - disconnect(lastStage, SIGNAL(finished(QString)), this, SIGNAL(compileFinished(QString))); + lastCompilerPass = m_pipeline.last(); + disconnect(lastCompilerPass, SIGNAL(finished(QString)), this, SIGNAL(compileFinished(QString))); } - m_pipeline.append(stage); + m_pipeline.append(compilerPass); - if (lastStage) { - lastStage->connectToSuccessor(stage); + if (lastCompilerPass) { + lastCompilerPass->connectToSuccessor(compilerPass); } - connect(stage, SIGNAL(finished(QString)), this, SIGNAL(compileFinished(QString))); + connect(compilerPass, SIGNAL(finished(QString)), this, SIGNAL(compileFinished(QString))); } diff --git a/src/qmljsc/compilerpipeline.h b/src/qmljsc/compilerpipeline.h index 55f4d45..3298e09 100644 --- a/src/qmljsc/compilerpipeline.h +++ b/src/qmljsc/compilerpipeline.h @@ -1,61 +1,61 @@ /* * Copyright (C) 2015 Jan Marker * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ #ifndef PIPELINE_H #define PIPELINE_H #include #include #include #include #include "error.h" namespace QmlJSc { class CompilerPass; class CompilerPipeline : public QObject { Q_OBJECT public: - CompilerPipeline(); + CompilerPipeline(QObject* parent = 0); ~CompilerPipeline(); /** - * Appends @param stage to the pipeline and takes the - * ownership of @param stage + * Appends @param compilerPass to the pipeline and takes the + * ownership of @param compilerPass */ - void appendCompilerPass(CompilerPass *stage); + void appendCompilerPass(CompilerPass *compilerPass); void compile(QString &file); QUrl file() const; signals: void compileFinished(QString output); private: QLinkedList m_pipeline; QString m_file; }; } #endif // PIPELINE_H diff --git a/src/qmljsc/parserstage.cpp b/src/qmljsc/parserpass.cpp similarity index 91% rename from src/qmljsc/parserstage.cpp rename to src/qmljsc/parserpass.cpp index f081f3c..f98e164 100644 --- a/src/qmljsc/parserstage.cpp +++ b/src/qmljsc/parserpass.cpp @@ -1,50 +1,50 @@ /* * Copyright (C) 2015 Jan Marker * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ -#include "parserstage.h" +#include "parserpass.h" using namespace QmlJSc; -ParserStage::ParserStage() +ParserPass::ParserPass() { } -ParserStage::~ParserStage() +ParserPass::~ParserPass() { } -void ParserStage::process(QString input) +void ParserPass::process(QString input) { QQmlJS::Engine* engine = new QQmlJS::Engine(); QQmlJS::Lexer* lexer = new QQmlJS::Lexer(engine); lexer->setCode(input, 1, true); QQmlJS::Parser* parser = new QQmlJS::Parser(engine); bool successfullyParsed = parser->parse(); if (!successfullyParsed) { Error error(Error::ParseError, parser->errorMessage()); error.setColumn(parser->errorColumnNumber()); error.setLine(parser->errorLineNumber()); throw error; } emit finished(parser->ast()); } diff --git a/src/qmljsc/parserstage.h b/src/qmljsc/parserpass.h similarity index 92% rename from src/qmljsc/parserstage.h rename to src/qmljsc/parserpass.h index 2a6b475..402cfc7 100644 --- a/src/qmljsc/parserstage.h +++ b/src/qmljsc/parserpass.h @@ -1,48 +1,48 @@ /* * Copyright (C) 2015 Jan Marker * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ #ifndef PARSER_H #define PARSER_H #include #include #include #include #include "compilerpass.h" namespace QmlJSc { -class ParserStage : public CompilerPass +class ParserPass : public CompilerPass { Q_OBJECT public: - ParserStage(); - ~ParserStage(); + ParserPass(); + ~ParserPass(); public slots: void process(QString input) override; }; } #endif // PARSER_H diff --git a/src/qmljsc/prettygeneratorstage.cpp b/src/qmljsc/prettygeneratorpass.cpp similarity index 80% rename from src/qmljsc/prettygeneratorstage.cpp rename to src/qmljsc/prettygeneratorpass.cpp index 428e166..44fa5c2 100644 --- a/src/qmljsc/prettygeneratorstage.cpp +++ b/src/qmljsc/prettygeneratorpass.cpp @@ -1,99 +1,99 @@ /* * Copyright (C) 2015 Jan Marker * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ #include #include "compiler.h" #include "compilerpipeline.h" -#include "prettygeneratorstage.h" +#include "prettygeneratorpass.h" #include "symboltable.h" using namespace QmlJSc; const QString RUNTIME_INHERIT = QStringLiteral("QW_INHERIT"); const QString RUNTIME_CONTEXT = QStringLiteral("QWContext"); const QString TEMPLATE_COMPONENT_HEAD = QStringLiteral( "%1(%2, %3);\n" \ "function %2(parent) {\n" \ " %3.call(this, parent);\n" \ " var __ = new %4(this);\n" \ ); const QString TEMPLATE_COMPONENT_FOOT = QStringLiteral( "\n\n" \ "%1;" ); -PrettyGeneratorStage::PrettyGeneratorStage(SymbolTable* symbolTable) +PrettyGeneratorPass::PrettyGeneratorPass(SymbolTable* symbolTable) : m_symbols(symbolTable) , m_output() { m_componentRoot = false; m_output.setString(new QString()); } -void PrettyGeneratorStage::process(QQmlJS::AST::UiProgram* ast) +void PrettyGeneratorPass::process(QQmlJS::AST::UiProgram* ast) { Q_ASSERT(ast); ast->accept(this); } -bool PrettyGeneratorStage::visit(QQmlJS::AST::UiProgram* uiProgram) +bool PrettyGeneratorPass::visit(QQmlJS::AST::UiProgram* uiProgram) { m_componentRoot = true; return true; } -bool PrettyGeneratorStage::visit(QQmlJS::AST::UiObjectDefinition* objectDefinition) +bool PrettyGeneratorPass::visit(QQmlJS::AST::UiObjectDefinition* objectDefinition) { if (m_componentRoot) { const QString objectIdentifier = objectDefinition->qualifiedTypeNameId->name.toString(); const QString objectFqi = m_symbols->findType(ModuleImports(), objectIdentifier); m_output << TEMPLATE_COMPONENT_HEAD.arg(RUNTIME_INHERIT) .arg("__comp") .arg(objectFqi) .arg(RUNTIME_CONTEXT); m_componentRoot = false; } return true; } -void PrettyGeneratorStage::endVisit(QQmlJS::AST::UiProgram* uiProgram) +void PrettyGeneratorPass::endVisit(QQmlJS::AST::UiProgram* uiProgram) { m_output << TEMPLATE_COMPONENT_FOOT.arg("__comp"); } -void PrettyGeneratorStage::endVisit(QQmlJS::AST::UiObjectDefinition* objectDefinition) +void PrettyGeneratorPass::endVisit(QQmlJS::AST::UiObjectDefinition* objectDefinition) { m_output << '}'; } -void PrettyGeneratorStage::postVisit(QQmlJS::AST::Node* node) +void PrettyGeneratorPass::postVisit(QQmlJS::AST::Node* node) { if (node->kind == QQmlJS::AST::Node::Kind_UiProgram) { m_output.flush(); emit finished(*(m_output.string())); } } diff --git a/src/qmljsc/prettygeneratorstage.h b/src/qmljsc/prettygeneratorpass.h similarity index 92% rename from src/qmljsc/prettygeneratorstage.h rename to src/qmljsc/prettygeneratorpass.h index 6906387..7338b0d 100644 --- a/src/qmljsc/prettygeneratorstage.h +++ b/src/qmljsc/prettygeneratorpass.h @@ -1,60 +1,60 @@ /* * Copyright (C) 2015 Jan Marker * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ #ifndef PRETTYGENERATORSTAGE_H #define PRETTYGENERATORSTAGE_H #include #include #include "compilerpass.h" #include "symboltable.h" namespace QmlJSc { -class PrettyGeneratorStage : public CompilerPass, public QQmlJS::AST::Visitor +class PrettyGeneratorPass : public CompilerPass, public QQmlJS::AST::Visitor { Q_OBJECT public: - PrettyGeneratorStage(SymbolTable*); + PrettyGeneratorPass(SymbolTable*); bool visit(QQmlJS::AST::UiProgram*) override; bool visit(QQmlJS::AST::UiObjectDefinition*) override; void endVisit(QQmlJS::AST::UiProgram*) override; void endVisit(QQmlJS::AST::UiObjectDefinition*) override; void postVisit(QQmlJS::AST::Node*) override; public slots: void process(QQmlJS::AST::UiProgram*) override; private: int m_levelSpaceCount = 4; QTextStream m_output; bool m_componentRoot; SymbolTable* m_symbols; }; } #endif // PRETTYGENERATORSTAGE_H diff --git a/tests/auto/qmljsc/CMakeLists.txt b/tests/auto/qmljsc/CMakeLists.txt index 505220c..fe1eb13 100644 --- a/tests/auto/qmljsc/CMakeLists.txt +++ b/tests/auto/qmljsc/CMakeLists.txt @@ -1,26 +1,26 @@ find_package(Qt5 CONFIG REQUIRED Core Test Qml) function(new_test) set(options ) set(oneValueArgs TEST) set(multiValueArgs RESOURCES) cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) include_directories(${Qt5Qml_PRIVATE_INCLUDE_DIRS}) add_test(NAME ${ARGS_TEST} COMMAND ${ARGS_TEST}) generate_qrc_file(FILENAME "${ARGS_TEST}_resources.qrc" RESOURCES ${ARGS_RESOURCES} FILEPATH_VAR qrcfilepath) qt5_add_resources(ResourceSources ${qrcfilepath}) add_executable(${ARGS_TEST} ${ARGS_TEST}.cpp ${ResourceSources}) qt5_use_modules(${ARGS_TEST} Core Qml Test) target_link_libraries(${ARGS_TEST} libqmljsc) endfunction() new_test(TEST testcompiler) -new_test(TEST testparserstage RESOURCES ../data/minimal/minimal.qml) -new_test(TEST testprettygeneratorstage RESOURCES ../data/minimal/minimal.qml ../data/minimal/minimal.qml.js) +new_test(TEST testparserpass RESOURCES ../data/minimal/minimal.qml) +new_test(TEST testprettygeneratorpass RESOURCES ../data/minimal/minimal.qml ../data/minimal/minimal.qml.js) new_test(TEST testcompilerpipeline RESOURCES ../data/minimal/minimal.qml) new_test(TEST testsymboltable RESOURCES ../data/imports/TestModule.0.1.js) new_test(TEST testir) diff --git a/tests/auto/qmljsc/testparserstage.cpp b/tests/auto/qmljsc/testparserpass.cpp similarity index 79% rename from tests/auto/qmljsc/testparserstage.cpp rename to tests/auto/qmljsc/testparserpass.cpp index 52b665e..5306f28 100644 --- a/tests/auto/qmljsc/testparserstage.cpp +++ b/tests/auto/qmljsc/testparserpass.cpp @@ -1,104 +1,104 @@ /* * Copyright (C) 2015 Jan Marker * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ #include #include #include #include #include #include #include #include #include "../../../src/qmljsc/compilerpipeline.h" -#include "../../../src/qmljsc/parserstage.h" +#include "../../../src/qmljsc/parserpass.h" -class TestParserStage : public QObject +class TestParserPass : public QObject { Q_OBJECT private slots: void working(); void not_working(); }; -void TestParserStage::working() +void TestParserPass::working() { QmlJSc::CompilerPipeline pipeline; - QmlJSc::ParserStage* stage = new QmlJSc::ParserStage(); - pipeline.appendCompilerPass(stage); + QmlJSc::ParserPass *parserPass = new QmlJSc::ParserPass(); + pipeline.appendCompilerPass(parserPass); QFile minimalTestFile(":/test/minimal.qml"); minimalTestFile.open(QFile::ReadOnly); QTextStream minimalTestFileStream(&minimalTestFile); QString minimalTestQml = minimalTestFileStream.readAll(); - QSignalSpy spy(stage, SIGNAL(finished(QQmlJS::AST::UiProgram*))); + QSignalSpy spy(parserPass, SIGNAL(finished(QQmlJS::AST::UiProgram*))); try { - stage->process(minimalTestQml); + parserPass->process(minimalTestQml); } catch (QmlJSc::Error& error) { QFAIL("no error should occur"); } QCOMPARE(spy.count(), 1); QList stageResult = spy.takeFirst(); QVERIFY2(stageResult.length() == 1, "Only one result should have been sent"); QVariant astVariant = stageResult.takeFirst(); QVERIFY2(astVariant.canConvert(), "Stage produced a wrong result"); QQmlJS::AST::UiProgram* ast = astVariant.value(); QVERIFY2(ast->headers == 0, "There should not be headers"); QVERIFY(ast->members->kind == QQmlJS::AST::Node::Kind_UiObjectMemberList); QVERIFY(ast->members->member->kind == QQmlJS::AST::Node::Kind_UiObjectDefinition); QQmlJS::AST::UiObjectDefinition* memberObjectDefinition = reinterpret_cast(ast->members->member); QCOMPARE(QString().append(memberObjectDefinition->qualifiedTypeNameId->name), QStringLiteral("QtObject")); } -void TestParserStage::not_working() +void TestParserPass::not_working() { QmlJSc::CompilerPipeline pipeline; - QmlJSc::ParserStage* stage = new QmlJSc::ParserStage(); - pipeline.appendCompilerPass(stage); + QmlJSc::ParserPass *parserPass = new QmlJSc::ParserPass(); + pipeline.appendCompilerPass(parserPass); QString invalidQml = "not valid QML"; - QSignalSpy spy(stage, SIGNAL(finished(QQmlJS::AST::UiProgram*))); + QSignalSpy spy(parserPass, SIGNAL(finished(QQmlJS::AST::UiProgram*))); try { - stage->process(invalidQml); + parserPass->process(invalidQml); QFAIL("an parse error should have been thrown"); } catch (QmlJSc::Error& error) { QCOMPARE(error.type(), QmlJSc::Error::ParseError); } QCOMPARE(spy.count(), 0); } -QTEST_MAIN(TestParserStage) -#include "testparserstage.moc" +QTEST_MAIN(TestParserPass) +#include "testparserpass.moc" diff --git a/tests/auto/qmljsc/testprettygeneratorstage.cpp b/tests/auto/qmljsc/testprettygeneratorpass.cpp similarity index 79% rename from tests/auto/qmljsc/testprettygeneratorstage.cpp rename to tests/auto/qmljsc/testprettygeneratorpass.cpp index 6014659..ccc7518 100644 --- a/tests/auto/qmljsc/testprettygeneratorstage.cpp +++ b/tests/auto/qmljsc/testprettygeneratorpass.cpp @@ -1,86 +1,86 @@ /* * Copyright (C) 2015 Jan Marker * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ #include #include #include #include #include #include #include "../../../src/qmljsc/compilerpipeline.h" -#include "../../../src/qmljsc/parserstage.h" -#include "../../../src/qmljsc/prettygeneratorstage.h" +#include "../../../src/qmljsc/parserpass.h" +#include "../../../src/qmljsc/prettygeneratorpass.h" #include "../../../src/qmljsc/compiler.h" -class TestPrettyGeneratorStage : public QObject +class TestPrettyGeneratorPass : public QObject { Q_OBJECT private: private slots: void initTestCase(); void printout_data(); void printout(); }; -void TestPrettyGeneratorStage::initTestCase() +void TestPrettyGeneratorPass::initTestCase() { new QmlJSc::Compiler(); } -void TestPrettyGeneratorStage::printout_data() +void TestPrettyGeneratorPass::printout_data() { QTest::addColumn("qmlFileUrl"); QTest::addColumn("jsFileUrl"); QTest::newRow("minimal") << ":/test/minimal.qml" << ":/test/minimal.qml.js"; } -void TestPrettyGeneratorStage::printout() +void TestPrettyGeneratorPass::printout() { QFETCH(QString, qmlFileUrl); QFETCH(QString, jsFileUrl); QFile jsFile(jsFileUrl); Q_ASSERT(jsFile.open(QFile::ReadOnly)); QTextStream jsFileStream(&jsFile); QString jsFileContent = jsFileStream.readAll(); QmlJSc::SymbolTable symbolTable; QmlJSc::CompilerPipeline pipeline; - pipeline.appendCompilerPass(new QmlJSc::ParserStage()); - pipeline.appendCompilerPass(new QmlJSc::PrettyGeneratorStage(&symbolTable)); + pipeline.appendCompilerPass(new QmlJSc::ParserPass()); + pipeline.appendCompilerPass(new QmlJSc::PrettyGeneratorPass(&symbolTable)); QSignalSpy pipelineFinished(&pipeline, SIGNAL(compileFinished(QString))); pipeline.compile(qmlFileUrl); QCOMPARE(pipelineFinished.count(), 1); QString compilerOutput = pipelineFinished.takeFirst().takeFirst().value(); QCOMPARE(compilerOutput, jsFileContent); } -QTEST_MAIN(TestPrettyGeneratorStage) -#include "testprettygeneratorstage.moc" +QTEST_MAIN(TestPrettyGeneratorPass) +#include "testprettygeneratorpass.moc"