void preprocessSrcrefs()

in src/debugger/SourceFileManager.cpp [188:231]


  void preprocessSrcrefs(SEXP x) {
    if ((TYPEOF(x) == LANGSXP && CAR(x) == RI->beginSymbol) || TYPEOF(x) == EXPRSXP) {
      bool isExpr = TYPEOF(x) == EXPRSXP;
      SEXP srcrefs = getBlockSrcrefs(x);
      if (srcrefs == R_NilValue || Rf_getAttrib(srcrefs, RI->srcProcessedFlag) != R_NilValue) return;
      Rf_setAttrib(srcrefs, RI->srcProcessedFlag, Rf_ScalarLogical(true));
      for (int i = isExpr ? 0 : 1; i < Rf_length(srcrefs); ++i) {
        if (!isExpr) {
          if (x == R_NilValue) break;
          x = CDR(x);
        }
        SEXP srcref = getSrcref(srcrefs, i);
        int currentFirst = -1;
        int currentLast = -1;
        if (srcref != R_NilValue) {
          currentFirst = INTEGER(srcref)[0];
          currentLast = INTEGER(srcref)[2];
          if (currentFirst == lastBreakpointLine) {
            Rf_setAttrib(srcref, RI->noBreakpointFlag, Rf_ScalarLogical(true));
          }
          lastBreakpointLine = std::max(lastBreakpointLine, currentFirst);
          if (currentFirst == lastPositionLine) {
            Rf_setAttrib(srcref, RI->sendExtendedPositionFlag, Rf_ScalarLogical(true));
            if (lastPositionSrcref != R_NilValue && currentFirst == INTEGER(lastPositionSrcref)[0]) {
              Rf_setAttrib(lastPositionSrcref, RI->sendExtendedPositionFlag, Rf_ScalarLogical(true));
            }
          }
          lastPositionLine = currentFirst;
        }
        preprocessSrcrefs(isExpr ? VECTOR_ELT(x, i) : CAR(x));
        if (srcref != R_NilValue) {
          lastPositionLine = currentLast;
          if (currentFirst == currentLast) lastPositionSrcref = srcref;
        }
      }
    } else if (TYPEOF(x) == LANGSXP) {
      if (CAR(x) == RI->functionSymbol) return;
      x = CDR(x);
      while (x != R_NilValue) {
        preprocessSrcrefs(CAR(x));
        x = CDR(x);
      }
    }
  }