diff options
Diffstat (limited to 'src/qml/jsruntime/qv4function.cpp')
| -rw-r--r-- | src/qml/jsruntime/qv4function.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/qml/jsruntime/qv4function.cpp b/src/qml/jsruntime/qv4function.cpp index b96fdb1fe5..ebe214ad72 100644 --- a/src/qml/jsruntime/qv4function.cpp +++ b/src/qml/jsruntime/qv4function.cpp @@ -147,19 +147,22 @@ int Function::lineNumberForProgramCounter(qptrdiff offset) const return helper.table[pos * 2 + 1]; } -qptrdiff Function::programCounterForLine(quint32 line) const +QList<qptrdiff> Function::programCountersForAllLines() const { - // Access the second field, the line number - LineNumberMappingHelper<1, quint32> helper; - helper.table = compiledFunction->lineNumberMapping(); - const int count = static_cast<int>(compiledFunction->nLineNumberMappingEntries); + // Only store 1 breakpoint per line... + QHash<quint32, qptrdiff> offsetsPerLine; + const quint32 *mapping = compiledFunction->lineNumberMapping(); + + // ... and make it the first instruction by walking backwards over the line mapping table + // and inserting all entries keyed on line. + for (quint32 i = compiledFunction->nLineNumberMappingEntries; i > 0; ) { + --i; // the loop is written this way, because starting at endIndex-1 and checking for i>=0 will never end: i>=0 is always true for unsigned. + quint32 offset = mapping[i * 2]; + quint32 line = mapping[i * 2 + 1]; + offsetsPerLine.insert(line, offset); + } - int pos = helper.upperBound(0, count, line); - if (pos != 0 && count > 0) - --pos; - if (pos == count) - return -1; - return helper.table[pos * 2]; + return offsetsPerLine.values(); } QT_END_NAMESPACE |
