diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2019-07-09 14:30:24 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-07-11 11:14:54 +0200 |
commit | f5e4f0784176a6c6e80176b1916ebe8a571f3646 (patch) | |
tree | 8bbfa93b4645bee727a48f6d98d115ce548139ff /src/qml/compiler | |
parent | be600348ef3530ba69290cb1610d673faafae866 (diff) |
Disentangle includes and namespaces
Avoid using namespace in headers and include only the headers we
actually need.
Change-Id: I526a0f874dc09b07693fd87070665be396d3b637
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/compiler')
-rw-r--r-- | src/qml/compiler/qqmlirbuilder.cpp | 1 | ||||
-rw-r--r-- | src/qml/compiler/qqmlirbuilder_p.h | 22 | ||||
-rw-r--r-- | src/qml/compiler/qv4codegen.cpp | 1 | ||||
-rw-r--r-- | src/qml/compiler/qv4codegen_p.h | 270 | ||||
-rw-r--r-- | src/qml/compiler/qv4compilercontrolflow_p.h | 10 | ||||
-rw-r--r-- | src/qml/compiler/qv4compilerscanfunctions.cpp | 1 | ||||
-rw-r--r-- | src/qml/compiler/qv4compilerscanfunctions_p.h | 99 |
7 files changed, 208 insertions, 196 deletions
diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp index 3bad0d6a10..aab3f8e9d6 100644 --- a/src/qml/compiler/qqmlirbuilder.cpp +++ b/src/qml/compiler/qqmlirbuilder.cpp @@ -56,6 +56,7 @@ QT_USE_NAMESPACE static const quint32 emptyStringIndex = 0; using namespace QmlIR; +using namespace QQmlJS; #define COMPILE_EXCEPTION(location, desc) \ { \ diff --git a/src/qml/compiler/qqmlirbuilder_p.h b/src/qml/compiler/qqmlirbuilder_p.h index b4a815f11b..82b9050c0b 100644 --- a/src/qml/compiler/qqmlirbuilder_p.h +++ b/src/qml/compiler/qqmlirbuilder_p.h @@ -269,7 +269,7 @@ struct Function QV4::CompiledData::Location location; int nameIndex; quint32 index; // index in parsedQML::functions - FixedPoolArray<Parameter> formals; + QQmlJS::FixedPoolArray<Parameter> formals; QV4::CompiledData::ParameterType returnType; // --- QQmlPropertyCacheCreator interface @@ -350,9 +350,9 @@ public: QString bindingAsString(Document *doc, int scriptIndex) const; PoolList<CompiledFunctionOrExpression> *functionsAndExpressions; - FixedPoolArray<int> runtimeFunctionIndices; + QQmlJS::FixedPoolArray<int> runtimeFunctionIndices; - FixedPoolArray<quint32> namedObjectsInComponent; + QQmlJS::FixedPoolArray<quint32> namedObjectsInComponent; int namedObjectsInComponentCount() const { return namedObjectsInComponent.size(); } const quint32 *namedObjectsInComponentTable() const { return namedObjectsInComponent.begin(); } @@ -440,7 +440,7 @@ public: void throwRecursionDepthError() override { - recordError(AST::SourceLocation(), + recordError(QQmlJS::AST::SourceLocation(), QStringLiteral("Maximum statement or expression depth exceeded")); } @@ -459,13 +459,19 @@ public: QStringRef textRefAt(const QQmlJS::AST::SourceLocation &first, const QQmlJS::AST::SourceLocation &last) const; - void setBindingValue(QV4::CompiledData::Binding *binding, QQmlJS::AST::Statement *statement, AST::Node *parentNode); + void setBindingValue(QV4::CompiledData::Binding *binding, QQmlJS::AST::Statement *statement, + QQmlJS::AST::Node *parentNode); void tryGeneratingTranslationBinding(const QStringRef &base, QQmlJS::AST::ArgumentList *args, QV4::CompiledData::Binding *binding); - void appendBinding(QQmlJS::AST::UiQualifiedId *name, QQmlJS::AST::Statement *value, AST::Node *parentNode); + void appendBinding(QQmlJS::AST::UiQualifiedId *name, QQmlJS::AST::Statement *value, + QQmlJS::AST::Node *parentNode); void appendBinding(QQmlJS::AST::UiQualifiedId *name, int objectIndex, bool isOnAssignment = false); - void appendBinding(const QQmlJS::AST::SourceLocation &qualifiedNameLocation, const QQmlJS::AST::SourceLocation &nameLocation, quint32 propertyNameIndex, QQmlJS::AST::Statement *value, AST::Node *parentNode); - void appendBinding(const QQmlJS::AST::SourceLocation &qualifiedNameLocation, const QQmlJS::AST::SourceLocation &nameLocation, quint32 propertyNameIndex, int objectIndex, bool isListItem = false, bool isOnAssignment = false); + void appendBinding(const QQmlJS::AST::SourceLocation &qualifiedNameLocation, + const QQmlJS::AST::SourceLocation &nameLocation, quint32 propertyNameIndex, + QQmlJS::AST::Statement *value, QQmlJS::AST::Node *parentNode); + void appendBinding(const QQmlJS::AST::SourceLocation &qualifiedNameLocation, + const QQmlJS::AST::SourceLocation &nameLocation, quint32 propertyNameIndex, + int objectIndex, bool isListItem = false, bool isOnAssignment = false); bool appendAlias(QQmlJS::AST::UiPublicMember *node); diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index 6248348d8e..86617aa428 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -69,6 +69,7 @@ static const bool disable_lookups = false; QT_USE_NAMESPACE using namespace QV4; using namespace QV4::Compiler; +using namespace QQmlJS; using namespace QQmlJS::AST; static inline void setJumpOutLocation(QV4::Moth::BytecodeGenerator *bytecodeGenerator, diff --git a/src/qml/compiler/qv4codegen_p.h b/src/qml/compiler/qv4codegen_p.h index ef710b5648..491ecb2a0d 100644 --- a/src/qml/compiler/qv4codegen_p.h +++ b/src/qml/compiler/qv4codegen_p.h @@ -63,8 +63,6 @@ QT_BEGIN_NAMESPACE -using namespace QQmlJS; - namespace QV4 { namespace Moth { @@ -93,14 +91,14 @@ public: void generateFromProgram(const QString &fileName, const QString &finalUrl, const QString &sourceCode, - AST::Program *ast, + QQmlJS::AST::Program *ast, Module *module, ContextType contextType = ContextType::Global); void generateFromModule(const QString &fileName, const QString &finalUrl, const QString &sourceCode, - AST::ESModule *ast, + QQmlJS::AST::ESModule *ast, Module *module); public: @@ -487,10 +485,10 @@ protected: } }; - void enterContext(AST::Node *node); + void enterContext(QQmlJS::AST::Node *node); int leaveContext(); public: - Context *enterBlock(AST::Node *node); + Context *enterBlock(QQmlJS::AST::Node *node); int leaveBlock() { return leaveContext(); } protected: void leaveLoop(); @@ -521,18 +519,18 @@ public: int registerQmlContextPropertyGetterLookup(int nameIndex) { return jsUnitGenerator->registerQmlContextPropertyGetterLookup(nameIndex); } // Returns index in _module->functions - virtual int defineFunction(const QString &name, AST::Node *ast, - AST::FormalParameterList *formals, - AST::StatementList *body); + virtual int defineFunction(const QString &name, QQmlJS::AST::Node *ast, + QQmlJS::AST::FormalParameterList *formals, + QQmlJS::AST::StatementList *body); protected: - void statement(AST::Statement *ast); - void statement(AST::ExpressionNode *ast); - void condition(AST::ExpressionNode *ast, const BytecodeGenerator::Label *iftrue, + void statement(QQmlJS::AST::Statement *ast); + void statement(QQmlJS::AST::ExpressionNode *ast); + void condition(QQmlJS::AST::ExpressionNode *ast, const BytecodeGenerator::Label *iftrue, const BytecodeGenerator::Label *iffalse, bool trueBlockFollowsCondition); - inline Reference expression(AST::ExpressionNode *ast, const QString &name = QString()) + inline Reference expression(QQmlJS::AST::ExpressionNode *ast, const QString &name = QString()) { if (!ast || hasError()) return Reference(); @@ -542,133 +540,134 @@ protected: return popResult(); } - inline void accept(AST::Node *node) + inline void accept(QQmlJS::AST::Node *node) { if (!hasError() && node) node->accept(this); } - void program(AST::Program *ast); - void statementList(AST::StatementList *ast); - void variableDeclaration(AST::PatternElement *ast); - void variableDeclarationList(AST::VariableDeclarationList *ast); + void program(QQmlJS::AST::Program *ast); + void statementList(QQmlJS::AST::StatementList *ast); + void variableDeclaration(QQmlJS::AST::PatternElement *ast); + void variableDeclarationList(QQmlJS::AST::VariableDeclarationList *ast); - Reference targetForPatternElement(AST::PatternElement *p); - void initializeAndDestructureBindingElement(AST::PatternElement *e, const Reference &baseRef = Reference(), bool isDefinition = false); - void destructurePropertyList(const Reference &object, AST::PatternPropertyList *bindingList, bool isDefinition = false); - void destructureElementList(const Reference &array, AST::PatternElementList *bindingList, bool isDefinition = false); - void destructurePattern(AST::Pattern *p, const Reference &rhs); + Reference targetForPatternElement(QQmlJS::AST::PatternElement *p); + void initializeAndDestructureBindingElement(QQmlJS::AST::PatternElement *e, const Reference &baseRef = Reference(), bool isDefinition = false); + void destructurePropertyList(const Reference &object, QQmlJS::AST::PatternPropertyList *bindingList, bool isDefinition = false); + void destructureElementList(const Reference &array, QQmlJS::AST::PatternElementList *bindingList, bool isDefinition = false); + void destructurePattern(QQmlJS::AST::Pattern *p, const Reference &rhs); - Reference referenceForPropertyName(const Codegen::Reference &object, AST::PropertyName *name); + Reference referenceForPropertyName(const Codegen::Reference &object, QQmlJS::AST::PropertyName *name); void emitReturn(const Reference &expr); // nodes - bool visit(AST::ArgumentList *ast) override; - bool visit(AST::CaseBlock *ast) override; - bool visit(AST::CaseClause *ast) override; - bool visit(AST::CaseClauses *ast) override; - bool visit(AST::Catch *ast) override; - bool visit(AST::DefaultClause *ast) override; - bool visit(AST::Elision *ast) override; - bool visit(AST::Finally *ast) override; - bool visit(AST::FormalParameterList *ast) override; - bool visit(AST::Program *ast) override; - bool visit(AST::StatementList *ast) override; - bool visit(AST::UiArrayMemberList *ast) override; - bool visit(AST::UiImport *ast) override; - bool visit(AST::UiHeaderItemList *ast) override; - bool visit(AST::UiPragma *ast) override; - bool visit(AST::UiObjectInitializer *ast) override; - bool visit(AST::UiObjectMemberList *ast) override; - bool visit(AST::UiParameterList *ast) override; - bool visit(AST::UiProgram *ast) override; - bool visit(AST::UiQualifiedId *ast) override; - bool visit(AST::VariableDeclarationList *ast) override; - - bool visit(AST::PatternElement *ast) override; - bool visit(AST::PatternElementList *ast) override; - bool visit(AST::PatternProperty *ast) override; - bool visit(AST::PatternPropertyList *ast) override; - - bool visit(AST::ExportDeclaration *ast) override; - - bool visit(AST::TypeAnnotation *ast) override; + bool visit(QQmlJS::AST::ArgumentList *ast) override; + bool visit(QQmlJS::AST::CaseBlock *ast) override; + bool visit(QQmlJS::AST::CaseClause *ast) override; + bool visit(QQmlJS::AST::CaseClauses *ast) override; + bool visit(QQmlJS::AST::Catch *ast) override; + bool visit(QQmlJS::AST::DefaultClause *ast) override; + bool visit(QQmlJS::AST::Elision *ast) override; + bool visit(QQmlJS::AST::Finally *ast) override; + bool visit(QQmlJS::AST::FormalParameterList *ast) override; + bool visit(QQmlJS::AST::Program *ast) override; + bool visit(QQmlJS::AST::StatementList *ast) override; + bool visit(QQmlJS::AST::UiArrayMemberList *ast) override; + bool visit(QQmlJS::AST::UiImport *ast) override; + bool visit(QQmlJS::AST::UiHeaderItemList *ast) override; + bool visit(QQmlJS::AST::UiPragma *ast) override; + bool visit(QQmlJS::AST::UiObjectInitializer *ast) override; + bool visit(QQmlJS::AST::UiObjectMemberList *ast) override; + bool visit(QQmlJS::AST::UiParameterList *ast) override; + bool visit(QQmlJS::AST::UiProgram *ast) override; + bool visit(QQmlJS::AST::UiQualifiedId *ast) override; + bool visit(QQmlJS::AST::VariableDeclarationList *ast) override; + + bool visit(QQmlJS::AST::PatternElement *ast) override; + bool visit(QQmlJS::AST::PatternElementList *ast) override; + bool visit(QQmlJS::AST::PatternProperty *ast) override; + bool visit(QQmlJS::AST::PatternPropertyList *ast) override; + + bool visit(QQmlJS::AST::ExportDeclaration *ast) override; + + bool visit(QQmlJS::AST::TypeAnnotation *ast) override; // expressions - bool visit(AST::Expression *ast) override; - bool visit(AST::ArrayPattern *ast) override; - bool visit(AST::ArrayMemberExpression *ast) override; - bool visit(AST::BinaryExpression *ast) override; - bool visit(AST::CallExpression *ast) override; - bool visit(AST::ConditionalExpression *ast) override; - bool visit(AST::DeleteExpression *ast) override; - bool visit(AST::FalseLiteral *ast) override; - bool visit(AST::SuperLiteral *ast) override; - bool visit(AST::FieldMemberExpression *ast) override; - bool visit(AST::TaggedTemplate *ast) override; - bool visit(AST::FunctionExpression *ast) override; - bool visit(AST::IdentifierExpression *ast) override; - bool visit(AST::NestedExpression *ast) override; - bool visit(AST::NewExpression *ast) override; - bool visit(AST::NewMemberExpression *ast) override; - bool visit(AST::NotExpression *ast) override; - bool visit(AST::NullExpression *ast) override; - bool visit(AST::NumericLiteral *ast) override; - bool visit(AST::ObjectPattern *ast) override; - bool visit(AST::PostDecrementExpression *ast) override; - bool visit(AST::PostIncrementExpression *ast) override; - bool visit(AST::PreDecrementExpression *ast) override; - bool visit(AST::PreIncrementExpression *ast) override; - bool visit(AST::RegExpLiteral *ast) override; - bool visit(AST::StringLiteral *ast) override; - bool visit(AST::TemplateLiteral *ast) override; - bool visit(AST::ThisExpression *ast) override; - bool visit(AST::TildeExpression *ast) override; - bool visit(AST::TrueLiteral *ast) override; - bool visit(AST::TypeOfExpression *ast) override; - bool visit(AST::UnaryMinusExpression *ast) override; - bool visit(AST::UnaryPlusExpression *ast) override; - bool visit(AST::VoidExpression *ast) override; - bool visit(AST::FunctionDeclaration *ast) override; - bool visit(AST::YieldExpression *ast) override; - bool visit(AST::ClassExpression *ast) override; - bool visit(AST::ClassDeclaration *ast) override; + bool visit(QQmlJS::AST::Expression *ast) override; + bool visit(QQmlJS::AST::ArrayPattern *ast) override; + bool visit(QQmlJS::AST::ArrayMemberExpression *ast) override; + bool visit(QQmlJS::AST::BinaryExpression *ast) override; + bool visit(QQmlJS::AST::CallExpression *ast) override; + bool visit(QQmlJS::AST::ConditionalExpression *ast) override; + bool visit(QQmlJS::AST::DeleteExpression *ast) override; + bool visit(QQmlJS::AST::FalseLiteral *ast) override; + bool visit(QQmlJS::AST::SuperLiteral *ast) override; + bool visit(QQmlJS::AST::FieldMemberExpression *ast) override; + bool visit(QQmlJS::AST::TaggedTemplate *ast) override; + bool visit(QQmlJS::AST::FunctionExpression *ast) override; + bool visit(QQmlJS::AST::IdentifierExpression *ast) override; + bool visit(QQmlJS::AST::NestedExpression *ast) override; + bool visit(QQmlJS::AST::NewExpression *ast) override; + bool visit(QQmlJS::AST::NewMemberExpression *ast) override; + bool visit(QQmlJS::AST::NotExpression *ast) override; + bool visit(QQmlJS::AST::NullExpression *ast) override; + bool visit(QQmlJS::AST::NumericLiteral *ast) override; + bool visit(QQmlJS::AST::ObjectPattern *ast) override; + bool visit(QQmlJS::AST::PostDecrementExpression *ast) override; + bool visit(QQmlJS::AST::PostIncrementExpression *ast) override; + bool visit(QQmlJS::AST::PreDecrementExpression *ast) override; + bool visit(QQmlJS::AST::PreIncrementExpression *ast) override; + bool visit(QQmlJS::AST::RegExpLiteral *ast) override; + bool visit(QQmlJS::AST::StringLiteral *ast) override; + bool visit(QQmlJS::AST::TemplateLiteral *ast) override; + bool visit(QQmlJS::AST::ThisExpression *ast) override; + bool visit(QQmlJS::AST::TildeExpression *ast) override; + bool visit(QQmlJS::AST::TrueLiteral *ast) override; + bool visit(QQmlJS::AST::TypeOfExpression *ast) override; + bool visit(QQmlJS::AST::UnaryMinusExpression *ast) override; + bool visit(QQmlJS::AST::UnaryPlusExpression *ast) override; + bool visit(QQmlJS::AST::VoidExpression *ast) override; + bool visit(QQmlJS::AST::FunctionDeclaration *ast) override; + bool visit(QQmlJS::AST::YieldExpression *ast) override; + bool visit(QQmlJS::AST::ClassExpression *ast) override; + bool visit(QQmlJS::AST::ClassDeclaration *ast) override; // statements - bool visit(AST::Block *ast) override; - bool visit(AST::BreakStatement *ast) override; - bool visit(AST::ContinueStatement *ast) override; - bool visit(AST::DebuggerStatement *ast) override; - bool visit(AST::DoWhileStatement *ast) override; - bool visit(AST::EmptyStatement *ast) override; - bool visit(AST::ExpressionStatement *ast) override; - bool visit(AST::ForEachStatement *ast) override; - bool visit(AST::ForStatement *ast) override; - bool visit(AST::IfStatement *ast) override; - bool visit(AST::LabelledStatement *ast) override; - bool visit(AST::ReturnStatement *ast) override; - bool visit(AST::SwitchStatement *ast) override; - bool visit(AST::ThrowStatement *ast) override; - bool visit(AST::TryStatement *ast) override; - bool visit(AST::VariableStatement *ast) override; - bool visit(AST::WhileStatement *ast) override; - bool visit(AST::WithStatement *ast) override; + bool visit(QQmlJS::AST::Block *ast) override; + bool visit(QQmlJS::AST::BreakStatement *ast) override; + bool visit(QQmlJS::AST::ContinueStatement *ast) override; + bool visit(QQmlJS::AST::DebuggerStatement *ast) override; + bool visit(QQmlJS::AST::DoWhileStatement *ast) override; + bool visit(QQmlJS::AST::EmptyStatement *ast) override; + bool visit(QQmlJS::AST::ExpressionStatement *ast) override; + bool visit(QQmlJS::AST::ForEachStatement *ast) override; + bool visit(QQmlJS::AST::ForStatement *ast) override; + bool visit(QQmlJS::AST::IfStatement *ast) override; + bool visit(QQmlJS::AST::LabelledStatement *ast) override; + bool visit(QQmlJS::AST::ReturnStatement *ast) override; + bool visit(QQmlJS::AST::SwitchStatement *ast) override; + bool visit(QQmlJS::AST::ThrowStatement *ast) override; + bool visit(QQmlJS::AST::TryStatement *ast) override; + bool visit(QQmlJS::AST::VariableStatement *ast) override; + bool visit(QQmlJS::AST::WhileStatement *ast) override; + bool visit(QQmlJS::AST::WithStatement *ast) override; // ui object members - bool visit(AST::UiArrayBinding *ast) override; - bool visit(AST::UiObjectBinding *ast) override; - bool visit(AST::UiObjectDefinition *ast) override; - bool visit(AST::UiPublicMember *ast) override; - bool visit(AST::UiScriptBinding *ast) override; - bool visit(AST::UiSourceElement *ast) override; - - bool throwSyntaxErrorOnEvalOrArgumentsInStrictMode(const Reference &r, const AST::SourceLocation &loc); - virtual void throwSyntaxError(const AST::SourceLocation &loc, const QString &detail); - virtual void throwReferenceError(const AST::SourceLocation &loc, const QString &detail); + bool visit(QQmlJS::AST::UiArrayBinding *ast) override; + bool visit(QQmlJS::AST::UiObjectBinding *ast) override; + bool visit(QQmlJS::AST::UiObjectDefinition *ast) override; + bool visit(QQmlJS::AST::UiPublicMember *ast) override; + bool visit(QQmlJS::AST::UiScriptBinding *ast) override; + bool visit(QQmlJS::AST::UiSourceElement *ast) override; + + bool throwSyntaxErrorOnEvalOrArgumentsInStrictMode(const Reference &r, + const QQmlJS::AST::SourceLocation &loc); + virtual void throwSyntaxError(const QQmlJS::AST::SourceLocation &loc, const QString &detail); + virtual void throwReferenceError(const QQmlJS::AST::SourceLocation &loc, const QString &detail); void throwRecursionDepthError() override { - throwSyntaxError(AST::SourceLocation(), + throwSyntaxError(QQmlJS::AST::SourceLocation(), QStringLiteral("Maximum statement or expression depth exceeded")); } @@ -681,31 +680,33 @@ public: ErrorType errorType() const { return _errorType; } bool hasError() const { return _errorType != NoError; } - DiagnosticMessage error() const; + QQmlJS::DiagnosticMessage error() const; QUrl url() const; Reference binopHelper(QSOperator::Op oper, Reference &left, Reference &right); Reference jumpBinop(QSOperator::Op oper, Reference &left, Reference &right); struct Arguments { int argc; int argv; bool hasSpread; }; - Arguments pushArgs(AST::ArgumentList *args); + Arguments pushArgs(QQmlJS::AST::ArgumentList *args); void handleCall(Reference &base, Arguments calldata, int slotForFunction, int slotForThisObject); - Arguments pushTemplateArgs(AST::TemplateLiteral *args); - bool handleTaggedTemplate(Reference base, AST::TaggedTemplate *ast); - void createTemplateObject(AST::TemplateLiteral *t); + Arguments pushTemplateArgs(QQmlJS::AST::TemplateLiteral *args); + bool handleTaggedTemplate(Reference base, QQmlJS::AST::TaggedTemplate *ast); + void createTemplateObject(QQmlJS::AST::TemplateLiteral *t); void setUseFastLookups(bool b) { useFastLookups = b; } - void handleTryCatch(AST::TryStatement *ast); - void handleTryFinally(AST::TryStatement *ast); + void handleTryCatch(QQmlJS::AST::TryStatement *ast); + void handleTryFinally(QQmlJS::AST::TryStatement *ast); - Reference referenceForName(const QString &name, bool lhs, const QQmlJS::AST::SourceLocation &accessLocation = QQmlJS::AST::SourceLocation()); + Reference referenceForName( + const QString &name, bool lhs, + const QQmlJS::AST::SourceLocation &accessLocation = QQmlJS::AST::SourceLocation()); QV4::CompiledData::CompilationUnit generateCompilationUnit(bool generateUnitData = true); static QV4::CompiledData::CompilationUnit compileModule( bool debugMode, const QString &url, const QString &sourceCode, - const QDateTime &sourceTimeStamp, QList<DiagnosticMessage> *diagnostics); + const QDateTime &sourceTimeStamp, QList<QQmlJS::DiagnosticMessage> *diagnostics); Context *currentContext() const { return _context; } BytecodeGenerator *generator() const { return bytecodeGenerator; } @@ -764,7 +765,7 @@ protected: int _returnAddress; Context *_context; Context *_functionContext = nullptr; - AST::LabelledStatement *_labelledStatement; + QQmlJS::AST::LabelledStatement *_labelledStatement; QV4::Compiler::JSUnitGenerator *jsUnitGenerator; BytecodeGenerator *bytecodeGenerator = nullptr; Moth::BytecodeGenerator::Label *_returnLabel = nullptr; @@ -808,9 +809,10 @@ protected: }; private: - VolatileMemoryLocations scanVolatileMemoryLocations(AST::Node *ast); - void handleConstruct(const Reference &base, AST::ArgumentList *args); - void throwError(ErrorType errorType, const AST::SourceLocation &loc, const QString &detail); + VolatileMemoryLocations scanVolatileMemoryLocations(QQmlJS::AST::Node *ast); + void handleConstruct(const Reference &base, QQmlJS::AST::ArgumentList *args); + void throwError(ErrorType errorType, const QQmlJS::AST::SourceLocation &loc, + const QString &detail); }; } diff --git a/src/qml/compiler/qv4compilercontrolflow_p.h b/src/qml/compiler/qv4compilercontrolflow_p.h index 5b622e81d8..8ae618a6d4 100644 --- a/src/qml/compiler/qv4compilercontrolflow_p.h +++ b/src/qml/compiler/qv4compilercontrolflow_p.h @@ -279,7 +279,7 @@ struct ControlFlowWith : public ControlFlowUnwind struct ControlFlowBlock : public ControlFlowUnwind { - ControlFlowBlock(Codegen *cg, AST::Node *ast) + ControlFlowBlock(Codegen *cg, QQmlJS::AST::Node *ast) : ControlFlowUnwind(cg, Block) { block = cg->enterBlock(ast); @@ -314,11 +314,11 @@ struct ControlFlowBlock : public ControlFlowUnwind struct ControlFlowCatch : public ControlFlowUnwind { - AST::Catch *catchExpression; + QQmlJS::AST::Catch *catchExpression; bool insideCatch = false; BytecodeGenerator::ExceptionHandler exceptionLabel; - ControlFlowCatch(Codegen *cg, AST::Catch *catchExpression) + ControlFlowCatch(Codegen *cg, QQmlJS::AST::Catch *catchExpression) : ControlFlowUnwind(cg, Catch), catchExpression(catchExpression), exceptionLabel(generator()->newExceptionHandler()) { @@ -372,10 +372,10 @@ struct ControlFlowCatch : public ControlFlowUnwind struct ControlFlowFinally : public ControlFlowUnwind { - AST::Finally *finally; + QQmlJS::AST::Finally *finally; bool insideFinally = false; - ControlFlowFinally(Codegen *cg, AST::Finally *finally) + ControlFlowFinally(Codegen *cg, QQmlJS::AST::Finally *finally) : ControlFlowUnwind(cg, Finally), finally(finally) { Q_ASSERT(finally != nullptr); diff --git a/src/qml/compiler/qv4compilerscanfunctions.cpp b/src/qml/compiler/qv4compilerscanfunctions.cpp index 003c32a8fe..ab0ebf3d4b 100644 --- a/src/qml/compiler/qv4compilerscanfunctions.cpp +++ b/src/qml/compiler/qv4compilerscanfunctions.cpp @@ -52,6 +52,7 @@ QT_USE_NAMESPACE using namespace QV4; using namespace QV4::Compiler; +using namespace QQmlJS; using namespace QQmlJS::AST; static CompiledData::Location location(const QQmlJS::AST::SourceLocation &astLocation) diff --git a/src/qml/compiler/qv4compilerscanfunctions_p.h b/src/qml/compiler/qv4compilerscanfunctions_p.h index 0f7bf1818a..84d3ff5e31 100644 --- a/src/qml/compiler/qv4compilerscanfunctions_p.h +++ b/src/qml/compiler/qv4compilerscanfunctions_p.h @@ -62,8 +62,6 @@ QT_BEGIN_NAMESPACE -using namespace QQmlJS; - namespace QV4 { namespace Moth { @@ -83,84 +81,87 @@ class ScanFunctions: protected QQmlJS::AST::Visitor typedef QScopedValueRollback<bool> TemporaryBoolAssignment; public: ScanFunctions(Codegen *cg, const QString &sourceCode, ContextType defaultProgramType); - void operator()(AST::Node *node); + void operator()(QQmlJS::AST::Node *node); void enterGlobalEnvironment(ContextType compilationMode); - void enterEnvironment(AST::Node *node, ContextType compilationMode, const QString &name); + void enterEnvironment(QQmlJS::AST::Node *node, ContextType compilationMode, + const QString &name); void leaveEnvironment(); - void enterQmlFunction(AST::FunctionDeclaration *ast) + void enterQmlFunction(QQmlJS::AST::FunctionDeclaration *ast) { enterFunction(ast, false); } protected: using Visitor::visit; using Visitor::endVisit; - void checkDirectivePrologue(AST::StatementList *ast); + void checkDirectivePrologue(QQmlJS::AST::StatementList *ast); - void checkName(const QStringRef &name, const AST::SourceLocation &loc); + void checkName(const QStringRef &name, const QQmlJS::AST::SourceLocation &loc); - bool visit(AST::Program *ast) override; - void endVisit(AST::Program *) override; + bool visit(QQmlJS::AST::Program *ast) override; + void endVisit(QQmlJS::AST::Program *) override; - bool visit(AST::ESModule *ast) override; - void endVisit(AST::ESModule *) override; + bool visit(QQmlJS::AST::ESModule *ast) override; + void endVisit(QQmlJS::AST::ESModule *) override; - bool visit(AST::ExportDeclaration *declaration) override; - bool visit(AST::ImportDeclaration *declaration) override; + bool visit(QQmlJS::AST::ExportDeclaration *declaration) override; + bool visit(QQmlJS::AST::ImportDeclaration *declaration) override; - bool visit(AST::CallExpression *ast) override; - bool visit(AST::PatternElement *ast) override; - bool visit(AST::IdentifierExpression *ast) override; - bool visit(AST::ExpressionStatement *ast) override; - bool visit(AST::FunctionExpression *ast) override; - bool visit(AST::TemplateLiteral *ast) override; - bool visit(AST::SuperLiteral *) override; - bool visit(AST::FieldMemberExpression *) override; - bool visit(AST::ArrayPattern *) override; + bool visit(QQmlJS::AST::CallExpression *ast) override; + bool visit(QQmlJS::AST::PatternElement *ast) override; + bool visit(QQmlJS::AST::IdentifierExpression *ast) override; + bool visit(QQmlJS::AST::ExpressionStatement *ast) override; + bool visit(QQmlJS::AST::FunctionExpression *ast) override; + bool visit(QQmlJS::AST::TemplateLiteral *ast) override; + bool visit(QQmlJS::AST::SuperLiteral *) override; + bool visit(QQmlJS::AST::FieldMemberExpression *) override; + bool visit(QQmlJS::AST::ArrayPattern *) override; - bool enterFunction(AST::FunctionExpression *ast, bool enterName); + bool enterFunction(QQmlJS::AST::FunctionExpression *ast, bool enterName); - void endVisit(AST::FunctionExpression *) override; + void endVisit(QQmlJS::AST::FunctionExpression *) override; - bool visit(AST::ObjectPattern *ast) override; + bool visit(QQmlJS::AST::ObjectPattern *ast) override; - bool visit(AST::PatternProperty *ast) override; - void endVisit(AST::PatternProperty *) override; + bool visit(QQmlJS::AST::PatternProperty *ast) override; + void endVisit(QQmlJS::AST::PatternProperty *) override; - bool visit(AST::FunctionDeclaration *ast) override; - void endVisit(AST::FunctionDeclaration *) override; + bool visit(QQmlJS::AST::FunctionDeclaration *ast) override; + void endVisit(QQmlJS::AST::FunctionDeclaration *) override; - bool visit(AST::ClassExpression *ast) override; - void endVisit(AST::ClassExpression *) override; + bool visit(QQmlJS::AST::ClassExpression *ast) override; + void endVisit(QQmlJS::AST::ClassExpression *) override; - bool visit(AST::ClassDeclaration *ast) override; - void endVisit(AST::ClassDeclaration *) override; + bool visit(QQmlJS::AST::ClassDeclaration *ast) override; + void endVisit(QQmlJS::AST::ClassDeclaration *) override; - bool visit(AST::DoWhileStatement *ast) override; - bool visit(AST::ForStatement *ast) override; - void endVisit(AST::ForStatement *) override; - bool visit(AST::ForEachStatement *ast) override; - void endVisit(AST::ForEachStatement *) override; + bool visit(QQmlJS::AST::DoWhileStatement *ast) override; + bool visit(QQmlJS::AST::ForStatement *ast) override; + void endVisit(QQmlJS::AST::ForStatement *) override; + bool visit(QQmlJS::AST::ForEachStatement *ast) override; + void endVisit(QQmlJS::AST::ForEachStatement *) override; - bool visit(AST::ThisExpression *ast) override; + bool visit(QQmlJS::AST::ThisExpression *ast) override; - bool visit(AST::Block *ast) override; - void endVisit(AST::Block *ast) override; + bool visit(QQmlJS::AST::Block *ast) override; + void endVisit(QQmlJS::AST::Block *ast) override; - bool visit(AST::CaseBlock *ast) override; - void endVisit(AST::CaseBlock *ast) override; + bool visit(QQmlJS::AST::CaseBlock *ast) override; + void endVisit(QQmlJS::AST::CaseBlock *ast) override; - bool visit(AST::Catch *ast) override; - void endVisit(AST::Catch *ast) override; + bool visit(QQmlJS::AST::Catch *ast) override; + void endVisit(QQmlJS::AST::Catch *ast) override; - bool visit(AST::WithStatement *ast) override; - void endVisit(AST::WithStatement *ast) override; + bool visit(QQmlJS::AST::WithStatement *ast) override; + void endVisit(QQmlJS::AST::WithStatement *ast) override; void throwRecursionDepthError() override; protected: - bool enterFunction(AST::Node *ast, const QString &name, AST::FormalParameterList *formals, AST::StatementList *body, bool enterName); + bool enterFunction(QQmlJS::AST::Node *ast, const QString &name, + QQmlJS::AST::FormalParameterList *formals, + QQmlJS::AST::StatementList *body, bool enterName); void calcEscapingVariables(); // fields: @@ -173,7 +174,7 @@ protected: ContextType defaultProgramType; private: - static constexpr AST::Node *astNodeForGlobalEnvironment = nullptr; + static constexpr QQmlJS::AST::Node *astNodeForGlobalEnvironment = nullptr; }; } |