|
@@ -18,6 +18,7 @@ import org.openzen.zenscript.parser.*;
|
18
|
18
|
import org.openzen.zenscript.validator.*;
|
19
|
19
|
|
20
|
20
|
import java.io.*;
|
|
21
|
+import java.lang.reflect.InvocationTargetException;
|
21
|
22
|
import java.util.*;
|
22
|
23
|
import java.util.function.*;
|
23
|
24
|
|
|
@@ -36,6 +37,8 @@ public class ScriptingEngine {
|
36
|
37
|
|
37
|
38
|
public boolean debug = false;
|
38
|
39
|
|
|
40
|
+ public IZSLogger logger;
|
|
41
|
+
|
39
|
42
|
public ScriptingEngine() {
|
40
|
43
|
space = new ModuleSpace(registry, new ArrayList<>(), StorageType.getStandard());
|
41
|
44
|
|
|
@@ -47,6 +50,12 @@ public class ScriptingEngine {
|
47
|
50
|
} catch (IOException | CompileException | ParseException ex) {
|
48
|
51
|
throw new RuntimeException(ex);
|
49
|
52
|
}
|
|
53
|
+ this.logger = new EmptyLogger();
|
|
54
|
+ }
|
|
55
|
+
|
|
56
|
+ public ScriptingEngine(IZSLogger logger) {
|
|
57
|
+ this();
|
|
58
|
+ this.logger = logger;
|
50
|
59
|
}
|
51
|
60
|
|
52
|
61
|
public JavaNativeModule createNativeModule(String name, String basePackage, JavaNativeModule... dependencies) {
|
|
@@ -145,8 +154,13 @@ public class ScriptingEngine {
|
145
|
154
|
runUnit.add(compiler.compile(compiled.name, compiled, javaSpace));
|
146
|
155
|
if (debug)
|
147
|
156
|
runUnit.dump(new File("classes"));
|
148
|
|
- runUnit.run(arguments, parentClassLoader);
|
149
|
|
- }
|
|
157
|
+
|
|
158
|
+ try {
|
|
159
|
+ runUnit.run(arguments, parentClassLoader);
|
|
160
|
+ } catch(ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
|
|
161
|
+ logger.throwingErr(e.getCause().getMessage(), e.getCause());
|
|
162
|
+ }
|
|
163
|
+ }
|
150
|
164
|
|
151
|
165
|
public List<JavaNativeModule> getNativeModules() {
|
152
|
166
|
return Collections.unmodifiableList(this.nativeModules);
|