Commit 56db2c36 authored by Tooru Fujisawa's avatar Tooru Fujisawa
Browse files

Bug 1477621 - Part 4: Add source note field constants for line. r=jandem

parent 4409e98b
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -90,6 +90,15 @@ class SrcNote {
            Count
        };
    };
    // SRC_SETLINE: Source note for arbitrary ops.
    class SetLine {
      public:
        enum Fields {
            // The file-absolute source line number of the current op.
            Line,
            Count
        };
    };
};

#define FOR_EACH_SRC_NOTE_TYPE(M)                                                                  \
@@ -118,7 +127,7 @@ class SrcNote {
    /* All notes above here are "gettable".  See SN_IS_GETTABLE below. */                          \
    M(SRC_COLSPAN,      "colspan",     SrcNote::ColSpan::Count) \
    M(SRC_NEWLINE,      "newline",     0)  /* Bytecode follows a source newline. */                \
    M(SRC_SETLINE,      "setline",     1)  /* A file-absolute source line number note. */          \
    M(SRC_SETLINE,      "setline",     SrcNote::SetLine::Count) \
    M(SRC_UNUSED21,     "unused21",    0)  /* Unused. */                                           \
    M(SRC_UNUSED22,     "unused22",    0)  /* Unused. */                                           \
    M(SRC_UNUSED23,     "unused23",    0)  /* Unused. */                                           \
+1 −1
Original line number Diff line number Diff line
@@ -2731,7 +2731,7 @@ SrcNotes(JSContext* cx, HandleScript script, Sprinter* sp)
            break;

          case SRC_SETLINE:
            lineno = GetSrcNoteOffset(sn, 0);
            lineno = GetSrcNoteOffset(sn, SrcNote::SetLine::Line);
            if (!sp->jsprintf(" lineno %u", lineno))
                return false;
            break;
+1 −1
Original line number Diff line number Diff line
@@ -184,7 +184,7 @@ class BytecodeRangeWithPosition : private BytecodeRange
                column += colspan;
                lastLinePC = snpc;
            } else if (type == SRC_SETLINE) {
                lineno = size_t(GetSrcNoteOffset(sn, 0));
                lineno = size_t(GetSrcNoteOffset(sn, SrcNote::SetLine::Line));
                column = 0;
                lastLinePC = snpc;
            } else if (type == SRC_NEWLINE) {
+1 −1
Original line number Diff line number Diff line
@@ -196,7 +196,7 @@ LCovSource::writeScript(JSScript* script)
            while (!SN_IS_TERMINATOR(sn) && snpc <= pc) {
                SrcNoteType type = SN_TYPE(sn);
                if (type == SRC_SETLINE)
                    lineno = size_t(GetSrcNoteOffset(sn, 0));
                    lineno = size_t(GetSrcNoteOffset(sn, SrcNote::SetLine::Line));
                else if (type == SRC_NEWLINE)
                    lineno++;
                else if (type == SRC_TABLESWITCH)
+3 −3
Original line number Diff line number Diff line
@@ -3271,7 +3271,7 @@ js::PCToLineNumber(unsigned startLine, jssrcnote* notes, jsbytecode* code, jsbyt

        SrcNoteType type = SN_TYPE(sn);
        if (type == SRC_SETLINE) {
            lineno = unsigned(GetSrcNoteOffset(sn, 0));
            lineno = unsigned(GetSrcNoteOffset(sn, SrcNote::SetLine::Line));
            column = 0;
        } else if (type == SRC_NEWLINE) {
            lineno++;
@@ -3323,7 +3323,7 @@ js::LineNumberToPC(JSScript* script, unsigned target)
        offset += SN_DELTA(sn);
        SrcNoteType type = SN_TYPE(sn);
        if (type == SRC_SETLINE) {
            lineno = unsigned(GetSrcNoteOffset(sn, 0));
            lineno = unsigned(GetSrcNoteOffset(sn, SrcNote::SetLine::Line));
        } else if (type == SRC_NEWLINE) {
            lineno++;
        }
@@ -3342,7 +3342,7 @@ js::GetScriptLineExtent(JSScript* script)
    for (jssrcnote* sn = script->notes(); !SN_IS_TERMINATOR(sn); sn = SN_NEXT(sn)) {
        SrcNoteType type = SN_TYPE(sn);
        if (type == SRC_SETLINE)
            lineno = unsigned(GetSrcNoteOffset(sn, 0));
            lineno = unsigned(GetSrcNoteOffset(sn, SrcNote::SetLine::Line));
        else if (type == SRC_NEWLINE)
            lineno++;