Permalink
Browse files

Provide a default environment while compiling.

  • Loading branch information...
LadyCailin committed Jan 18, 2019
1 parent 268d3aa commit b1e537579407acc908a7dce4dc4ff134a12ff319
@@ -2308,7 +2308,20 @@ private static void optimize(ParseTree tree, Stack<List<Procedure>> procs, Set<C
+ tree.getData().val(), tree.getData().getTarget()));
result = null;
} else {
result = func.exec(tree.getData().getTarget(), null, constructs);
// TODO: This should probably be moved up outside of this single method, and create a
// compiler environment, which would be used by the functions that can do specific
// optimizations, i.e. compile time type checking, etc. This is a good first start
// though.
Environment env = null;
try {
env = Static.GenerateStandaloneEnvironment(false);
} catch (IOException | DataSourceException | URISyntaxException
| Profiles.InvalidProfileException e) {
// Print the stacktrace and move on. Not sure how to deal with this right now, or
// what cases it would occur in.
e.printStackTrace(System.err);
}
result = func.exec(tree.getData().getTarget(), env, constructs);
}
} else {
result = ((Optimizable) func).optimize(tree.getData().getTarget(), constructs);
@@ -267,7 +267,7 @@ public Mixed seval(ParseTree c, final Environment env) {
*/
@SuppressWarnings("UseSpecificCatch")
public Mixed eval(ParseTree c, final Environment env) throws CancelCommandException {
if(env != null && env.getEnv(GlobalEnv.class).IsInterrupted()) {
if(env.getEnv(GlobalEnv.class).IsInterrupted()) {
//First things first, if we're interrupted, kill the script
//unconditionally.
throw new CancelCommandException("", Target.UNKNOWN);

0 comments on commit b1e5375

Please sign in to comment.