anchor.diff:      // Nothing to do.
     }
   }
  +
  +class NotQuiteString {
  +  /**
  +   * Write [source] string into [target] starting at index [index].
  +   *
  +   * Optionally only write part of the input [source] starting at [start] and
  +   * ending at [end].
  +   *
  +   * The output space needed is at most [source.length] * 3.
  +   *
  +   * Returns
  +   *  * Non-negative on success (the new index in [target]).
  +   *  * -1 when [target] doesn't have enough space. Note that [target] can be
  +   *    poluted starting at [index].
  +   *  * -2 on input error, i.e. an unpaired lead or tail surrogate.
  +   */
  +  static int writeUtf8(List<int> target, int index, String source,
  +      [int start = 0, int end]) {
  +    RangeError.checkValidIndex(index, target, null, target.length);
  +    end = RangeError.checkValidRange(start, end, source.length);
  +    if (start == end) return index;
  +    var i = start;
  +    var length = target.length;
  +    do {
  +      int codeUnit = source.codeUnitAt(i++);
  +      while (codeUnit < 128) {
  +        if (index >= length) return -1;
  +        target[index++] = codeUnit;
  +        if (i >= end) return index;
  +        codeUnit = source.codeUnitAt(i++);
  +      }
  +      if (codeUnit < 0x800) {
  +        index += 2;
  +        if (index > length) return -1;
  +        target[index - 2] = 0xC0 | (codeUnit >> 6);
  +        target[index - 1] = 0x80 | (codeUnit & 0x3f);
  +      } else if (codeUnit & 0xF800 != 0xD800) {
  +        // Not a surrogate.
  +        index += 3;
  +        if (index > length) return -1;
  +        target[index - 3] = 0xE0 | (codeUnit >> 12);
  +        target[index - 2] = 0x80 | ((codeUnit >> 6) & 0x3f);
  +        target[index - 1] = 0x80 | (codeUnit & 0x3f);
  +      } else {
  +        if (codeUnit >= 0xDC00) return -2; // Unpaired tail surrogate.
  +        if (i >= end) return -2; // Unpaired lead surrogate.
  +        int nextChar = source.codeUnitAt(i++);
  +        if (nextChar & 0xFC00 != 0xDC00) return -2; // Unpaired lead surrogate.
  +        index += 4;
  +        if (index > length) return -1;
  +        codeUnit = (codeUnit & 0x3FF) + 0x40;
  +        target[index - 4] = 0xF0 | (codeUnit >> 8);
  +        target[index - 3] = 0x80 | ((codeUnit >> 2) & 0x3F);
  +        target[index - 2] =
  +            0x80 | (((codeUnit & 3) << 4) | ((nextChar & 0x3FF) >> 6));
  +        target[index - 1] = 0x80 | (nextChar & 0x3f);
  +      }
  +    } while (i < end);
  +    return index;
  +  }
  +}
  
positive.code: library kernel.ast_to_binary;
  
  import 'dart:core' hide MapEntry;
  
  import '../ast.dart';
  import 'tag.dart';
  import 'dart:convert';
  import 'dart:io' show BytesBuilder;
  import 'dart:typed_data';
  
  
negative.code: 
      // Write data.
      int i = 0;
      Uint8List buffer = new Uint8List(1 << 16);
      for (Uri uri in _sourceUriIndexer.index.keys) {
        index[i] = getBufferOffset();
        Source source = ((includeSources &&
  