<commit_before>
var luajs = luajs || {};




luajs.VM = function (env) {
	this._env = env || {};
	this._resetGlobals ();
};



	
luajs.VM.prototype._resetGlobals = function () {
	this._globals = {};
	for (var i in luajs.lib) this._globals[i] = luajs.lib[i];
	for (var i in this._env) this._globals[i] = this._env[i];
};




luajs.VM.prototype.load = function (url, execute) {
	var me = this;
	
	$.get (url, function (data) {			
		me._data = JSON.parse (data);
		if (execute || execute === undefined) me.execute ();
	});
};




luajs.VM.prototype.execute = function () {
	if (!this._data) throw new Error ('No data loaded.'); 
	
	try {
		new luajs.VM.Function (this._data, this._globals) ();
	} catch (e) {
		if (e instanceof luajs.Error && console) throw new Error ('[luajs] ' + e.message + '\n    ' + (e.luaStack || []).join ('\n    '));
		throw e;
	}	
};




luajs.VM.prototype.setGlobal = function (name, value) {
	this._globals[name] = value;
};




(function () {
	// Wrap functions passed to setTimeout in order to display formatted debugging.
	// (Not best practice, but practical in this case)
	
	var setTimeout = window.setTimeout;
	
	window.setTimeout = function (func, timeout) {

		return setTimeout (function () {
			try {
				func ();
			} catch (e) {
				if (e instanceof luajs.Error && console) throw new Error ('[luajs] ' + e.message + '\n    ' + (e.luaStack || []).join ('\n    '));
				throw e;
			}
		}, timeout);
	}
})();








luajs.VM.Closure = function (data, globals, upvalues) {
	this._data = data;
	this._globals = globals;
	this._upvalues = upvalues || {};
};




luajs.VM.Closure.prototype.getInstance = function () {
	return new luajs.VM.Function (this._data, this._globals, this._upvalues);
};



luajs.VM.Closure.prototype.call = function (obj) {
	var args = [],
		l = arguments.length,
		i;
		
	for (i = 1; i < l; i++) args.push (arguments[i]);
	return this.apply (obj, args);
};



luajs.VM.Closure.prototype.apply = function (obj, args) {
	if (!obj) throw new luajs.Error ('Call to undefined function');
	return this.getInstance ().apply (obj, args);
};









luajs.VM.Function = function (data, globals, upvalues) {<commit_msg>Updated so that jQuery does not conflict on $ var.<commit_after>
var luajs = luajs || {};




luajs.VM = function (env) {
	this._env = env || {};
	this._resetGlobals ();
};



	
luajs.VM.prototype._resetGlobals = function () {
	this._globals = {};
	for (var i in luajs.lib) this._globals[i] = luajs.lib[i];
	for (var i in this._env) this._globals[i] = this._env[i];
};




luajs.VM.prototype.load = function (url, execute) {
	var me = this;
	
	// TODO: Remove dependency on jQuery here!
	jQuery.get (url, function (data) {			
		me._data = JSON.parse (data);
		if (execute || execute === undefined) me.execute ();
	});
};




luajs.VM.prototype.execute = function () {
	if (!this._data) throw new Error ('No data loaded.'); 
	
	try {
		new luajs.VM.Function (this._data, this._globals) ();
	} catch (e) {
		if (e instanceof luajs.Error && console) throw new Error ('[luajs] ' + e.message + '\n    ' + (e.luaStack || []).join ('\n    '));
		throw e;
	}	
};




luajs.VM.prototype.setGlobal = function (name, value) {
	this._globals[name] = value;
};




(function () {
	// Wrap functions passed to setTimeout in order to display formatted debugging.
	// (Not best practice, but practical in this case)
	
	var setTimeout = window.setTimeout;
	
	window.setTimeout = function (func, timeout) {

		return setTimeout (function () {
			try {
				func ();
			} catch (e) {
				if (e instanceof luajs.Error && console) throw new Error ('[luajs] ' + e.message + '\n    ' + (e.luaStack || []).join ('\n    '));
				throw e;
			}
		}, timeout);
	}
})();








luajs.VM.Closure = function (data, globals, upvalues) {
	this._data = data;
	this._globals = globals;
	this._upvalues = upvalues || {};
};




luajs.VM.Closure.prototype.getInstance = function () {
	return new luajs.VM.Function (this._data, this._globals, this._upvalues);
};




luajs.VM.Closure.prototype.call = function (obj) {
	var args = [],
		l = arguments.length,
		i;
		
	for (i = 1; i < l; i++) args.push (arguments[i]);
	return this.apply (obj, args);
};




luajs.VM.Closure.prototype.apply = function (obj, args) {
	if (!obj) throw new luajs.Error ('Call to undefined function');
	return this.getInstance ().apply (obj, args);
};









luajs.VM.Function = function (data, globals, upvalues) {
{'fraction_non_alphanumeric': 0.17201627486437612, 'fraction_numerical': 0.0004520795660036166, 'mean_word_length': 3.123951537744641, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7507575', 'n_tokens_mistral': 1708, 'n_tokens_neox': 1555, 'n_words': 410}