<commit_before>// Copyright (c) 2015, the Dart project authors.  Please see the AUTHORS file
// 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.

var dart, _js_helper, _js_primitives;
(function (dart) {
  'use strict';

  let defineProperty = Object.defineProperty;
  let getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  let getOwnPropertyNames = Object.getOwnPropertyNames;
  let getOwnPropertySymbols = Object.getOwnPropertySymbols;

  function getOwnNamesAndSymbols(obj) {
    return getOwnPropertyNames(obj).concat(getOwnPropertySymbols(obj));
  }

  // Adapted from Angular.js
  let FN_ARGS = /^function\s*[^\(]*\(\s*([^\)]*)\)/m;
  let FN_ARG_SPLIT = /,/;
  let FN_ARG = /^\s*(_?)(\S+?)\1\s*$/;
  let STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;

  function formalParameterList(fn) {
    let fnText,argDecl;
    let args=[];
    fnText = fn.toString().replace(STRIP_COMMENTS, '');
    argDecl = fnText.match(FN_ARGS);

    let r = argDecl[1].split(FN_ARG_SPLIT);
    for (let arg of r) {
      arg.replace(FN_ARG, function(all, underscore, name){
        args.push(name);
      });
    }
    return args;
  }

  function dload(obj, field) {
    if (!(field in obj)) {
      throw new core.NoSuchMethodError(obj, field);
    }
    var result = obj[field];
    if (typeof result == "function") {
      // We can't tell if the result needs binding. Fortunately binding the
      // same function twice has no effect, so we can simply attempt to bind.
      return result.bind(obj);
    }
    return result;
  }
  dart.dload = dload;

  // TODO(jmesserly): this should call noSuchMethod, not throw.
  function throwNoSuchMethod(obj, name, args, opt_func) {
    if (obj === void 0) obj = opt_func;
    throw new core.NoSuchMethodError(obj, name, args);
  }

  function checkAndCall(f, obj, args, name) {
    if (!(f instanceof Function)) {
      // Grab the `call` method if it's not a function.
      if (f !== null) f = f.call;
      if (!(f instanceof Function)) {
        throwNoSuchMethod(obj, method, args);
      }
    }
    // TODO(jmesserly): enable this when we can fix => and methods.
    /*
    let formals = formalParameterList(f);
    // TODO(vsm): Type check args!  We need to encode sufficient type info on f.
    if (formals.length < args.length) {
      throwNoSuchMethod(obj, name, args, f);
    } else if (formals.length > args.length) {
      for (let i = args.length; i < formals.length; ++i) {
        if (formals[i].indexOf("opt$") != 0) {
          throwNoSuchMethod(obj, name, args, f);
        }
      }
    }
    */
    return f.apply(obj, args);
  }

  function dcall(f/*, ...args*/) {
    let args = Array.prototype.slice.call(arguments, 1);
    return checkAndCall(f, void 0, args, 'call');
  }
  dart.dcall = dcall;

  function dsend(obj, method/*, ...args*/) {
    let args = Array.prototype.slice.call(arguments, 2);
    return checkAndCall(obj[method], obj, args, method);
  }
  dart.dsend = dsend;

  function dindex(obj, index) {
    // TODO(jmesserly): remove this special case once Array extensions are
    // hooked up.
    if (obj instanceof Array && realRuntimeType(index) == core.int) {
      return obj[index];
    }
    return checkAndCall(obj.get, obj, [index], '[]');
  }
  dart.dindex = dindex;

  function dsetindex(obj, index, value) {
    return checkAndCall(obj.set, obj, [index, value], '[]=');
  }
  dart.dsetindex = dsetindex;

  /**
   * Returns bound `method`.
   * This helper function avoids needing a temp for `obj`.
   */
  function bind(obj, method) {
    // This is a static bind (dynamic would use `dload`) so no need to check
    // if `method` is really there on `obj`.`
    return obj[method].bind(obj);
  }
  dart.bind = bind;

  function cast(obj, type) {
    // TODO(vsm): handle non-nullable types
    if (obj == null) return obj;
    let actual = realRuntimeType(obj);
    if (isSubtype(actual, type)) return obj;
    throw new _js_helper.CastErrorImplementation(actual, type);
  }
  dart.as = cast;


  // TODO(vsm): How should we encode the runtime type?
  let _runtimeType = Symbol('_runtimeType');

  function checkPrimitiveType(obj) {
    switch (typeof obj) {
      case "undefined":
        return core.Null;
      case "number":
        return Math.floor(obj) == obj ? core.int : core.double;
      case "boolean":
        return core.bool;
      case "string":
        return core.String;
      case "symbol":
        return Symbol;
    }
    // Undefined is handled above. For historical reasons,
    // typeof null == "object" in JS.
    if (obj === null) return core.Null;
    return null;
  }

  /**
   * Returns the runtime type of obj. This is the same as `obj.realRuntimeType`
   * but will not call an overridden getter.
   *
   * Currently this will return null for non-Dart objects.
   */
  function realRuntimeType(obj) {
    var result = checkPrimitiveType(obj);
    if (result !== null) return result;
    // TODO(vsm): Should we treat Dart and JS objects differently here?
    // E.g., we can check if obj instanceof core.Object to differentiate.
    result = obj[_runtimeType];
    if (result) return result;
    result = obj.constructor;
    if (result == Function) {
      return getFunctionType(obj);
    }
    return result;
  }
  dart.realRuntimeType = realRuntimeType;

  function instanceOf(obj, type) {
    return isSubtype(realRuntimeType(obj), type);
  }
  dart.is = instanceOf;

  /**
   * Computes the canonical type.
   * This maps JS types onto their corresponding Dart Type.
   */
  // TODO(jmesserly): lots more needs to be done here.
  function canonicalType(t) {
    if (t === Object) return core.Object;
    if (t === Function) return core.Function;
    if (t === Array) return core.List;

    // We shouldn't normally get here with these types, unless something strange
    // happens like subclassing Number in JS and passing it to Dart.
    if (t === String) return core.String;
    if (t === Number) return core.double;
    if (t === Boolean) return core.bool;
    return t;
  }

  let subtypeMap = new Map();
  function isSubtype(t1, t2) {
    // See if we already know the answer
    // TODO(jmesserly): general purpose memoize function?
    let map = subtypeMap.get(t1);
    let result;
    if (map) {
      result = map.get(t2);
      if (result !== void 0) return result;
    } else {
      subtypeMap.set(t1, map = new Map());
    }
    map.set(t2, result = isSubtype_(t1, t2));
    return result;
  }
  dart.isSubtype = isSubtype;

  function _isBottom(type, dynamicIsBottom) {
    return (type == dart.dynamic && dynamicIsBottom) || type == dart.bottom;
  }

  function _isTop(type, dynamicIsBottom) {
    return type == core.Object || (type == dart.dynamic && !dynamicIsBottom);
  }

  function isSubtype_(t1, t2, opt_dynamicIsBottom) {
    let dynamicIsBottom =
      opt_dynamicIsBottom === void 0 ? false : opt_dynamicIsBottom;<commit_msg>Treat our type objects as core.Type and other minor fixes<commit_after>// Copyright (c) 2015, the Dart project authors.  Please see the AUTHORS file
// 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.

var dart, _js_helper, _js_primitives;
(function (dart) {
  'use strict';

  let defineProperty = Object.defineProperty;
  let getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  let getOwnPropertyNames = Object.getOwnPropertyNames;
  let getOwnPropertySymbols = Object.getOwnPropertySymbols;

  function getOwnNamesAndSymbols(obj) {
    return getOwnPropertyNames(obj).concat(getOwnPropertySymbols(obj));
  }

  // Adapted from Angular.js
  let FN_ARGS = /^function\s*[^\(]*\(\s*([^\)]*)\)/m;
  let FN_ARG_SPLIT = /,/;
  let FN_ARG = /^\s*(_?)(\S+?)\1\s*$/;
  let STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;

  function formalParameterList(fn) {
    let fnText,argDecl;
    let args=[];
    fnText = fn.toString().replace(STRIP_COMMENTS, '');
    argDecl = fnText.match(FN_ARGS);

    let r = argDecl[1].split(FN_ARG_SPLIT);
    for (let arg of r) {
      arg.replace(FN_ARG, function(all, underscore, name){
        args.push(name);
      });
    }
    return args;
  }

  function dload(obj, field) {
    if (!(field in obj)) {
      throw new core.NoSuchMethodError(obj, field);
    }
    var result = obj[field];
    if (typeof result == "function") {
      // We can't tell if the result needs binding. Fortunately binding the
      // same function twice has no effect, so we can simply attempt to bind.
      return result.bind(obj);
    }
    return result;
  }
  dart.dload = dload;

  // TODO(jmesserly): this should call noSuchMethod, not throw.
  function throwNoSuchMethod(obj, name, args, opt_func) {
    if (obj === void 0) obj = opt_func;
    throw new core.NoSuchMethodError(obj, name, args);
  }

  function checkAndCall(f, obj, args, name) {
    if (!(f instanceof Function)) {
      // Grab the `call` method if it's not a function.
      if (f !== null) f = f.call;
      if (!(f instanceof Function)) {
        throwNoSuchMethod(obj, name, args);
      }
    }
    // TODO(jmesserly): enable this when we can fix => and methods.
    /*
    let formals = formalParameterList(f);
    // TODO(vsm): Type check args!  We need to encode sufficient type info on f.
    if (formals.length < args.length) {
      throwNoSuchMethod(obj, name, args, f);
    } else if (formals.length > args.length) {
      for (let i = args.length; i < formals.length; ++i) {
        if (formals[i].indexOf("opt$") != 0) {
          throwNoSuchMethod(obj, name, args, f);
        }
      }
    }
    */
    return f.apply(obj, args);
  }

  function dcall(f/*, ...args*/) {
    let args = Array.prototype.slice.call(arguments, 1);
    return checkAndCall(f, void 0, args, 'call');
  }
  dart.dcall = dcall;

  function dsend(obj, method/*, ...args*/) {
    let args = Array.prototype.slice.call(arguments, 2);
    return checkAndCall(obj[method], obj, args, method);
  }
  dart.dsend = dsend;

  function dindex(obj, index) {
    // TODO(jmesserly): remove this special case once Array extensions are
    // hooked up.
    if (obj instanceof Array && realRuntimeType(index) == core.int) {
      return obj[index];
    }
    return checkAndCall(obj.get, obj, [index], '[]');
  }
  dart.dindex = dindex;

  function dsetindex(obj, index, value) {
    return checkAndCall(obj.set, obj, [index, value], '[]=');
  }
  dart.dsetindex = dsetindex;

  /**
   * Returns bound `method`.
   * This helper function avoids needing a temp for `obj`.
   */
  function bind(obj, method) {
    // This is a static bind (dynamic would use `dload`) so no need to check
    // if `method` is really there on `obj`.`
    return obj[method].bind(obj);
  }
  dart.bind = bind;

  function cast(obj, type) {
    // TODO(vsm): handle non-nullable types
    if (obj == null) return obj;
    let actual = realRuntimeType(obj);
    if (isSubtype(actual, type)) return obj;
    throw new _js_helper.CastErrorImplementation(actual, type);
  }
  dart.as = cast;


  // TODO(vsm): How should we encode the runtime type?
  let _runtimeType = Symbol('_runtimeType');

  function checkPrimitiveType(obj) {
    switch (typeof obj) {
      case "undefined":
        return core.Null;
      case "number":
        return Math.floor(obj) == obj ? core.int : core.double;
      case "boolean":
        return core.bool;
      case "string":
        return core.String;
      case "symbol":
        return Symbol;
    }
    // Undefined is handled above. For historical reasons,
    // typeof null == "object" in JS.
    if (obj === null) return core.Null;
    return null;
  }

  /**
   * Returns the runtime type of obj. This is the same as `obj.realRuntimeType`
   * but will not call an overridden getter.
   *
   * Currently this will return null for non-Dart objects.
   */
  function realRuntimeType(obj) {
    var result = checkPrimitiveType(obj);
    if (result !== null) return result;
    // TODO(vsm): Should we treat Dart and JS objects differently here?
    // E.g., we can check if obj instanceof core.Object to differentiate.
    result = obj[_runtimeType];
    if (result) return result;
    result = obj.constructor;
    if (result == Function) {
      return getFunctionType(obj);
    }
    return result;
  }
  dart.realRuntimeType = realRuntimeType;

  function instanceOf(obj, type) {
    return isSubtype(realRuntimeType(obj), type);
  }
  dart.is = instanceOf;

  /**
   * Computes the canonical type.
   * This maps JS types onto their corresponding Dart Type.
   */
  // TODO(jmesserly): lots more needs to be done here.
  function canonicalType(t) {
    if (t === Object) return core.Object;
    if (t === Function) return core.Function;
    if (t === Array) return core.List;

    // We shouldn't normally get here with these types, unless something strange
    // happens like subclassing Number in JS and passing it to Dart.
    if (t === String) return core.String;
    if (t === Number) return core.double;
    if (t === Boolean) return core.bool;
    return t;
  }

  let subtypeMap = new Map();
  function isSubtype(t1, t2) {
    // See if we already know the answer
    // TODO(jmesserly): general purpose memoize function?
    let map = subtypeMap.get(t1);
    let result;
    if (map) {
      result = map.get(t2);
      if (result !== void 0) return result;
    } else {
      subtypeMap.set(t1, map = new Map());
    }
    if (t2 == core.Type) {
      // Special case Types.
      result = t1.prototype instanceof core.Type ||
        t1 instanceof AbstractFunctionType ||
        isSubtype_(t1, t2);
    } else {
      result = isSubtype_(t1, t2)
    }
    map.set(t2, result);
    return result;
  }
  dart.isSubtype = isSubtype;

  function _isBottom(type, dynamicIsBottom) {
    return (type == dart.dynamic && dynamicIsBottom) || type == dart.bottom;
  }

  function _isTop(type, dynamicIsBottom) {
    return type == core.Object || (type == dart.dynamic && !dynamicIsBottom);
  }

  function isSubtype_(t1, t2, opt_dynamicIsBottom) {
    let dynamicIsBottom =
      opt_dynamicIsBottom === void 0 ? false : opt_dynamicIsBottom;
{'fraction_non_alphanumeric': 0.13073459048691247, 'fraction_numerical': 0.0035885167464114833, 'mean_word_length': 2.817620198764437, 'pattern_counts': {'":': 10, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3097016', 'n_tokens_mistral': 4619, 'n_tokens_neox': 4507, 'n_words': 1389}