<commit_before>function $init$native$Exception$before(exc) {
  var _caller=arguments.callee.caller.caller;
  exc.stack_trace=[];
  while(_caller) {
    exc.stack_trace.push(_caller);
    _caller = _caller.caller;
  }
}
function printStackTrace(exc, _write) {
  if (_write===undefined)_write=getProcess().writeError;
  var _c = className(exc);
  if (exc.message.size > 0) {
    _c += ' "' + exc.message + '"';
  }
  _write(_c);_write(getOperatingSystem().newline);
  for (var i=0; i<exc.stack_trace.length; i++) {
    var f = exc.stack_trace[i];
    var mm = f.$$metamodel$$;
    if (typeof(mm)==='function') {
      mm = mm();
      f.$$metamodel$$=mm;
    }
    if (mm) {
      var _src = '';
      if (i==0) {
        if (exc.$loc && exc.$file) _src = ' (' + exc.$file + " " + exc.$loc + ')';
      }
      _write("    at " + mm.d[0] + "::" + mm.d[mm.d.length-1] + _src);_write(getOperatingSystem().newline);
    }
  }
}
printStackTrace.$$metamodel$$=function(){
  return{mod:$$METAMODEL$$,d:['ceylon.language','printStackTrace'],$t:{t:Anything},$ps:[
    {$nm:'exception',$t:{t:Exception},$mt:'prm'},{$nm:'write',$t:{t:Callable,a:{Return:{t:Anything},Arguments:{t:'T',l:[{t:String$}]}}},$mt:'prm','$def':1}
  ]};};
exports.printStackTrace=printStackTrace;
<commit_msg>fix ceylon/ceylon-js#307 detect infinite loop in stack trace<commit_after>function $init$native$Exception$before(exc) {
  var _caller=arguments.callee.caller.caller;
  exc.stack_trace=[];
  var ilc=0;
  var ilf=null;
  while(_caller) {
    exc.stack_trace.push(_caller);
    _caller = _caller.caller;
    if (_caller===ilf) {
      ilc++;
      if (ilc>2) {
        exc.stack_trace.push("CIRCULAR");
        _caller = null;
      }
    } else if (ilc===0 && _caller && exc.stack_trace.contains(_caller)) {
      ilc=1;
      ilf=_caller;
    }
  }
}
function printStackTrace(exc, _write) {
  if (_write===undefined)_write=getProcess().writeError;
  var _c = className(exc);
  if (exc.message.size > 0) {
    _c += ' "' + exc.message + '"';
  }
  _write(_c);_write(getOperatingSystem().newline);
  for (var i=0; i<exc.stack_trace.length; i++) {
    var f = exc.stack_trace[i];
    if (f == "CIRCULAR") {
      _write("    (Infinite loop detected)");
      _write(getOperatingSystem().newline);
      return;
    }
    var mm = f.$$metamodel$$;
    if (typeof(mm)==='function') {
      mm = mm();
      f.$$metamodel$$=mm;
    }
    if (mm) {
      var _src = '';
      if (i==0) {
        if (exc.$loc && exc.$file) _src = ' (' + exc.$file + " " + exc.$loc + ')';
      }
      _write("    at " + mm.d[0] + "::" + mm.d[mm.d.length-1] + _src);_write(getOperatingSystem().newline);
    }
  }
}
printStackTrace.$$metamodel$$=function(){
  return{mod:$$METAMODEL$$,d:['ceylon.language','printStackTrace'],$t:{t:Anything},$ps:[
    {$nm:'exception',$t:{t:Exception},$mt:'prm'},{$nm:'write',$t:{t:Callable,a:{Return:{t:Anything},Arguments:{t:'T',l:[{t:String$}]}}},$mt:'prm','$def':1}
  ]};};
exports.printStackTrace=printStackTrace;

{'fraction_non_alphanumeric': 0.22414943295530354, 'fraction_numerical': 0.0063375583722481655, 'mean_word_length': 3.628086419753086, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 6, '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': '6019903', 'n_tokens_mistral': 1179, 'n_tokens_neox': 1145, 'n_words': 155}