mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-09 14:44:05 +09:00
some primitive MONitor thing
This commit is contained in:
@@ -1259,14 +1259,15 @@ const moduleCache = {}
|
||||
|
||||
// install other stuffs
|
||||
// js source-based impl
|
||||
/*var require = (absdir) => {
|
||||
var require = (absdir) => {
|
||||
let moduleFile = files.open(absdir)
|
||||
if (!moduleFile.exists) throw Error("No such file: " + absdir)
|
||||
let moduleScript = moduleFile.sread()
|
||||
var intchkFunName = `tvdosSIGTERM_${generateRandomHashStr(16)}`;
|
||||
return eval(`var ${intchkFunName} = function(){ ${checkTerm} };let exports = {}; ${injectIntChk(moduleScript, intchkFunName)}; Object.freeze(exports)`)
|
||||
}*/
|
||||
// COCC-based impl
|
||||
}
|
||||
|
||||
// COCC-based impl helper functions
|
||||
let loadImgToMem = (str) => {
|
||||
let intent = str.charCodeAt(4) // 2 for executable, 3 for shared
|
||||
let addrToLoad = (str.charCodeAt(5) << 16) | (str.charCodeAt(6) << 8) | (str.charCodeAt(7))
|
||||
@@ -1284,27 +1285,6 @@ let loadImgToMem = (str) => {
|
||||
|
||||
return addrToLoad
|
||||
}
|
||||
var require = (absdir) => {
|
||||
let moduleFile = files.open(absdir)
|
||||
if (!moduleFile.exists) throw Error("No such file: " + absdir)
|
||||
let moduleScript = moduleFile.sread()
|
||||
let moduleName = absdir.split("\\").last().substringBeforeLast(".")
|
||||
|
||||
// load the "string" into memory
|
||||
let ptr = loadImgToMem(moduleScript)
|
||||
let intent = sys.peek(ptr + 4)
|
||||
|
||||
// if it's a shared library, put it into the global table
|
||||
if (3 == intent) {
|
||||
// create the table if it's not there
|
||||
if (!_G.SO)
|
||||
_G.SO = {}
|
||||
|
||||
_G.SO[moduleName] = ptr
|
||||
}
|
||||
|
||||
requireFromMemory(ptr)
|
||||
}
|
||||
let requireFromMemory = (ptr) => {
|
||||
if (moduleCache[ptr]) return moduleCache[ptr]
|
||||
|
||||
@@ -1328,6 +1308,28 @@ let requireFromMemory = (ptr) => {
|
||||
moduleCache[moduleId] = moduleRunner
|
||||
return moduleRunner
|
||||
}
|
||||
// COCC-based impl
|
||||
/*var require = (absdir) => {
|
||||
let moduleFile = files.open(absdir)
|
||||
if (!moduleFile.exists) throw Error("No such file: " + absdir)
|
||||
let moduleScript = moduleFile.sread()
|
||||
let moduleName = absdir.split("\\").last().substringBeforeLast(".")
|
||||
|
||||
// load the "string" into memory
|
||||
let ptr = loadImgToMem(moduleScript)
|
||||
let intent = sys.peek(ptr + 4)
|
||||
|
||||
// if it's a shared library, put it into the global table
|
||||
if (3 == intent) {
|
||||
// create the table if it's not there
|
||||
if (!_G.SO)
|
||||
_G.SO = {}
|
||||
|
||||
_G.SO[moduleName] = ptr
|
||||
}
|
||||
|
||||
requireFromMemory(ptr)
|
||||
}*/
|
||||
|
||||
|
||||
var GL = require("A:/tvdos/include/gl.mjs")
|
||||
|
||||
@@ -44,7 +44,8 @@ const EXEC_FUNS = {
|
||||
"pcm": (f) => _G.shell.execute(`playpcm "${f}" -i`),
|
||||
"ipf1": (f) => _G.shell.execute(`decodeipf "${f}" -i`),
|
||||
"ipf2": (f) => _G.shell.execute(`decodeipf "${f}" -i`),
|
||||
"bas": (f) => _G.shell.execute(`basic "${f}"`)
|
||||
"bas": (f) => _G.shell.execute(`basic "${f}"`),
|
||||
"txt": (f) => _G.shell.execute(`less "${f}"`)
|
||||
}
|
||||
|
||||
let windowMode = 0 // 0 == left, 1 == right
|
||||
|
||||
Reference in New Issue
Block a user