Commit 54517584 authored by Ted Campbell's avatar Ted Campbell
Browse files

Bug 1672172 - Show column numbers in jsshell src-note disassembly. r=arai

parent 5c59c362
Loading
Loading
Loading
Loading
+13 −9
Original line number Diff line number Diff line
@@ -3089,15 +3089,15 @@ static bool PCToLine(JSContext* cx, unsigned argc, Value* vp) {
static MOZ_MUST_USE bool SrcNotes(JSContext* cx, HandleScript script,
                                  Sprinter* sp) {
  if (!sp->put("\nSource notes:\n") ||
      !sp->jsprintf("%4s %4s %5s %6s %-8s %s\n", "ofs", "line", "pc", "delta",
                    "desc", "args") ||
      !sp->put("---- ---- ----- ------ -------- ------\n")) {
      !sp->jsprintf("%4s %4s %6s %5s %6s %-10s %s\n", "ofs", "line", "column",
                    "pc", "delta", "desc", "args") ||
      !sp->put("---- ---- ------ ----- ------ ---------- ------\n")) {
    return false;
  }

  unsigned offset = 0;
  unsigned colspan = 0;
  unsigned lineno = script->lineno();
  unsigned column = script->column();
  SrcNote* notes = script->notes();
  for (SrcNoteIterator iter(notes); !iter.atEnd(); ++iter) {
    auto sn = *iter;
@@ -3106,8 +3106,8 @@ static MOZ_MUST_USE bool SrcNotes(JSContext* cx, HandleScript script,
    offset += delta;
    SrcNoteType type = sn->type();
    const char* name = sn->name();
    if (!sp->jsprintf("%3u: %4u %5u [%4u] %-8s", unsigned(sn - notes), lineno,
                      offset, delta, name)) {
    if (!sp->jsprintf("%3u: %4u %6u %5u [%4u] %-10s", unsigned(sn - notes),
                      lineno, column, offset, delta, name)) {
      return false;
    }

@@ -3119,22 +3119,26 @@ static MOZ_MUST_USE bool SrcNotes(JSContext* cx, HandleScript script,
      case SrcNoteType::XDelta:
        break;

      case SrcNoteType::ColSpan:
        colspan = SrcNote::ColSpan::getSpan(sn);
        if (!sp->jsprintf("%u", colspan)) {
      case SrcNoteType::ColSpan: {
        uint32_t colspan = SrcNote::ColSpan::getSpan(sn);
        if (!sp->jsprintf(" colspan %u", colspan)) {
          return false;
        }
        column += colspan;
        break;
      }

      case SrcNoteType::SetLine:
        lineno = SrcNote::SetLine::getLine(sn, script->lineno());
        if (!sp->jsprintf(" lineno %u", lineno)) {
          return false;
        }
        column = 0;
        break;

      case SrcNoteType::NewLine:
        ++lineno;
        column = 0;
        break;

      default: