script modules and 'require()'

This commit is contained in:
minjaesong
2023-01-08 05:07:25 +09:00
parent 3a879edd54
commit ca39263131
7 changed files with 75 additions and 28 deletions

View File

@@ -1062,8 +1062,17 @@ Object.freeze(unicode);
///////////////////////////////////////////////////////////////////////////////
// install other stuffs
let glfile = files.open("A:/tvdos/gl.js")
const GL = eval(glfile.sread())
var require = (absdir) => {
let moduleFile = files.open(absdir)
if (!moduleFile.exists) throw Error("No such file: " + absdir)
let moduleScript = moduleFile.sread()
return eval(`let exports = {}; ${moduleScript}; Object.freeze(exports)`)
}
var GL = require("A:/tvdos/include/gl.js")
let checkTerm = `if (sys.peek(-49)&1) throw new InterruptedException();`
let injectIntChk = (s, n) => {
@@ -1091,6 +1100,8 @@ var execApp = (cmdsrc, args, appname) => {
execAppPrg(args);
}
///////////////////////////////////////////////////////////////////////////////
// Boot script