<commit_before>/*
  Analyse ast, create scopes
*/

//
// Scope class
//

function Scope(type, parentScope, thisObject){
  this.type = type || 'unknown';
  this.thisObject = thisObject;
  this.subscopes = [];

  if (parentScope)
  {
    this.parent = parentScope;
    this.root = parentScope.root;
    parentScope.subscopes.push(this);
  }
  else
  {
    this.root = this;
  }

  if (parentScope)
  {
    var Names = Function();
    Names.prototype = parentScope.names;
    this.names = new Names();
  }
  else
    this.names = {};
}

Scope.prototype = {
  root: null,
  parent: null,
  subscopes: null,
  thisObject: null,
  names: null,

  getNames: function(){
    var result = {};

    for (var name in this.names)
      result[name] = this.names[name];

    return result;
  },
  scopeByName: function(name){
    if (name in this.names)
    {
      var cursor = this;
      while (cursor)
      {
        if (cursor.names.hasOwnProperty(name))
          return cursor;

        cursor = cursor.parent;
      }
    }
  },
  has: function(name){
    return !!this.scopeByName(name);
  },
  hasOwn: function(name){
    return this.names.hasOwnProperty(name);
  },
  get: function(name){
    if (this.has(name))
      return this.names[name];
  },
  token: function(name){
    var ref = this.get(name);
    return ref && ref.token;
  },
  put: function(name, type, token){<commit_msg>fix issue with hasOwnProperty override<commit_after>/*
  Analyse ast, create scopes
*/

var hasOwnProperty = Object.prototype.hasOwnProperty;

//
// Scope class
//

function Scope(type, parentScope, thisObject){
  this.type = type || 'unknown';
  this.thisObject = thisObject;
  this.subscopes = [];

  if (parentScope)
  {
    this.parent = parentScope;
    this.root = parentScope.root;
    parentScope.subscopes.push(this);
  }
  else
  {
    this.root = this;
  }

  if (parentScope)
  {
    var Names = Function();
    Names.prototype = parentScope.names;
    this.names = new Names();
  }
  else
    this.names = {};
}

Scope.prototype = {
  root: null,
  parent: null,
  subscopes: null,
  thisObject: null,
  names: null,

  getNames: function(){
    var result = {};

    for (var name in this.names)
      result[name] = this.names[name];

    return result;
  },
  scopeByName: function(name){
    if (name in this.names)
    {
      var cursor = this;
      while (cursor)
      {
        if (hasOwnProperty.call(cursor.names, name)) // hasOwnProperty may be overriden
          return cursor;

        cursor = cursor.parent;
      }
    }
  },
  has: function(name){
    return !!this.scopeByName(name);
  },
  hasOwn: function(name){
    return this.names.hasOwnProperty(name);
  },
  get: function(name){
    if (this.has(name))
      return this.names[name];
  },
  token: function(name){
    var ref = this.get(name);
    return ref && ref.token;
  },
  put: function(name, type, token){
{'fraction_non_alphanumeric': 0.13949463482173763, 'fraction_numerical': 0.0, 'mean_word_length': 2.5767326732673266, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3079924', 'n_tokens_mistral': 975, 'n_tokens_neox': 972, 'n_words': 223}