public static void encodeVLQ(StringBuffer output, int value) 
 {
    int signBit = 0;
    if (value < 0) {
       signBit = 1;
       value = -value;
    }
    value = (value << 1) | signBit;
    do {
       int digit = value & VLQ_BASE_MASK;
       value >>= VLQ_BASE_SHIFT;
       if (value > 0) {
          digit |= VLQ_CONTINUATION_BIT;
       }
       output.write(BASE64_DIGITS[digit]);
    } while (value > 0);
 }
 public String build() 
 {
    resetPreviousSourceLocation();
    StringBuffer mappingsBuffer = new StringBuffer();
    entries.ForEach((SourceMapEntry entry) => writeEntry(entry, targetFile, mappingsBuffer));
    StringBuffer buffer = new StringBuffer();
    buffer.write("{\n");
    buffer.write("  \u0022version\u0022: 3,\n");
    if (uri != null && fileUri != null) {
       buffer.write(string.Format("  \u0022file\u0022: \u0022{0}\u0022,\n",Uri.relativize(uri, fileUri, false)));
    }
    buffer.write("  \u0022sourceRoot\u0022: \u0022\u0022,\n");
    buffer.write("  \u0022sources\u0022: ");
    if(uri != null) 
    {
       //sourceUrlList = sourceUrlList.map((url) => relativize(uri, Uri.parse(url), false)).toList();
       for(int t=0;t<sourceUrlList.length;t++) sourceUrlList[t] = Uri.relativize(uri, Uri.parse(sourceUrlList[t]), false);
    }
    printStringListOn(sourceUrlList, buffer);
    buffer.write(",\n");
    buffer.write("  \u0022names\u0022: ");
    printStringListOn(sourceNameList, buffer);
    buffer.write(",\n");
    buffer.write("  \u0022mappings\u0022: \u0022");
    buffer.write(mappingsBuffer);
    buffer.write("\u0022\n}\n");
    return buffer.toString();
 }
      public void writeEntry(SourceMapEntry entry, SourceFile targetFile, StringBuffer output) 
      {
         int targetLine = targetFile.getLine(entry.targetOffset);
         int targetColumn = targetFile.getColumn(targetLine, entry.targetOffset);

         if (targetLine > previousTargetLine) {
            for (int i = previousTargetLine; i < targetLine; ++i) {
               output.write(";");
            }
            previousTargetLine = targetLine;
            previousTargetColumn = 0;
            firstEntryInLine = true;
         }

         if (!firstEntryInLine) {
            output.write(",");
         }
         firstEntryInLine = false;

         encodeVLQ(output, targetColumn - previousTargetColumn);
         previousTargetColumn = targetColumn;

         if (entry.sourceLocation == null) return;

         String sourceUrl = entry.sourceLocation.getSourceUrl();
         int sourceLine = entry.sourceLocation.getLine();
         int sourceColumn = entry.sourceLocation.getColumn();
         String sourceName = entry.sourceLocation.getSourceName();

         int sourceUrlIndex = indexOf(sourceUrlList, sourceUrl, sourceUrlMap);
         encodeVLQ(output, sourceUrlIndex - previousSourceUrlIndex);
         encodeVLQ(output, sourceLine - previousSourceLine);
         encodeVLQ(output, sourceColumn - previousSourceColumn);

         if (sourceName != null) {
            int sourceNameIndex = indexOf(sourceNameList, sourceName, sourceNameMap);
            encodeVLQ(output, sourceNameIndex - previousSourceNameIndex);
         }

         // Update previous source location to ensure the next indices are relative
         // to those if [entry.sourceLocation].
         updatePreviousSourceLocation(entry.sourceLocation);
      }
 private void printStringListOn(List<String> strings, StringBuffer buffer)
 {
    bool first = true;
    buffer.write("[");
    foreach(String str in strings) 
    {
       if (!first) buffer.write(",");
       buffer.write("\u0022");
       writeJsonEscapedCharsOn.call(str, buffer);
       buffer.write("\u0022");
       first = false;
    }
    buffer.write("]");
 }
 public void write(StringBuffer s)
 {
    _sb.Append(s.toString());
 }
 public void write(StringBuffer s)
 {
     _sb.Append(s.toString());
 }
 public static void call(string s, StringBuffer sb)
 {
    sb.write(s);
 }
 public static void call(string s, StringBuffer sb)
 {
     sb.write(s);
 }