5#ifndef QV4BYTECODEGENERATOR_P_H
6#define QV4BYTECODEGENERATOR_P_H
18#include <private/qv4instr_moth_p.h>
19#include <private/qv4compileddata_p.h>
20#include <private/qv4compilercontext_p.h>
21#include <private/qqmljssourcelocation_p.h>
42 : startLine(line), debugMode(debug)
44 if (storeSourceLocation)
45 m_sourceLocationTable.reset(
new QV4::Compiler::Context::SourceLocationTable {});
56 index(generator->labels.size()) {
57 generator->labels.append(-1);
78 { Q_ASSERT(generator &&
index != -1); }
141 InstrMeta<InstrT>::setData(genericInstr, data);
142 addInstructionHelper(Moth::Instr::Type(InstrT), genericInstr);
240 return currentExceptionHandler;
254 InstrMeta<InstrT>::setData(genericInstr, data);
255 return Jump(
this, addInstructionHelper(Moth::Instr::Type(InstrT), genericInstr, offsetof(InstrData<InstrT>, offset)));
261 addJumpInstruction(Instruction::JumpFalse()).link(*falseLabel);
263 addJumpInstruction(Instruction::JumpTrue()).link(*trueLabel);
273 _labelInfos.push_back({ start.index });
281 int addInstructionHelper(Moth::Instr::Type type,
const Instr &i,
int offsetOfOffset = -1);
284 Moth::Instr::Type type;
291 unsigned char packed[
sizeof(Instr) + 2];
294 void compressInstructions();
295 void packInstruction(I &i);
296 void adjustJumpOffsets();
298 QList<I> instructions;
307 int currentStatement = 0;
309 std::unique_ptr<QV4::Compiler::Context::SourceLocationTable> m_sourceLocationTable;
310 bool debugMode =
false;
312 int lastInstrType = -1;
313 Moth::Instr lastInstr;
318 std::vector<LabelInfo> _labelInfos;
void insert(quint32 key, quint32 value)
void clearLastInstruction()
Jump addJumpInstruction(const InstrData< InstrT > &data)
BytecodeGenerator(int line, bool debug, bool storeSourceLocation=false)
int currentRegister() const
ExceptionHandler newExceptionHandler()
ExceptionHandler * exceptionHandler() const
void addInstruction(const InstrData< InstrT > &data)
void incrementStatement()
void addLoopStart(const Label &start)
void addCJumpInstruction(bool jumpOnFalse, const Label *trueLabel, const Label *falseLabel)
void finalize(Compiler::Context *context)
int newRegisterArray(int n)
int registerCount() const
Combined button and popup list for selecting options.
QList< Method > staticMethods
KeyValuePair(quint32 key, quint32 value)
bool isLexicallyScoped() const
QQmlJS::AST::FunctionExpression * function
bool requiresTDZCheck(const QQmlJS::SourceLocation &accessLocation, bool accessAcrossContextBoundaries) const
QQmlJS::SourceLocation declarationLocation
QQmlJS::AST::VariableScope scope
QQmlJS::SourceLocation declarationLocation
Context::MemberType memberType
QQmlJS::SourceLocation location
QList< Context * > nestedContexts
bool memberInfo(const QString &name, const Member **m) const
void emitBlockFooter(Compiler::Codegen *codegen)
QQmlJS::AST::FormalParameterList * formals
bool innerFunctionAccessesThis
bool hasArgument(const QString &name) const
void emitBlockHeader(Compiler::Codegen *codegen)
QQmlJS::AST::BoundNames arguments
QSet< QString > usedVariables
bool canHaveTailCalls() const
bool innerFunctionAccessesNewTarget
int firstTemporalDeadZoneRegister
std::unique_ptr< SourceLocationTable > sourceLocationTable
UsesArgumentsObject usesArgumentsObject
QList< CompiledData::CodeOffsetToLineAndStatement > lineAndStatementNumberMapping
QList< ImportEntry > importEntries
bool requiresExecutionContext
QMap< QString, Member > MemberMap
QQmlJS::AST::Type * returnType
Context(Context *parent, ContextType type)
int sizeOfRegisterTemporalDeadZone
ResolvedName resolveName(const QString &name, const QQmlJS::SourceLocation &accessLocation)
QString localNameForDefaultExport
bool requiresImplicitReturnValue() const
void setupFunctionIndices(Moth::BytecodeGenerator *bytecodeGenerator)
int registerCountInFunction
QQmlJS::SourceLocation lastBlockInitializerLocation
void addUsedVariable(const QString &name)
ControlFlow * controlFlow
QList< ExportEntry > exportEntries
int sizeOfLocalTemporalDeadZone
std::vector< unsigned > labelInfo
Member findMember(const QString &name) const
QStringList moduleRequests
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)
int findArgument(const QString &name, bool *isInjected) const
CompiledData::Location location
static bool lessThan(const ExportEntry &lhs, const ExportEntry &rhs)
CompiledData::Location location
Context * newContext(QQmlJS::AST::Node *node, Context *parent, ContextType compilationMode)
QHash< QQmlJS::AST::Node *, Context * > contextMap
QList< ExportEntry > indirectExportEntries
QList< Context * > functions
QDateTime sourceTimeStamp
Module(const QString &fileName, const QString &finalUrl, bool debugMode)
QStringList moduleRequests
QList< ExportEntry > starExportEntries
QList< TemplateObject > templateObjects
QList< ImportEntry > importEntries
QList< ExportEntry > localExportEntries
QList< Context * > blocks
bool operator==(const TemplateObject &other)
ExceptionHandler(BytecodeGenerator *generator)
ExceptionHandler & operator=(ExceptionHandler &&)=default
ExceptionHandler & operator=(const ExceptionHandler &)=default
ExceptionHandler()=default
ExceptionHandler(ExceptionHandler &&)=default
ExceptionHandler(const ExceptionHandler &)=default
BytecodeGenerator * generator
Jump(BytecodeGenerator *generator, int instruction)
Label(BytecodeGenerator *generator, LinkMode mode=LinkNow)
BytecodeGenerator * generator