|
44 | 44 | import org.graalvm.options.OptionCategory;
|
45 | 45 | import org.graalvm.polyglot.Context;
|
46 | 46 | import org.graalvm.polyglot.Context.Builder;
|
| 47 | +import org.graalvm.polyglot.Engine; |
47 | 48 | import org.graalvm.polyglot.PolyglotException;
|
48 | 49 | import org.graalvm.polyglot.PolyglotException.StackFrame;
|
49 | 50 | import org.graalvm.polyglot.Source;
|
@@ -73,14 +74,14 @@ public static void main(String[] args) {
|
73 | 74 | private boolean stdinIsInteractive = System.console() != null;
|
74 | 75 | private boolean runLLI = false;
|
75 | 76 | private boolean unbufferedIO = false;
|
| 77 | + private boolean multiContext = false; |
76 | 78 | private VersionAction versionAction = VersionAction.None;
|
77 | 79 | private String sulongLibraryPath = null;
|
78 | 80 | private List<String> givenArguments;
|
79 | 81 | private boolean wantsExperimental = false;
|
80 | 82 |
|
81 | 83 | @Override
|
82 | 84 | protected List<String> preprocessArguments(List<String> givenArgs, Map<String, String> polyglotOptions) {
|
83 |
| - |
84 | 85 | ArrayList<String> unrecognized = new ArrayList<>();
|
85 | 86 | ArrayList<String> inputArgs = new ArrayList<>();
|
86 | 87 | inputArgs.addAll(givenArgs);
|
@@ -197,6 +198,13 @@ protected List<String> preprocessArguments(List<String> givenArgs, Map<String, S
|
197 | 198 | unrecognized.add(arg);
|
198 | 199 | }
|
199 | 200 | break;
|
| 201 | + case "-multi-context": |
| 202 | + if (wantsExperimental) { |
| 203 | + multiContext = true; |
| 204 | + } else { |
| 205 | + unrecognized.add(arg); |
| 206 | + } |
| 207 | + break; |
200 | 208 | case "-dump":
|
201 | 209 | if (wantsExperimental) {
|
202 | 210 | subprocessArgs.add("Dgraal.Dump=");
|
@@ -374,6 +382,10 @@ protected void launch(Builder contextBuilder) {
|
374 | 382 | contextBuilder.option("python.TerminalWidth", Integer.toString(consoleHandler.getTerminalWidth()));
|
375 | 383 | contextBuilder.option("python.TerminalHeight", Integer.toString(consoleHandler.getTerminalHeight()));
|
376 | 384 |
|
| 385 | + if (multiContext) { |
| 386 | + contextBuilder.engine(Engine.create()); |
| 387 | + } |
| 388 | + |
377 | 389 | int rc = 1;
|
378 | 390 | try (Context context = contextBuilder.build()) {
|
379 | 391 | runVersionAction(versionAction, context.getEngine());
|
|
0 commit comments