2021-09-24 00:36:29 -05:00
|
|
|
jdk.imports['java.lang.System'].load = async () => {
|
|
|
|
const Formatter = await jdk.import('java.util.Formatter');
|
|
|
|
const InputStream = await jdk.import('java.io.InputStream');
|
|
|
|
const PrintStream = await jdk.import('java.io.PrintStream');
|
2021-09-23 01:41:44 -05:00
|
|
|
|
|
|
|
class System {}
|
|
|
|
|
|
|
|
System.in = new InputStream();
|
|
|
|
System.out = new PrintStream();
|
2022-02-23 11:26:23 -05:00
|
|
|
System.err = System.out;
|
2021-09-23 01:41:44 -05:00
|
|
|
System.out.onPrint = (length) => {
|
|
|
|
System.in.mark += length;
|
|
|
|
};
|
|
|
|
|
|
|
|
System.arraycopy = (src, srcPos, dest, destPos, numElements) => {
|
|
|
|
if (
|
|
|
|
(dest instanceof Float64Array || dest instanceof Int32Array) &&
|
|
|
|
(src instanceof Float64Array || src instanceof Int32Array)
|
|
|
|
) {
|
|
|
|
if (numElements == src.length) {
|
|
|
|
dest.set(src, destPos);
|
|
|
|
} else {
|
|
|
|
dest.set(src.subarray(srcPos, srcPos + numElements), destPos);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (let i = 0; i < numElements; i++) {
|
|
|
|
dest[destPos + i] = src[srcPos + i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
System.exit = (code) => {
|
|
|
|
console.log('Exited with code: ' + code);
|
2021-09-23 19:56:21 -05:00
|
|
|
if (window?.exit) exit();
|
2021-09-23 01:41:44 -05:00
|
|
|
};
|
2021-09-23 23:26:42 -05:00
|
|
|
jdk.java.lang.System = System;
|
2021-09-23 01:41:44 -05:00
|
|
|
};
|