summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8212ec1)
raw | patch | inline | side by side (parent: 8212ec1)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Sat, 16 Sep 2017 13:51:55 +0000 (16:51 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Sat, 16 Sep 2017 13:51:55 +0000 (16:51 +0300) |
rtl/Oberon.obn | patch | blob | history | |
rtl/java/Launcher.java | patch | blob | history |
diff --git a/rtl/Oberon.obn b/rtl/Oberon.obn
index 3316b850ea9e30bfd4b0c82eac8f77994fb0a1b3..37067d702e8879834e09136b304f7f894bd20920 100644 (file)
--- a/rtl/Oberon.obn
+++ b/rtl/Oberon.obn
i := 1;
WHILE i < Args.count DO
Args.GetArg(i, str); Texts.WriteString(W, str); Texts.Write(W, " ");
- Out.String("Param "); Out.Int(i, 0); Out.Char(" "); Out.String(str); Out.Ln;
INC(i)
END;
Texts.Append(Par.text, W.buf);
diff --git a/rtl/java/Launcher.java b/rtl/java/Launcher.java
index a49e32840ddb95efb76a6b743cd5b44de52d8328..3135732199c7bc03e68d3aae44dd41407cb6b277 100644 (file)
--- a/rtl/java/Launcher.java
+++ b/rtl/java/Launcher.java
class Launcher
{
public static void main(String[] args)
- throws
- ClassNotFoundException,
- InstantiationException,
- IllegalAccessException,
- NoSuchMethodException,
- InvocationTargetException
{
+ /* Этап 1: Сохраняем список параметров */
Args.args = args;
- Class<?> module = Class.forName(args[0]);
- Method begin = module.getMethod("BEGIN");
- begin.invoke(null);
+
+ /* Этап 2: Получаем имена связки Модуль.Команда */
+ if(args == null || args.length < 1)
+ {
+ System.err.println("uses: Launcher Module[.Command] {Argumets}");
+ System.exit(1);
+ }
+
+ String moduleName = args[0];
+ String commandName = "";
+ int i = args[0].indexOf('.');
+ if(i >= 0)
+ {
+ moduleName = args[0].substring(0, i);
+ commandName = args[0].substring(i + 1);
+ if(commandName == "BEGIN")
+ {
+ commandName = "";
+ }
+ }
+
+ /* Этап 3: Выполнение тела модуля и команды */
+ Class<?> module = null;
+ Method begin = null;
+ Method command = null;
+
+ try {
+ module = Class.forName(moduleName);
+ } catch(ClassNotFoundException e) {
+ System.err.println("Module " + moduleName + " not found");
+ System.exit(1);
+ }
+
+ try {
+ begin = module.getMethod("BEGIN");
+ } catch(Exception e) {
+ System.err.println("Invalid module " + moduleName);
+ System.exit(1);
+ }
+
+ try {
+ begin.invoke(null);
+ } catch(IllegalAccessException e) {
+ System.err.println("Invalid module " + moduleName);
+ System.exit(1);
+ } catch(IllegalArgumentException e) {
+ System.err.println("Invalid module " + moduleName);
+ System.exit(1);
+ } catch(InvocationTargetException e) {
+ System.err.println("Invalid module " + moduleName);
+ System.exit(1);
+ }
+
+ if(commandName == "")
+ {
+ return;
+ }
+
+ try {
+ command = module.getMethod(commandName);
+ } catch(Exception e) {
+ System.err.println("Invalid command " + moduleName + "." + commandName);
+ System.exit(1);
+ }
+
+ try {
+ command.invoke(null);
+ } catch(IllegalAccessException e) {
+ System.err.println("Invalid command " + moduleName + "." + commandName);
+ System.exit(1);
+ } catch(IllegalArgumentException e) {
+ System.err.println("Invalid command " + moduleName + "." + commandName);
+ System.exit(1);
+ } catch(InvocationTargetException e) {
+ System.err.println("Invalid command " + moduleName + "." + commandName);
+ System.exit(1);
+ }
}
}