<commit_before>Array.prototype.each = function(f) {
  for (var idx = 0; idx < this.length; idx++)
    f(this[idx], idx)
}



/*
  Copyright (c) 2008 <NAME> <<EMAIL>>

  TODO: make assignment into properties of argument work, e.g., arguments[5] = 1234
  TODO: make for-in work when variable is a property access, e.g., for (x.y in ys) ...
*/

ometa WJSParser <: BSJSParser {
  isKeyword :x = ?(x == 'thisWorld')
               | super('isKeyword', x),
  primExprHd   = "thisWorld"            -> ['thisWorld']
               | super('primExprHd'),
  stmt         = "in" expr:w block:b    -> ['in', w, b]
               | super('stmt')
}

makeFunction = function(fs, body) {
  return '(function() { var staticScope = thisScope;'                                                            +
                      ' var r = function() {'                                                                    +
                        ' var oldScope = thisScope;'                                                             +
                        ' thisScope = staticScope.makeChild();'                                                  +
/*
                        ' thisScope.set("arguments", arguments);'                                                +
                        ' thisWorld.set(arguments, "length", arguments.length);'                                 +
                        ' for (var i = 0; i < arguments.length; i++) thisWorld.set(arguments, i, arguments[i]);' +
*/
                        ' try { ' + fs + body + '}'                                                              +
                        ' catch (e) { throw e }'                                                                 +
                        ' finally { thisScope = oldScope }};'                                                    +
                      ' baseWorld.set(r, "prototype", {parent: Object.prototype});'                              +
                      ' return r })()' }

makeIn = function(w, body) {
  return '{ try { worldStack.push(thisWorld); thisWorld = ' + w + '; ' + body + '} ' +
           'catch (e) { throw e } '                                                  +
           'finally { thisWorld = worldStack.pop() }'                                +
           'undefined }'
}

makeForIn = function(v, e, s, decl) {
  var p = tempnam(), ps = tempnam()
  var r = 'for (var ' + p + ' in ' + ps + ' = thisWorld.props(' + e + ', {})) {' +
            'if (!' + ps + '.hasOwnProperty(' + p + ')) continue; ' +<commit_msg>try { ... } catch (e) { throw e } finally { ... } -> try { ... } finally { ... }<commit_after>Array.prototype.each = function(f) {
  for (var idx = 0; idx < this.length; idx++)
    f(this[idx], idx)
}



/*
  Copyright (c) 2008 <NAME> <<EMAIL>>

  TODO: make assignment into properties of argument work, e.g., arguments[5] = 1234
  TODO: make for-in work when variable is a property access, e.g., for (x.y in ys) ...
*/

ometa WJSParser <: BSJSParser {
  isKeyword :x = ?(x == 'thisWorld')
               | super('isKeyword', x),
  primExprHd   = "thisWorld"            -> ['thisWorld']
               | super('primExprHd'),
  stmt         = "in" expr:w block:b    -> ['in', w, b]
               | super('stmt')
}

makeFunction = function(fs, body) {
  return '(function() { var staticScope = thisScope;'                                                            +
                      ' var r = function() {'                                                                    +
                        ' var oldScope = thisScope;'                                                             +
                        ' thisScope = staticScope.makeChild();'                                                  +
/*
                        ' thisScope.set("arguments", arguments);'                                                +
                        ' thisWorld.set(arguments, "length", arguments.length);'                                 +
                        ' for (var i = 0; i < arguments.length; i++) thisWorld.set(arguments, i, arguments[i]);' +
*/
                        ' try { ' + fs + body + '}'                                                              +
                        ' finally { thisScope = oldScope }};'                                                    +
                      ' baseWorld.set(r, "prototype", {parent: Object.prototype});'                              +
                      ' return r })()' }

makeIn = function(w, body) {
  return '{ try { worldStack.push(thisWorld); thisWorld = ' + w + '; ' + body + '} ' +
           'finally { thisWorld = worldStack.pop() }'                                +
           'undefined }'
}

makeForIn = function(v, e, s, decl) {
  var p = tempnam(), ps = tempnam()
  var r = 'for (var ' + p + ' in ' + ps + ' = thisWorld.props(' + e + ', {})) {' +
            'if (!' + ps + '.hasOwnProperty(' + p + ')) continue; ' +
{'fraction_non_alphanumeric': 0.13947847180109157, 'fraction_numerical': 0.004447139680614514, 'mean_word_length': 0.9919484702093397, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 38, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7092328', 'n_tokens_mistral': 1252, 'n_tokens_neox': 1208, 'n_words': 302}