17#include <private/qqmljsastvisitor_p.h>
18#include <private/qqmljsengine_p.h>
19#include <private/qqmljsast_p.h>
20#include <private/qqmljsdiagnosticmessage_p.h>
21#include <private/qv4compiler_p.h>
22#include <private/qv4compilercontext_p.h>
23#include <private/qv4util_p.h>
24#include <private/qv4bytecodegenerator_p.h>
25#include <private/qv4calldata_p.h>
27#include <QtCore/qsharedpointer.h>
37namespace CompiledData {
38struct CompilationUnit;
44struct ControlFlowCatch;
45struct ControlFlowFinally;
70 bool storeSourceLocations =
false);
89 bool allVolatile =
false;
119 r.theStackSlot = stackSlot;
125 r.type = Accumulator;
154 void loadInAccumulator()
const;
185 isReferenceToConst(
false),
186 requiresTDZCheck(
false),
187 subscriptRequiresTDZCheck(
false),
188 stackSlotIsLocalOrArgument(
false),
192 throwsReferenceError(
false),
193 subscriptLoadedForCall(
false)
203 {
return !(*
this ==
other); }
214 return requiresTDZCheck;
223 return isStackSlot();
236 r.theStackSlot = Moth::StackSlot::createRegister(tempIndex);
237 r.stackSlotIsLocalOrArgument = isLocal;
267 r.sourceLocation = sourceLocation;
275 r.property =
property.stackSlot();
276 r.subscriptRequiresTDZCheck =
property.requiresTDZCheck;
283 r.elementSubscript = subscript.
asRValue();
296 Reference r = fromStackSlot(cg, CallData::This);
300 r.requiresTDZCheck =
true;
311 { Reference::fromConst(cg,
constant).storeOnStack(stackSlot); }
314 void storeOnStack(
int tempIndex)
const;
316 Reference storeConsumeAccumulator()
const;
320 bool storeWipesAccumulator()
const;
321 void loadInAccumulator()
const;
325 return codegen->registerString(
name);
337 tdzCheck(requiresTDZCheck, throwsReferenceError);
338 else if (isStackSlot())
339 tdzCheckStackSlot(stackSlot(), requiresTDZCheck, throwsReferenceError);
381 void storeAccumulator()
const;
382 Reference doStoreOnStack(
int tempIndex)
const;
383 void tdzCheck(
bool requiresCheck,
bool throwsReferenceError)
const;
384 void tdzCheckStackSlot(
385 Moth::StackSlot slot,
bool requiresCheck,
bool throwsReferenceError)
const;
391 regCountForScope(
generator->currentReg) {}
393 generator->currentReg = regCountForScope;
420 bool _trueBlockFollowsCondition =
false;
434 : _requested(requested) {}
438 bool trueBlockFollowsCondition)
442 , _trueBlockFollowsCondition(trueBlockFollowsCondition)
464 if (_requested ==
f) {
472 return _trueBlockFollowsCondition;
484 _result = std::move(
result);
511 Reference unop(UnaryOperation op,
const Reference &expr);
549 const BytecodeGenerator::Label *iffalse,
550 bool trueBlockFollowsCondition);
554 if (!ast || hasError())
564 if (!hasError() && node)
574 void initializeAndDestructureBindingElement(
QQmlJS::AST::PatternElement *
e,
const Reference &baseRef = Reference(),
bool isDefinition =
false);
581 void emitReturn(
const Reference &expr);
687 bool throwSyntaxErrorOnEvalOrArgumentsInStrictMode(
const Reference &
r,
694 QStringLiteral(
"Maximum statement or expression depth exceeded"));
713 void handleCall(
Reference &
base,
Arguments calldata,
int slotForFunction,
int slotForThisObject,
bool optional =
false);
725 Reference referenceForName(
737 void loadClosure(
int index);
744 return *_returnLabel;
748 m_globalNames = globalNames;
751 static const char *s_globalNames[];
768 inline void pushExpr(
Result &&expr) { m_expressions.push_back(std::move(expr)); }
775 m_expressions.pop_back();
781 m_expressions.pop_back();
796 bool useFastLookups =
true;
797 bool requiresReturnValue =
false;
798 bool insideSwitch =
false;
799 bool inFormalParameterList =
false;
800 bool functionEndsWithReturn =
false;
801 bool _tailCallsAreAllowed =
true;
802 bool storeSourceLocations =
false;
819 , _saved(_cg->_tailCallsAreAllowed)
821 { _cg->_tailCallsAreAllowed = onoff; }
824 { _cg->_tailCallsAreAllowed = _saved; }
827 { _cg->_tailCallsAreAllowed = _saved; }
830 { _cg->_tailCallsAreAllowed = _onoff; }
843 std::optional<Moth::BytecodeGenerator::Label> traverseOptionalChain(
QQmlJS::AST::Node *node);
844 Reference loadSubscriptForCall(
const Reference &
base);
\inmodule QtCore\reentrant
void append(parameter_type t)
void accept(BaseVisitor *visitor)
\macro QT_RESTRICTED_CAST_FROM_ASCII
void clear()
Clears the contents of the string and makes it null.
virtual ~CodegenWarningInterface()=default
Moth::StackSlot theStackSlot
static RValue fromStackSlot(Codegen *codegen, Moth::StackSlot stackSlot)
static RValue fromAccumulator(Codegen *codegen)
QV4::ReturnedValue constantValue() const
bool isAccumulator() const
static RValue fromConst(Codegen *codegen, QV4::ReturnedValue value)
QV4::ReturnedValue constant
Moth::StackSlot stackSlot() const
void setResult(const Reference &result)
Result(Format requested=ex)
bool trueBlockFollowsCondition() const
const BytecodeGenerator::Label * iffalse() const
const Reference & result() const
Result(const BytecodeGenerator::Label *iftrue, const BytecodeGenerator::Label *iffalse, bool trueBlockFollowsCondition)
Result(const QString &name)
Result(const Reference &lrvalue)
const BytecodeGenerator::Label * iftrue() const
void setResult(Reference &&result)
TailCallBlocker(Codegen *cg, bool onoff=false)
bool isVolatile(QStringView name)
void add(QStringView name)
void setUseFastLookups(bool b)
QQmlJS::AST::LabelledStatement * _labelledStatement
QSet< QString > m_globalNames
VolatileMemoryLocations _volatileMemoryLocations
CodegenWarningInterface * _interface
BytecodeGenerator * bytecodeGenerator
Context * currentContext() const
void accept(QQmlJS::AST::Node *node)
int registerString(const QString &name)
int registerConstant(QV4::ReturnedValue v)
int registerQmlContextPropertyGetterLookup(int nameIndex, JSUnitGenerator::LookupMode mode)
bool exprAccept(Format f)
void clearExprResultName()
QV4::Compiler::JSUnitGenerator * jsUnitGenerator
BytecodeGenerator::Label returnLabel()
int registerGetterLookup(int nameIndex, JSUnitGenerator::LookupMode mode)
void setExprResult(Reference &&result)
QSet< QQmlJS::AST::Node * > m_seenOptionalChainNodes
void pushExpr(const QString &name=QString())
int registerSetterLookup(int nameIndex)
void setExprResult(const Reference &result)
int registerGlobalGetterLookup(int nameIndex, JSUnitGenerator::LookupMode mode)
ErrorType errorType() const
QHash< QQmlJS::AST::Node *, Moth::BytecodeGenerator::Label > m_optionalChainLabels
std::vector< Result > m_expressions
void setGlobalNames(const QSet< QString > &globalNames)
QQmlJS::DiagnosticMessage _error
void pushExpr(Result &&expr)
const Result & currentExpr() const
Reference expression(QQmlJS::AST::ExpressionNode *ast, const QString &name=QString())
BytecodeGenerator * generator() const
void pushExpr(const Result &expr)
void throwRecursionDepthError() override
Reference exprResult() const
std::list< QString >::iterator Name
Combined button and popup list for selecting options.
CodegenWarningInterface * defaultCodegenWarningInterface()
\qmltype Particle \inqmlmodule QtQuick.Particles
#define Q_REQUIRED_RESULT
DBusConnection const char DBusError * error
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
#define QStringLiteral(str)
#define Q_QML_COMPILER_PRIVATE_EXPORT
static const QV4::Value & constant(Function *function, int index)
QRandomGenerator generator(sseq)
QUrl url("example.com")
[constructor-url-reference]
bool contains(const AT &t) const noexcept
static Reference fromScopedLocal(Codegen *cg, int index, int scope)
Reference(Reference &&)=default
static Reference fromImport(Codegen *cg, int index)
static Reference fromMember(const Reference &baseRef, const QString &name, QQmlJS::SourceLocation sourceLocation=QQmlJS::SourceLocation(), Moth::BytecodeGenerator::Label jumpLabel=Moth::BytecodeGenerator::Label(), Moth::BytecodeGenerator::Label targetLabel=Moth::BytecodeGenerator::Label())
quint32 isReferenceToConst
Moth::StackSlot stackSlot() const
bool loadTriggersSideEffect() const
bool isAccumulator() const
static void storeConstOnStack(Codegen *cg, QV4::ReturnedValue constant, int stackSlot)
static Reference fromConst(Codegen *cg, QV4::ReturnedValue constant)
Reference(const Reference &)=default
static Reference fromName(Codegen *cg, const QString &name)
bool isSuperProperty() const
static Reference fromAccumulator(Codegen *cg)
Reference(Codegen *cg, Type t=Invalid)
static Reference fromSuperProperty(const Reference &property)
static Reference fromStackSlot(Codegen *cg, int tempIndex=-1, bool isLocal=false)
Moth::StackSlot theStackSlot
QV4::ReturnedValue constant
Moth::StackSlot elementBase
static Reference fromSubscript(const Reference &baseRef, const Reference &subscript, Moth::BytecodeGenerator::Label targetLabel=Moth::BytecodeGenerator::Label())
quint32 stackSlotIsLocalOrArgument
quint32 subscriptLoadedForCall
static Q_REQUIRED_RESULT Reference storeConstOnStack(Codegen *cg, QV4::ReturnedValue constant)
Reference(const QString &name=QString())
quint32 subscriptRequiresTDZCheck
Q_REQUIRED_RESULT Reference storeOnStack() const
bool operator!=(const Reference &other) const
static Reference fromThis(Codegen *cg)
QSharedPointer< Moth::BytecodeGenerator::Label > optionalChainJumpLabel
quint32 throwsReferenceError
QSharedPointer< Moth::BytecodeGenerator::Label > optionalChainTargetLabel
static Reference fromSuper(Codegen *cg)
BytecodeGenerator * generator
RegisterScope(Codegen *cg)
int registerGlobalGetterLookup(int nameIndex, LookupMode mode)
int registerSetterLookup(const QString &name)
int registerQmlContextPropertyGetterLookup(int nameIndex, LookupMode mode)
int registerConstant(ReturnedValue v)
int registerGetterLookup(const QString &name, LookupMode mode)
int registerString(const QString &str)