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::Context Struct Reference

#include <qv4compilercontext_p.h>

+ Collaboration diagram for QV4::Compiler::Context:

Classes

struct  KeyValuePair
 
struct  Member
 
class  PropertyDependencyMap
 
struct  ResolvedName
 
class  SmallSet
 
struct  SourceLocationTable
 

Public Types

enum  MemberType {
  UndefinedMember , ThisFunctionName , VariableDefinition , VariableDeclaration ,
  FunctionDefinition
}
 
enum  UsesArgumentsObject { ArgumentsObjectUnknown , ArgumentsObjectNotUsed , ArgumentsObjectUsed }
 
typedef QMap< QString, MemberMemberMap
 

Public Member Functions

 Context (Context *parent, ContextType type)
 
bool hasArgument (const QString &name) const
 
int findArgument (const QString &name, bool *isInjected) const
 
Member findMember (const QString &name) const
 
bool memberInfo (const QString &name, const Member **m) const
 
bool requiresImplicitReturnValue () const
 
void addUsedVariable (const QString &name)
 
bool addLocalVar (const QString &name, MemberType contextType, QQmlJS::AST::VariableScope scope, QQmlJS::AST::FunctionExpression *function=nullptr, const QQmlJS::SourceLocation &declarationLocation=QQmlJS::SourceLocation(), bool isInjected=false)
 
ResolvedName resolveName (const QString &name, const QQmlJS::SourceLocation &accessLocation)
 
void emitBlockHeader (Compiler::Codegen *codegen)
 
void emitBlockFooter (Compiler::Codegen *codegen)
 
void setupFunctionIndices (Moth::BytecodeGenerator *bytecodeGenerator)
 
bool canHaveTailCalls () const
 
bool isCaseBlock () const
 

Public Attributes

Contextparent
 
QString name
 
int line = 0
 
int column = 0
 
int registerCountInFunction = 0
 
int functionIndex = -1
 
int blockIndex = -1
 
MemberMap members
 
QSet< QStringusedVariables
 
QQmlJS::AST::FormalParameterListformals = nullptr
 
QQmlJS::AST::BoundNames arguments
 
QQmlJS::AST::TypereturnType = nullptr
 
QStringList locals
 
QStringList moduleRequests
 
QVector< ImportEntryimportEntries
 
QVector< ExportEntryexportEntries
 
QString localNameForDefaultExport
 
QVector< Context * > nestedContexts
 
ControlFlowcontrolFlow = nullptr
 
QByteArray code
 
QVector< CompiledData::CodeOffsetToLineAndStatementlineAndStatementNumberMapping
 
std::unique_ptr< SourceLocationTablesourceLocationTable
 
std::vector< unsigned > labelInfo
 
int nRegisters = 0
 
int registerOffset = -1
 
int sizeOfLocalTemporalDeadZone = 0
 
int firstTemporalDeadZoneRegister = 0
 
int sizeOfRegisterTemporalDeadZone = 0
 
bool hasDirectEval = false
 
bool allVarsEscape = false
 
bool hasNestedFunctions = false
 
bool isStrict = false
 
bool isArrowFunction = false
 
bool isGenerator = false
 
bool usesThis = false
 
bool innerFunctionAccessesThis = false
 
bool innerFunctionAccessesNewTarget = false
 
bool returnsClosure = false
 
bool argumentsCanEscape = false
 
bool requiresExecutionContext = false
 
bool isWithBlock = false
 
bool isCatchBlock = false
 
QString caughtVariable
 
QQmlJS::SourceLocation lastBlockInitializerLocation
 
UsesArgumentsObject usesArgumentsObject = ArgumentsObjectUnknown
 
ContextType contextType
 

Detailed Description

Definition at line 132 of file qv4compilercontext_p.h.

Member Typedef Documentation

◆ MemberMap

Member Enumeration Documentation

◆ MemberType

Enumerator
UndefinedMember 
ThisFunctionName 
VariableDefinition 
VariableDeclaration 
FunctionDefinition 

Definition at line 141 of file qv4compilercontext_p.h.

◆ UsesArgumentsObject

Enumerator
ArgumentsObjectUnknown 
ArgumentsObjectNotUsed 
ArgumentsObjectUsed 

Definition at line 213 of file qv4compilercontext_p.h.

Constructor & Destructor Documentation

◆ Context()

QV4::Compiler::Context::Context ( Context * parent,
ContextType type )
inline

Definition at line 265 of file qv4compilercontext_p.h.

References isStrict, and parent.

Member Function Documentation

◆ addLocalVar()

bool Context::addLocalVar ( const QString & name,
Context::MemberType type,
QQmlJS::AST::VariableScope scope,
QQmlJS::AST::FunctionExpression * function = nullptr,
const QQmlJS::SourceLocation & declarationLocation = QQmlJS::SourceLocation(),
bool isInjected = false )

Definition at line 54 of file qv4compilercontext.cpp.

References addLocalVar(), QV4::Compiler::Block, caughtVariable, QQmlJS::AST::FormalParameterList::containsName(), contextType, QMap< Key, T >::end(), QMap< Key, T >::find(), formals, function, FunctionDefinition, QMap< Key, T >::insert(), isCatchBlock, it, members, parent, and QV4::Compiler::Context::Member::type.

Referenced by addLocalVar(), QV4::Compiler::ScanFunctions::visit(), QV4::Compiler::ScanFunctions::visit(), QV4::Compiler::ScanFunctions::visit(), and QV4::Compiler::ScanFunctions::visit().

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

◆ addUsedVariable()

void QV4::Compiler::Context::addUsedVariable ( const QString & name)
inline

Definition at line 318 of file qv4compilercontext_p.h.

References QSet< T >::insert(), and usedVariables.

Referenced by QV4::Compiler::ScanFunctions::visit().

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

◆ canHaveTailCalls()

bool QV4::Compiler::Context::canHaveTailCalls ( ) const
inline

Definition at line 353 of file qv4compilercontext_p.h.

References QV4::Compiler::Block, canHaveTailCalls(), contextType, QV4::Compiler::Function, isGenerator, isStrict, and parent.

Referenced by canHaveTailCalls(), and QV4::Compiler::Codegen::defineFunction().

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

◆ emitBlockFooter()

void Context::emitBlockFooter ( Compiler::Codegen * codegen)

Definition at line 286 of file qv4compilercontext.cpp.

References QV4::Moth::BytecodeGenerator::addInstruction(), contextType, QV4::Compiler::ESModule, QV4::Compiler::Codegen::generator(), QV4::Compiler::Global, QT_WARNING_DISABLE_GCC, QT_WARNING_POP, QT_WARNING_PUSH, requiresExecutionContext, and QV4::Compiler::ScriptImportedByQML.

Referenced by QV4::Compiler::ControlFlowBlock::~ControlFlowBlock(), QV4::Compiler::ControlFlowCatch::~ControlFlowCatch(), and QV4::Compiler::Codegen::defineFunction().

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

◆ emitBlockHeader()

void Context::emitBlockHeader ( Compiler::Codegen * codegen)

Definition at line 174 of file qv4compilercontext.cpp.

References QV4::Moth::BytecodeGenerator::addInstruction(), ArgumentsObjectUsed, QMap< Key, T >::begin(), QV4::Compiler::Binding, QV4::Compiler::Block, blockIndex, QV4::Compiler::Module::blocks, caughtVariable, QMap< Key, T >::constBegin(), QMap< Key, T >::constEnd(), contextType, convert(), createContext(), QV4::Compiler::Codegen::defineFunction(), QMap< Key, T >::end(), QV4::Compiler::ESModule, QV4::Compiler::Eval, formals, QV4::CallData::Function, QV4::Compiler::Function, QV4::Compiler::Codegen::generator(), QV4::Compiler::Global, innerFunctionAccessesNewTarget, innerFunctionAccessesThis, isCatchBlock, QQmlJS::AST::FormalParameterList::isSimpleParameterList(), isStrict, it, load(), QV4::Compiler::Codegen::loadClosure(), members, QV4::Compiler::Codegen::module(), QV4::CallData::NewTarget, nRegisters, Q_ASSERT, QStringLiteral, QV4::Compiler::Codegen::referenceForName(), registerOffset, QV4::Compiler::Codegen::registerString(), requiresExecutionContext, QV4::Compiler::ScriptImportedByQML, setupFunctionIndices(), sizeOfRegisterTemporalDeadZone, QV4::Compiler::Codegen::Reference::storeConsumeAccumulator(), QV4::CallData::This, ThisFunctionName, usesArgumentsObject, and usesThis.

Referenced by QV4::Compiler::ControlFlowBlock::ControlFlowBlock(), QV4::Compiler::ControlFlowCatch::~ControlFlowCatch(), and QV4::Compiler::Codegen::defineFunction().

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

◆ findArgument()

int QV4::Compiler::Context::findArgument ( const QString & name,
bool * isInjected ) const
inline

Definition at line 278 of file qv4compilercontext_p.h.

References arg, arguments, QList< T >::at(), i, and QList< T >::size().

+ Here is the call graph for this function:

◆ findMember()

Member QV4::Compiler::Context::findMember ( const QString & name) const
inline

Definition at line 291 of file qv4compilercontext_p.h.

References QMap< Key, T >::end(), QMap< Key, T >::find(), it, members, parent, and Q_ASSERT.

+ Here is the call graph for this function:

◆ hasArgument()

bool QV4::Compiler::Context::hasArgument ( const QString & name) const
inline

Definition at line 273 of file qv4compilercontext_p.h.

References arguments, and QQmlJS::AST::BoundNames::contains().

+ Here is the call graph for this function:

◆ isCaseBlock()

bool QV4::Compiler::Context::isCaseBlock ( ) const
inline

Definition at line 364 of file qv4compilercontext_p.h.

References QV4::Compiler::Block, and contextType.

◆ memberInfo()

bool QV4::Compiler::Context::memberInfo ( const QString & name,
const Member ** m ) const
inline

Definition at line 300 of file qv4compilercontext_p.h.

References QMap< Key, T >::end(), QMap< Key, T >::find(), it, members, and Q_ASSERT.

+ Here is the call graph for this function:

◆ requiresImplicitReturnValue()

bool QV4::Compiler::Context::requiresImplicitReturnValue ( ) const
inline

Definition at line 312 of file qv4compilercontext_p.h.

References QV4::Compiler::Binding, contextType, QV4::Compiler::Eval, QV4::Compiler::Global, and QV4::Compiler::ScriptImportedByQML.

Referenced by QV4::Compiler::Codegen::defineFunction().

+ Here is the caller graph for this function:

◆ resolveName()

◆ setupFunctionIndices()

void Context::setupFunctionIndices ( Moth::BytecodeGenerator * bytecodeGenerator)

Member Data Documentation

◆ allVarsEscape

bool QV4::Compiler::Context::allVarsEscape = false

◆ arguments

QQmlJS::AST::BoundNames QV4::Compiler::Context::arguments

◆ argumentsCanEscape

bool QV4::Compiler::Context::argumentsCanEscape = false
mutable

Definition at line 206 of file qv4compilercontext_p.h.

Referenced by QV4::Compiler::Codegen::defineFunction().

◆ blockIndex

int QV4::Compiler::Context::blockIndex = -1

◆ caughtVariable

QString QV4::Compiler::Context::caughtVariable

◆ code

QByteArray QV4::Compiler::Context::code

Definition at line 186 of file qv4compilercontext_p.h.

Referenced by QV4::Compiler::Codegen::defineFunction().

◆ column

int QV4::Compiler::Context::column = 0

Definition at line 136 of file qv4compilercontext_p.h.

Referenced by QQmlJSCodeGenerator::run().

◆ contextType

◆ controlFlow

ControlFlow* QV4::Compiler::Context::controlFlow = nullptr

Definition at line 185 of file qv4compilercontext_p.h.

◆ exportEntries

QVector<ExportEntry> QV4::Compiler::Context::exportEntries

Definition at line 181 of file qv4compilercontext_p.h.

Referenced by QV4::Compiler::ScanFunctions::visit().

◆ firstTemporalDeadZoneRegister

int QV4::Compiler::Context::firstTemporalDeadZoneRegister = 0

Definition at line 194 of file qv4compilercontext_p.h.

Referenced by setupFunctionIndices().

◆ formals

QQmlJS::AST::FormalParameterList* QV4::Compiler::Context::formals = nullptr

Definition at line 175 of file qv4compilercontext_p.h.

Referenced by addLocalVar(), and emitBlockHeader().

◆ functionIndex

int QV4::Compiler::Context::functionIndex = -1

◆ hasDirectEval

bool QV4::Compiler::Context::hasDirectEval = false

Definition at line 196 of file qv4compilercontext_p.h.

Referenced by QV4::Compiler::ScanFunctions::visit().

◆ hasNestedFunctions

bool QV4::Compiler::Context::hasNestedFunctions = false

◆ importEntries

QVector<ImportEntry> QV4::Compiler::Context::importEntries

Definition at line 180 of file qv4compilercontext_p.h.

Referenced by QV4::Compiler::ScanFunctions::visit().

◆ innerFunctionAccessesNewTarget

bool QV4::Compiler::Context::innerFunctionAccessesNewTarget = false

Definition at line 204 of file qv4compilercontext_p.h.

Referenced by emitBlockHeader().

◆ innerFunctionAccessesThis

bool QV4::Compiler::Context::innerFunctionAccessesThis = false

Definition at line 203 of file qv4compilercontext_p.h.

Referenced by emitBlockHeader().

◆ isArrowFunction

◆ isCatchBlock

bool QV4::Compiler::Context::isCatchBlock = false

◆ isGenerator

bool QV4::Compiler::Context::isGenerator = false

◆ isStrict

◆ isWithBlock

bool QV4::Compiler::Context::isWithBlock = false

◆ labelInfo

std::vector<unsigned> QV4::Compiler::Context::labelInfo

Definition at line 189 of file qv4compilercontext_p.h.

Referenced by QQmlJSCodeGenerator::run().

◆ lastBlockInitializerLocation

QQmlJS::SourceLocation QV4::Compiler::Context::lastBlockInitializerLocation

◆ line

int QV4::Compiler::Context::line = 0

◆ lineAndStatementNumberMapping

QVector<CompiledData::CodeOffsetToLineAndStatement> QV4::Compiler::Context::lineAndStatementNumberMapping

Definition at line 187 of file qv4compilercontext_p.h.

Referenced by QV4::Compiler::Codegen::defineFunction().

◆ localNameForDefaultExport

QString QV4::Compiler::Context::localNameForDefaultExport

◆ locals

QStringList QV4::Compiler::Context::locals

◆ members

MemberMap QV4::Compiler::Context::members

◆ moduleRequests

QStringList QV4::Compiler::Context::moduleRequests

◆ name

QString QV4::Compiler::Context::name

◆ nestedContexts

QVector<Context *> QV4::Compiler::Context::nestedContexts

Definition at line 183 of file qv4compilercontext_p.h.

Referenced by QV4::Compiler::Module::newContext().

◆ nRegisters

int QV4::Compiler::Context::nRegisters = 0

Definition at line 191 of file qv4compilercontext_p.h.

Referenced by emitBlockHeader(), and setupFunctionIndices().

◆ parent

◆ registerCountInFunction

int QV4::Compiler::Context::registerCountInFunction = 0

Definition at line 137 of file qv4compilercontext_p.h.

Referenced by QV4::Compiler::Codegen::defineFunction().

◆ registerOffset

int QV4::Compiler::Context::registerOffset = -1

Definition at line 192 of file qv4compilercontext_p.h.

Referenced by emitBlockHeader(), and setupFunctionIndices().

◆ requiresExecutionContext

◆ returnsClosure

bool QV4::Compiler::Context::returnsClosure = false

Definition at line 205 of file qv4compilercontext_p.h.

Referenced by QV4::Compiler::Codegen::defineFunction().

◆ returnType

QQmlJS::AST::Type* QV4::Compiler::Context::returnType = nullptr

Definition at line 177 of file qv4compilercontext_p.h.

◆ sizeOfLocalTemporalDeadZone

int QV4::Compiler::Context::sizeOfLocalTemporalDeadZone = 0

Definition at line 193 of file qv4compilercontext_p.h.

Referenced by setupFunctionIndices().

◆ sizeOfRegisterTemporalDeadZone

int QV4::Compiler::Context::sizeOfRegisterTemporalDeadZone = 0

Definition at line 195 of file qv4compilercontext_p.h.

Referenced by emitBlockHeader(), and setupFunctionIndices().

◆ sourceLocationTable

std::unique_ptr<SourceLocationTable> QV4::Compiler::Context::sourceLocationTable

Definition at line 188 of file qv4compilercontext_p.h.

◆ usedVariables

QSet<QString> QV4::Compiler::Context::usedVariables

Definition at line 174 of file qv4compilercontext_p.h.

Referenced by addUsedVariable().

◆ usesArgumentsObject

◆ usesThis

bool QV4::Compiler::Context::usesThis = false

Definition at line 202 of file qv4compilercontext_p.h.

Referenced by emitBlockHeader(), and QV4::Compiler::ScanFunctions::visit().


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