diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-06-13 23:37:40 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-06-20 09:47:20 +0000 |
commit | f129f9469e074defe470b10e1b357e98786e8d22 (patch) | |
tree | 1ead061e78ad1b81dc58723f9465faf6c70232c4 /src/qml/compiler/qv4bytecodegenerator.cpp | |
parent | 196f8365b386de6c0761b864481ab2beed6b8d2d (diff) |
Allow defining Labels as destinations for Jumps
Those Labels can be linked to a code location further ahead.
Change-Id: I82f1a719654162db0e0abb46df602ee2e01154da
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4bytecodegenerator.cpp')
-rw-r--r-- | src/qml/compiler/qv4bytecodegenerator.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/qml/compiler/qv4bytecodegenerator.cpp b/src/qml/compiler/qv4bytecodegenerator.cpp index 444d8385d4..6ccdeef777 100644 --- a/src/qml/compiler/qv4bytecodegenerator.cpp +++ b/src/qml/compiler/qv4bytecodegenerator.cpp @@ -72,13 +72,15 @@ QByteArray BytecodeGenerator::finalize() // resolve jumps // qDebug() << "resolving jumps"; for (const auto &j : jumps) { - Q_ASSERT(j.linkedInstruction != -1); + Q_ASSERT(j.linkedLabel != -1); + int linkedInstruction = labels.at(j.linkedLabel); + Q_ASSERT(linkedInstruction != -1); int offset = instructionOffsets.at(j.instructionIndex) + j.offset; // qDebug() << "offset data is at" << offset; char *c = code.data() + offset; - ptrdiff_t linkedInstruction = instructionOffsets.at(j.linkedInstruction) - offset; -// qDebug() << "linked instruction" << j.linkedInstruction << "at " << instructionOffsets.at(j.linkedInstruction); - memcpy(c, &linkedInstruction, sizeof(ptrdiff_t)); + ptrdiff_t linkedInstructionOffset = instructionOffsets.at(linkedInstruction) - offset; +// qDebug() << "linked instruction" << linkedInstruction << "at " << instructionOffsets.at(linkedInstruction); + memcpy(c, &linkedInstructionOffset, sizeof(ptrdiff_t)); } return code; |