Debugging...

This commit is contained in:
Eric van der Vlist 2021-05-01 23:40:15 +02:00
parent 0a98aaa1e6
commit b3cb52a8ab
2 changed files with 18 additions and 3 deletions

View File

@ -4,6 +4,11 @@
* This object can't be initialized when common.js is first read since the authorAccess object isn't available yet * This object can't be initialized when common.js is first read since the authorAccess object isn't available yet
* *
*/ */
out = Packages.java.lang.System.out;
out.println('commons.js');
__required__ = { __required__ = {
}; };
@ -18,12 +23,19 @@ require = function (filepath) {
}; };
__required__.required[currentPath] = true; __required__.required[currentPath] = true;
} }
var basePathFile = (new java.io.File(__required__.baseURIs[__required__.baseURIs.length - 1])).getParentFile(); var currentFilePath = __required__.baseURIs[__required__.baseURIs.length - 1];
filepath = new java.io.File(basePathFile, filepath).toString(); out.println('filepath: ' + filepath);
out.println('current filepath: ' + currentFilePath);
var currentURI = new java.net.URI(currentFilePath);
var targetURI = currentURI.resolve(filepath);
filepath = targetURI.toString();
out.println('filepath: ' + filepath);
if (__required__.required[filepath] == undefined) { if (__required__.required[filepath] == undefined) {
__required__.baseURIs.push(filepath); __required__.baseURIs.push(filepath);
__required__.required[filepath] = true; __required__.required[filepath] = true;
var text = new java.lang.String(java.nio.file.Files.readAllBytes(java.nio.file.Paths. get (java.net.URI(filepath)))); var uri = new java.net.URI(filepath);
out.println('New, inclusion needed: ' + uri.toString());
var text = new java.lang.String(java.nio.file.Files.readAllBytes( java.nio.file.Paths.get(targetURI) ));
text = String(text); text = String(text);
eval(text); eval(text);
__required__.baseURIs.pop(); __required__.baseURIs.pop();

View File

@ -1,3 +1,6 @@
require('hello.js');
require('./commons.js');
hello = function (){ hello = function (){
Packages.java.lang.System.out.println("Hello world."); Packages.java.lang.System.out.println("Hello world.");
} }