Skip to content

Commit

Permalink
Updated built libs.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulcuth committed Jul 27, 2015
1 parent 5501893 commit 1a3f5f2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion vm/moonshine-module.js

Large diffs are not rendered by default.

29 changes: 24 additions & 5 deletions vm/moonshine.js
Original file line number Diff line number Diff line change
Expand Up @@ -602,16 +602,16 @@ shine.FileManager.prototype.dispose = function () {


/**
* Loads a file containing compiled Luac code, decompiled to JSON.
* @param {string} url The url of the file to load.
* Loads a script.
* @param {string} script The URL, JSON blob or bytecode string of the script to be loaded.
* @param {boolean} [execute = true] Whether or not to execute the file once loaded.
* @param {object} [coConfig] Coroutine configuration. Only applicable if execute == true.
*/
shine.VM.prototype.load = function (url, execute, coConfig) {
shine.VM.prototype.load = function (script, execute, coConfig) {
var me = this;

this.fileManager.load(url, function (err, file) {
if (err) throw new URIError('Failed to load file: ' + url + ' (' + err + ')');
this.fileManager.load(script, function (err, file) {
if (err) throw new URIError('Failed to load file: ' + script + ' (' + err + ')');

me._trigger('file-loaded', file);
if (execute || execute === undefined) me.execute(coConfig, file);
Expand All @@ -621,6 +621,25 @@ shine.FileManager.prototype.dispose = function () {



/**
* Preloads a module into the Lua environment.
* @param {string} modname The under which the module will be made available in package.preload.
* @param {string} mod The URL, JSON blob or bytecode string of the module.
*/
shine.VM.prototype.preload = function (modname, mod) {
var me = this;

this.fileManager.load(mod, function (err, file) {
if (err) throw new URIError('Failed to preload module for: ' + modname + ' (' + err + ')');

var func = new shine.Function(me, file, file.data, me._globals);
me._globals['package'].preload[modname] = func;
});
};




/**
* Executes the loaded Luac data.
* @param {object} [coConfig] Coroutine configuration.
Expand Down
2 changes: 1 addition & 1 deletion vm/moonshine.min.js

Large diffs are not rendered by default.

0 comments on commit 1a3f5f2

Please sign in to comment.