diff options
author | Benoit Giannangeli <benoit.giannangeli@boursorama.fr> | 2017-02-17 16:04:42 +0100 |
---|---|---|
committer | Benoit Giannangeli <giann008@gmail.com> | 2017-02-17 21:28:40 +0100 |
commit | 06ec7904c37b897b2e87f4321198926ff22da1d9 (patch) | |
tree | 216d4a0e2fd2b0c984401caf91067b224a25cc28 /src/linit.js | |
parent | 5131a5ab1f471655d6398748b1eaa9abd47c14da (diff) | |
download | fengari-06ec7904c37b897b2e87f4321198926ff22da1d9.tar.gz fengari-06ec7904c37b897b2e87f4321198926ff22da1d9.tar.bz2 fengari-06ec7904c37b897b2e87f4321198926ff22da1d9.zip |
Basis to load std lib
Diffstat (limited to 'src/linit.js')
-rw-r--r-- | src/linit.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/linit.js b/src/linit.js new file mode 100644 index 0000000..2747fc2 --- /dev/null +++ b/src/linit.js @@ -0,0 +1,22 @@ +/* jshint esversion: 6 */ +"use strict"; + +const assert = require('assert'); + +const lapi = require('./lapi.js'); +const lauxlib = require('./lauxlib.js'); +const lbaselib = require('./lbaselib.js'); + +const loadedlibs = { + "_G" = luaopen_base +}; + +const luaL_openlibs = function(L) { + /* "require" functions from 'loadedlibs' and set results to global table */ + for (lib in loadedlibs) { + lauxlib.luaL_requiref(L, lib, loadedlibs[lib], 1); + lapi.lua_pop(L, 1); /* remove lib */ + } +} + +module.exports.luaL_openlibs = luaL_openlibs;
\ No newline at end of file |