Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QV4::Compiler::ScanFunctions Class Reference

#include <qv4compilerscanfunctions_p.h>

+ Inheritance diagram for QV4::Compiler::ScanFunctions:
+ Collaboration diagram for QV4::Compiler::ScanFunctions:

Public Member Functions

 ScanFunctions (Codegen *cg, const QString &sourceCode, ContextType defaultProgramType)
 
void operator() (QQmlJS::AST::Node *node)
 
void handleTopLevelFunctionFormals (QQmlJS::AST::FunctionExpression *node)
 
void enterGlobalEnvironment (ContextType compilationMode)
 
void enterEnvironment (QQmlJS::AST::Node *node, ContextType compilationMode, const QString &name)
 
void leaveEnvironment ()
 
void enterQmlFunction (QQmlJS::AST::FunctionExpression *ast)
 

Protected Types

enum class  FunctionNameContext { None , Inner , Outer }
 

Protected Member Functions

void checkDirectivePrologue (QQmlJS::AST::StatementList *ast)
 
void checkName (QStringView name, const QQmlJS::SourceLocation &loc)
 
bool visit (QQmlJS::AST::Program *ast) override
 
void endVisit (QQmlJS::AST::Program *) override
 
bool visit (QQmlJS::AST::ESModule *ast) override
 
void endVisit (QQmlJS::AST::ESModule *) override
 
bool visit (QQmlJS::AST::ExportDeclaration *declaration) override
 
bool visit (QQmlJS::AST::ImportDeclaration *declaration) 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 (QQmlJS::AST::FunctionExpression *ast, FunctionNameContext nameContext)
 
void endVisit (QQmlJS::AST::FunctionExpression *) override
 
bool visit (QQmlJS::AST::ObjectPattern *ast) override
 
bool visit (QQmlJS::AST::PatternProperty *ast) override
 
void endVisit (QQmlJS::AST::PatternProperty *) override
 
bool visit (QQmlJS::AST::FunctionDeclaration *ast) override
 
void endVisit (QQmlJS::AST::FunctionDeclaration *) override
 
bool visit (QQmlJS::AST::ClassExpression *ast) override
 
void endVisit (QQmlJS::AST::ClassExpression *) override
 
bool visit (QQmlJS::AST::ClassDeclaration *ast) override
 
void endVisit (QQmlJS::AST::ClassDeclaration *) 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 (QQmlJS::AST::ThisExpression *ast) override
 
bool visit (QQmlJS::AST::Block *ast) override
 
void endVisit (QQmlJS::AST::Block *ast) override
 
bool visit (QQmlJS::AST::CaseBlock *ast) override
 
void endVisit (QQmlJS::AST::CaseBlock *ast) override
 
bool visit (QQmlJS::AST::Catch *ast) override
 
void endVisit (QQmlJS::AST::Catch *ast) override
 
bool visit (QQmlJS::AST::WithStatement *ast) override
 
void endVisit (QQmlJS::AST::WithStatement *ast) override
 
void throwRecursionDepthError () override
 
bool enterFunction (QQmlJS::AST::Node *ast, const QString &name, QQmlJS::AST::FormalParameterList *formals, QQmlJS::AST::StatementList *body, FunctionNameContext nameContext)
 
void calcEscapingVariables ()
 
- Protected Member Functions inherited from QQmlJS::AST::Visitor
 Visitor (quint16 parentRecursionDepth=0)
 
bool preVisit (Node *) override
 
void postVisit (Node *) override
 
- Protected Member Functions inherited from QQmlJS::AST::BaseVisitor
 BaseVisitor (quint16 parentRecursionDepth=0)
 
virtual ~BaseVisitor ()
 
quint16 recursionDepth () const
 

Protected Attributes

Codegen_cg
 
const QString _sourceCode
 
Context_context
 
QStack< Context * > _contextStack
 
bool _allowFuncDecls
 
ContextType defaultProgramType
 
- Protected Attributes inherited from QQmlJS::AST::BaseVisitor
quint16 m_recursionDepth = 0
 

Detailed Description

Definition at line 43 of file qv4compilerscanfunctions_p.h.

Member Enumeration Documentation

◆ FunctionNameContext

Enumerator
None 
Inner 
Outer 

Definition at line 72 of file qv4compilerscanfunctions_p.h.

Constructor & Destructor Documentation

◆ ScanFunctions()

ScanFunctions::ScanFunctions ( Codegen * cg,
const QString & sourceCode,
ContextType defaultProgramType )

Definition at line 28 of file qv4compilerscanfunctions.cpp.

Member Function Documentation

◆ calcEscapingVariables()

◆ checkDirectivePrologue()

void ScanFunctions::checkDirectivePrologue ( QQmlJS::AST::StatementList * ast)
protected

Definition at line 69 of file qv4compilerscanfunctions.cpp.

References _context, _sourceCode, QV4::Compiler::Context::isStrict, it, QString::mid(), Q_ASSERT, and str.

Referenced by visit().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkName()

void ScanFunctions::checkName ( QStringView name,
const QQmlJS::SourceLocation & loc )
protected

Definition at line 94 of file qv4compilerscanfunctions.cpp.

References _cg, _context, QV4::Compiler::Context::isStrict, Q_ASSERT, QStringLiteral, and QV4::Compiler::Codegen::throwSyntaxError().

Referenced by visit(), and visit().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ endVisit() [1/13]

void ScanFunctions::endVisit ( QQmlJS::AST::Block * ast)
overrideprotected

Definition at line 577 of file qv4compilerscanfunctions.cpp.

References leaveEnvironment().

+ Here is the call graph for this function:

◆ endVisit() [2/13]

void ScanFunctions::endVisit ( QQmlJS::AST::CaseBlock * ast)
overrideprotected

Definition at line 588 of file qv4compilerscanfunctions.cpp.

References leaveEnvironment().

+ Here is the call graph for this function:

◆ endVisit() [3/13]

void ScanFunctions::endVisit ( QQmlJS::AST::Catch * ast)
overrideprotected

Definition at line 616 of file qv4compilerscanfunctions.cpp.

References leaveEnvironment().

+ Here is the call graph for this function:

◆ endVisit() [4/13]

void ScanFunctions::endVisit ( QQmlJS::AST::ClassDeclaration * )
overrideprotected

Definition at line 401 of file qv4compilerscanfunctions.cpp.

References leaveEnvironment().

+ Here is the call graph for this function:

◆ endVisit() [5/13]

void ScanFunctions::endVisit ( QQmlJS::AST::ClassExpression * )
overrideprotected

Definition at line 382 of file qv4compilerscanfunctions.cpp.

References leaveEnvironment().

+ Here is the call graph for this function:

◆ endVisit() [6/13]

void ScanFunctions::endVisit ( QQmlJS::AST::ESModule * )
overrideprotected

Definition at line 132 of file qv4compilerscanfunctions.cpp.

References leaveEnvironment().

+ Here is the call graph for this function:

◆ endVisit() [7/13]

void ScanFunctions::endVisit ( QQmlJS::AST::ForEachStatement * )
overrideprotected

Definition at line 557 of file qv4compilerscanfunctions.cpp.

References leaveEnvironment().

+ Here is the call graph for this function:

◆ endVisit() [8/13]

void ScanFunctions::endVisit ( QQmlJS::AST::ForStatement * )
overrideprotected

Definition at line 536 of file qv4compilerscanfunctions.cpp.

References leaveEnvironment().

+ Here is the call graph for this function:

◆ endVisit() [9/13]

void ScanFunctions::endVisit ( QQmlJS::AST::FunctionDeclaration * )
overrideprotected

Definition at line 509 of file qv4compilerscanfunctions.cpp.

References leaveEnvironment().

+ Here is the call graph for this function:

◆ endVisit() [10/13]

void ScanFunctions::endVisit ( QQmlJS::AST::FunctionExpression * )
overrideprotected

Definition at line 474 of file qv4compilerscanfunctions.cpp.

References leaveEnvironment().

+ Here is the call graph for this function:

◆ endVisit() [11/13]

void ScanFunctions::endVisit ( QQmlJS::AST::PatternProperty * )
overrideprotected

Definition at line 497 of file qv4compilerscanfunctions.cpp.

◆ endVisit() [12/13]

void ScanFunctions::endVisit ( QQmlJS::AST::Program * )
overrideprotected

Definition at line 119 of file qv4compilerscanfunctions.cpp.

References leaveEnvironment().

+ Here is the call graph for this function:

◆ endVisit() [13/13]

void ScanFunctions::endVisit ( QQmlJS::AST::WithStatement * ast)
overrideprotected

Definition at line 639 of file qv4compilerscanfunctions.cpp.

References leaveEnvironment().

+ Here is the call graph for this function:

◆ enterEnvironment()

void ScanFunctions::enterEnvironment ( QQmlJS::AST::Node * node,
ContextType compilationMode,
const QString & name )

Definition at line 51 of file qv4compilerscanfunctions.cpp.

References _cg, _context, _contextStack, QV4::Compiler::Codegen::_module, QV4::Compiler::Codegen::_strictMode, QV4::Compiler::Module::contextMap, QV4::Compiler::Context::isStrict, and QV4::Compiler::Module::newContext().

Referenced by enterGlobalEnvironment(), QV4::RuntimeCodegen::generateFromFunctionExpression(), QmlIR::JSCodeGen::generateJSCodeForFunctionsAndBindings(), visit(), visit(), visit(), visit(), visit(), visit(), visit(), visit(), visit(), and visit().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ enterFunction() [1/2]

bool ScanFunctions::enterFunction ( QQmlJS::AST::FunctionExpression * ast,
FunctionNameContext nameContext )
protected

Definition at line 466 of file qv4compilerscanfunctions.cpp.

References _cg, _context, QQmlJS::AST::FunctionExpression::body, enterFunction(), QQmlJS::AST::FunctionExpression::formals, QQmlJS::AST::FunctionExpression::identifierToken, QV4::Compiler::Context::isStrict, QQmlJS::AST::FunctionExpression::name, Q_ASSERT, QStringLiteral, QV4::Compiler::Codegen::throwSyntaxError(), and QStringView::toString().

Referenced by enterFunction(), enterQmlFunction(), visit(), visit(), and visit().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ enterFunction() [2/2]

bool QV4::Compiler::ScanFunctions::enterFunction ( QQmlJS::AST::Node * ast,
const QString & name,
QQmlJS::AST::FormalParameterList * formals,
QQmlJS::AST::StatementList * body,
FunctionNameContext nameContext )
protected

◆ enterGlobalEnvironment()

void ScanFunctions::enterGlobalEnvironment ( ContextType compilationMode)

Definition at line 46 of file qv4compilerscanfunctions.cpp.

References enterEnvironment(), and QStringLiteral.

Referenced by QmlIR::JSCodeGen::generateJSCodeForFunctionsAndBindings().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ enterQmlFunction()

void QV4::Compiler::ScanFunctions::enterQmlFunction ( QQmlJS::AST::FunctionExpression * ast)
inline

Definition at line 62 of file qv4compilerscanfunctions_p.h.

References enterFunction(), and None.

Referenced by QmlIR::JSCodeGen::generateJSCodeForFunctionsAndBindings().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleTopLevelFunctionFormals()

void QV4::Compiler::ScanFunctions::handleTopLevelFunctionFormals ( QQmlJS::AST::FunctionExpression * node)
inline

Definition at line 52 of file qv4compilerscanfunctions_p.h.

References QQmlJS::AST::Node::accept(), and QQmlJS::AST::FunctionExpression::formals.

Referenced by QmlIR::JSCodeGen::generateJSCodeForFunctionsAndBindings().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ leaveEnvironment()

void ScanFunctions::leaveEnvironment ( )

Definition at line 63 of file qv4compilerscanfunctions.cpp.

References _context, _contextStack, and nullptr.

Referenced by endVisit(), endVisit(), endVisit(), endVisit(), endVisit(), endVisit(), endVisit(), endVisit(), endVisit(), endVisit(), endVisit(), endVisit(), QV4::RuntimeCodegen::generateFromFunctionExpression(), QmlIR::JSCodeGen::generateJSCodeForFunctionsAndBindings(), and visit().

+ Here is the caller graph for this function:

◆ operator()()

void ScanFunctions::operator() ( QQmlJS::AST::Node * node)

Definition at line 38 of file qv4compilerscanfunctions.cpp.

References calcEscapingVariables().

+ Here is the call graph for this function:

◆ throwRecursionDepthError()

void ScanFunctions::throwRecursionDepthError ( )
overrideprotectedvirtual

Implements QQmlJS::AST::BaseVisitor.

Definition at line 892 of file qv4compilerscanfunctions.cpp.

References _cg, and QV4::Compiler::Codegen::throwRecursionDepthError().

+ Here is the call graph for this function:

◆ visit() [1/26]

bool ScanFunctions::visit ( QQmlJS::AST::ArrayPattern * ast)
overrideprotected

Definition at line 458 of file qv4compilerscanfunctions.cpp.

References QQmlJS::AST::ArrayPattern::elements, and it.

◆ visit() [2/26]

bool ScanFunctions::visit ( QQmlJS::AST::Block * ast)
overrideprotected

Definition at line 569 of file qv4compilerscanfunctions.cpp.

References _allowFuncDecls, _context, QV4::Compiler::Block, enterEnvironment(), QV4::Compiler::Context::isStrict, QStringLiteral, and QQmlJS::AST::Block::statements.

+ Here is the call graph for this function:

◆ visit() [3/26]

◆ visit() [4/26]

bool ScanFunctions::visit ( QQmlJS::AST::CaseBlock * ast)
overrideprotected

Definition at line 582 of file qv4compilerscanfunctions.cpp.

References QV4::Compiler::Block, enterEnvironment(), and QStringLiteral.

+ Here is the call graph for this function:

◆ visit() [5/26]

◆ visit() [6/26]

◆ visit() [7/26]

bool ScanFunctions::visit ( QQmlJS::AST::ClassExpression * ast)
overrideprotected

◆ visit() [8/26]

◆ visit() [9/26]

bool ScanFunctions::visit ( QQmlJS::AST::ESModule * ast)
overrideprotected

Definition at line 124 of file qv4compilerscanfunctions.cpp.

References _context, defaultProgramType, enterEnvironment(), QV4::Compiler::Context::isStrict, Q_ASSERT, and QStringLiteral.

+ Here is the call graph for this function:

◆ visit() [10/26]

◆ visit() [11/26]

bool ScanFunctions::visit ( QQmlJS::AST::ExpressionStatement * ast)
overrideprotected

◆ visit() [12/26]

bool ScanFunctions::visit ( QQmlJS::AST::FieldMemberExpression * ast)
overrideprotected

Definition at line 432 of file qv4compilerscanfunctions.cpp.

References _cg, _context, QQmlJS::AST::FieldMemberExpression::base, QV4::Compiler::Block, QQmlJS::AST::FieldMemberExpression::identifierToken, QV4::Compiler::Context::isArrowFunction, QQmlJS::AST::FieldMemberExpression::name, Q_ASSERT, and QV4::Compiler::Codegen::throwSyntaxError().

+ Here is the call graph for this function:

◆ visit() [13/26]

bool ScanFunctions::visit ( QQmlJS::AST::ForEachStatement * ast)
overrideprotected

◆ visit() [14/26]

bool ScanFunctions::visit ( QQmlJS::AST::ForStatement * ast)
overrideprotected

◆ visit() [15/26]

bool ScanFunctions::visit ( QQmlJS::AST::FunctionDeclaration * ast)
overrideprotected

Definition at line 504 of file qv4compilerscanfunctions.cpp.

References enterFunction(), and Outer.

+ Here is the call graph for this function:

◆ visit() [16/26]

bool ScanFunctions::visit ( QQmlJS::AST::FunctionExpression * ast)
overrideprotected

Definition at line 364 of file qv4compilerscanfunctions.cpp.

References enterFunction(), QQmlJS::AST::FunctionExpression::identifierToken, Inner, QQmlJS::SourceLocation::length, and None.

+ Here is the call graph for this function:

◆ visit() [17/26]

bool ScanFunctions::visit ( QQmlJS::AST::IdentifierExpression * ast)
overrideprotected

◆ visit() [18/26]

◆ visit() [19/26]

bool ScanFunctions::visit ( QQmlJS::AST::ObjectPattern * ast)
overrideprotected

◆ visit() [20/26]

◆ visit() [21/26]

bool ScanFunctions::visit ( QQmlJS::AST::PatternProperty * ast)
overrideprotected

Definition at line 486 of file qv4compilerscanfunctions.cpp.

References Q_UNUSED.

◆ visit() [22/26]

bool ScanFunctions::visit ( QQmlJS::AST::Program * ast)
overrideprotected

Definition at line 112 of file qv4compilerscanfunctions.cpp.

References checkDirectivePrologue(), defaultProgramType, enterEnvironment(), QStringLiteral, and QQmlJS::AST::Program::statements.

+ Here is the call graph for this function:

◆ visit() [23/26]

bool ScanFunctions::visit ( QQmlJS::AST::SuperLiteral * )
overrideprotected

◆ visit() [24/26]

bool ScanFunctions::visit ( QQmlJS::AST::TemplateLiteral * ast)
overrideprotected

◆ visit() [25/26]

bool ScanFunctions::visit ( QQmlJS::AST::ThisExpression * ast)
overrideprotected

◆ visit() [26/26]

bool ScanFunctions::visit ( QQmlJS::AST::WithStatement * ast)
overrideprotected

Member Data Documentation

◆ _allowFuncDecls

bool QV4::Compiler::ScanFunctions::_allowFuncDecls
protected

Definition at line 155 of file qv4compilerscanfunctions_p.h.

Referenced by visit(), visit(), visit(), visit(), visit(), visit(), visit(), and visit().

◆ _cg

Codegen* QV4::Compiler::ScanFunctions::_cg
protected

◆ _context

◆ _contextStack

QStack<Context *> QV4::Compiler::ScanFunctions::_contextStack
protected

Definition at line 153 of file qv4compilerscanfunctions_p.h.

Referenced by enterEnvironment(), and leaveEnvironment().

◆ _sourceCode

const QString QV4::Compiler::ScanFunctions::_sourceCode
protected

Definition at line 151 of file qv4compilerscanfunctions_p.h.

Referenced by checkDirectivePrologue(), and visit().

◆ defaultProgramType

ContextType QV4::Compiler::ScanFunctions::defaultProgramType
protected

Definition at line 156 of file qv4compilerscanfunctions_p.h.

Referenced by visit(), and visit().


The documentation for this class was generated from the following files: