code: public int writeCRT(ByteBuffer databuf, Position.LineMap lineMap, Log log) {
  
          int crtEntries = 0;
  
          // compute source positions for the method
          new SourceComputer().csp(methodTree);
  
          for (List<CRTEntry> l = entries.toList(); l.nonEmpty(); l = l.tail) {
  
              CRTEntry entry = l.head;
  
              // eliminate entries that do not produce bytecodes:
              // for example, empty blocks and statements
              if (entry.startPc == entry.endPc)
                  continue;
  
              SourceRange pos = positions.get(entry.tree);
              Assert.checkNonNull(pos, "CRT: tree source positions are undefined");
              if ((pos.startPos == Position.NOPOS) || (pos.endPos == Position.NOPOS))
                  continue;
  
              if (crtDebug) {
                  System.out.println("Tree: " + entry.tree + ", type:" + getTypes(entry.flags));
                  System.out.print("Start: pos = " + pos.startPos + ", pc = " + entry.startPc);
              }
  
              // encode startPos into line/column representation
              int startPos = encodePosition(pos.startPos, lineMap, log);
              if (startPos == Position.NOPOS)
                  continue;
  
              if (crtDebug) {
                  System.out.print("End:   pos = " + pos.endPos + ", pc = " + (entry.endPc - 1));
              }
  
              // encode endPos into line/column representation
              int endPos = encodePosition(pos.endPos, lineMap, log);
              if (endPos == Position.NOPOS)
                  continue;
  
              // write attribute
              databuf.appendChar(entry.startPc);
              // 'endPc - 1' because endPc actually points to start of the next command
              databuf.appendChar(entry.endPc - 1);
              databuf.appendInt(startPos);
              databuf.appendInt(endPos);
              databuf.appendChar(entry.flags);
  
              crtEntries++;
          }
  
          return crtEntries;
      }
docs: Compute source positions and write CRT to the databuf.
  @param databuf  The buffer to write bytecodes to.