Admin User, created Apr 18. 2025
import nova.*;
import nova.runtime;
import jdk.internal.misc.Signal;
import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
/**
* Warranty & Liability
* To the extent permitted by applicable law and unless explicitly
* otherwise agreed upon, XLOG Technologies AG makes no warranties
* regarding the provided information. XLOG Technologies AG assumes
* no liability that any problems might be solved with the information
* provided by XLOG Technologies AG.
* <p/>
* Rights & License
* All industrial property rights regarding the information - copyright
* and patent rights in particular - are the sole property of XLOG
* Technologies AG. If the company was not the originator of some
* excerpts, XLOG Technologies AG has at least obtained the right to
* reproduce, change and translate the information.
* <p/>
* Reproduction is restricted to the whole unaltered document. Reproduction
* of the information is only allowed for non-commercial uses. Selling,
* giving away or letting of the execution of the library is prohibited.
* The library can be distributed as part of your applications and libraries
* for execution provided this comment remains unchanged.
* <p/>
* Restrictions
* Only to be distributed with programs that add significant and primary
* functionality to the library. Not to be distributed with additional
* software intended to replace any components of the library.
* <p/>
* Trademarks
* Jekejeke is a registered trademark of XLOG Technologies AG.
*/
public final class Index {
/**************************************************************/
/* Boot API */
/**************************************************************/
public static void boot(String[] args) {
special.set_args(args);
special.boot();
runtime.boot();
eval.boot();
theatre.boot();
Bootload.boot1();
Bootload.boot2();
Bootload.boot3();
Bootload.boot4();
Bootload.boot8();
Bootload.boot10();
Streams.boot5();
Streams.boot6();
Streams.boot7();
Streams.boot9();
}
/**************************************************************/
/* Plain Console */
/**************************************************************/
private static Object plain_out(Object data, String buf) {
try {
((Writer) data).write(buf);
return data;
} catch (IOException err) {
throw Machine.make_error(runtime.map_stream_error(err));
}
}
private static void console_flush(Object data) {
try {
((Writer) data).flush();
} catch (IOException err) {
throw Machine.make_error(runtime.map_stream_error(err));
}
}
/**************************************************************/
/* Async ANSI Console */
/**************************************************************/
private final static String ANSI_RESET = "\u001B[0m";
private final static String ANSI_INPUT = "\u001B[32m"; // Green
private final static String ANSI_ERROR = "\u001B[31m"; // Red
private static Object ansi_out(Object data, String buf) {
try {
((Writer) data).write(ANSI_RESET);
((Writer) data).write(buf);
((Writer) data).write(ANSI_INPUT);
return data;
} catch (IOException err) {
throw Machine.make_error(runtime.map_stream_error(err));
}
}
private static Object ansi_err(Object data, String buf) {
try {
((Writer) data).write(ANSI_ERROR);
((Writer) data).write(buf);
((Writer) data).write(ANSI_INPUT);
return data;
} catch (IOException err) {
throw Machine.make_error(runtime.map_stream_error(err));
}
}
/**************************************************************/
/* When Main */
/**************************************************************/
private static void ctrlc_abort(Signal sig) {
theatre.post(new Store.Compound("system_error",
new Object[]{"user_abort"}));
}
private static void dogelog_async(Object[] args) {
Signal.Handler back = Signal.handle(new Signal("INT"), Index::ctrlc_abort);
try {
theatre.init();
theatre.perform("sys_baseline");
if (args.length > 0) {
theatre.perform_async("sys_launch");
} else {
runtime.Sink dst = new runtime.Sink();
dst.data = new OutputStreamWriter(System.out, StandardCharsets.UTF_8);
dst.send = Index::ansi_out;
dst.notify = Index::console_flush;
Store.engine.text_output = dst;
dst = new runtime.Sink();
dst.data = new OutputStreamWriter(System.err, StandardCharsets.UTF_8);
dst.send = Index::ansi_err;
dst.notify = Index::console_flush;
Store.engine.text_error = dst;
theatre.perform_async("sys_launch");
System.out.print(ANSI_RESET);
}
} finally {
Signal.handle(new Signal("INT"), back);
}
}
public static void main(String[] args) throws IOException, URISyntaxException {
boot(args);
String[] classpath = special.findRoots(runtime.class.getClassLoader());
special.set_classpath(classpath);
String bootbase = (classpath.length > 0 ? new File(new URI(classpath[0])).toString() : "");
runtime.set_bootbase(bootbase);
runtime.Sink dst = new runtime.Sink();
dst.data = new OutputStreamWriter(System.out, StandardCharsets.UTF_8);
dst.send = Index::plain_out;
dst.notify = Index::console_flush;
Store.engine.text_output = dst;
dst = new runtime.Sink();
dst.data = new OutputStreamWriter(System.err, StandardCharsets.UTF_8);
dst.send = Index::plain_out;
dst.notify = Index::console_flush;
Store.engine.text_error = dst;
runtime.Source src = new runtime.Source();
src.data = new InputStreamReader(System.in, StandardCharsets.UTF_8);
src.receive = (Handler.Factory) runtime::file_read_promise;
src.flags |= runtime.MASK_SRC_AREAD;
Store.engine.text_input = src;
try {
dogelog_async(args);
} catch (Handler.Problem err) {
theatre.perform(new Store.Compound("sys_print_error", new Object[]{err.term}));
System.exit(1);
}
}
}