anchor.diff:  // for details. All rights reserved. Use of this source code is governed by a
   // BSD-style license that can be found in the LICENSE file.
   
  -/**
  - * This part contains helpers for supporting runtime type information.
  - *
  - * The helper use a mixture of Dart and JavaScript objects. To indicate which is
  - * used where we adopt the scheme of using explicit type annotation for Dart
  - * objects and 'var' or omitted return type for JavaScript objects.
  - *
  - * Since bool, int, and String values are represented by the same JavaScript
  - * primitives, type annotations are used for these types in all cases.
  - *
  - * Several methods use a common JavaScript encoding of runtime type information.
  - * This encoding is referred to as the type representation which is one of
  - * these:
  - *  1) a JavaScript constructor for a class C: the represented type is the raw
  - *     type C.
  - *  2) a Dart object: this is the interceptor instance for a native type.
  - *  3) a JavaScript object: this represents a class for which there is no
  - *     JavaScript constructor, because it is only used in type arguments or it
  - *     is native. The represented type is the raw type of this class.
  - *  4) a JavaScript array: the first entry is of type 1, 2 or 3 and contains the
  - *     subtyping flags and the substitution of the type and the rest of the
  - *     array are the type arguments.
  - *  5) `null`: the dynamic type.
  - *
  - *
  - * To check subtype relations between generic classes we use a JavaScript
  - * expression that describes the necessary substitution for type arguments.
  - * Such a substitution expresssion can be:
  - *  1) `null`, if no substituted check is necessary, because the
  - *     type variables are the same or there are no type variables in the class
  - *     that is checked for.
  - *  2) A list expression describing the type arguments to be used in the
  - *     subtype check, if the type arguments to be used in the check do not
  - *     depend on the type arguments of the object.
  - *  3) A function mapping the type variables of the object to be checked to
  - *     a list expression.
  - */
  -
   part of _js_helper;
   
  -Type createRuntimeType(String name) => new TypeImpl(name);
  +setRuntimeTypeInfo(target, typeInfo) {
  +  assert(typeInfo == null || typeInfo is JSArray);
  +  // We have to check for null because factories may return null.
  +  if (target != null) JS('var', r'#.$builtinTypeInfo = #', target, typeInfo);
  +}
  +
  +getRuntimeTypeInfo(target) {
  +  if (target == null) return null;
  +  return JS('var', r'#.$builtinTypeInfo', target);
  +}
  +
  +getRuntimeTypeArgument(target, substitution, index) {
  +  var arguments = substitute(substitution, getRuntimeTypeInfo(target));
  +  return (arguments == null) ? null : getField(arguments, index);
  +}
   
   class TypeImpl implements Type {
     final String _typeName;
   
     TypeImpl(this._typeName);
   
  -  String toString() => _typeName;
  +  toString() => _typeName;
   
     // TODO(ahe): This is a poor hashCode as it collides with its name.
     int get hashCode => _typeName.hashCode;
  
positive.code:   }
  }
  
  /**
   * Creates a comma-separated string of human-readable representations of the
   * type representations in the JavaScript array [types] starting at index
   * [startIndex].
   */
  String joinArguments(var types, int startIndex) {
    if (isNull(types)) return '';
    assert(isJsArray(types));
    bool firstArgument = true;
    bool allDynamic = true;
    StringBuffer buffer = new StringBuffer();
    for (int index = startIndex; index < getLength(types); index++) {
      if (firstArgument) {
        firstArgument = false;
      } else {
        buffer.write(', ');
      }
      var argument = getIndex(types, index);
      if (argument != null) {
        allDynamic = false;
      }
  
negative.code:   // the subtype flags and the substitution on the prototype, so they are
    // properties of the object in JS.
    var type;
    if (JS('bool', '# != null', rti)) {
      // If the type has type variables (that is, [:rti != null:]), make a copy of
      // the type arguments and insert [o] in the first position to create a
      // compound type representation.
  