Permalink
Browse files

Isolate environment re-use in compiler

  • Loading branch information...
PseudoKnight committed Oct 12, 2017
1 parent 414c014 commit 1479a350cdaccb1944ca061268fabaa5fbd51208
@@ -1,8 +1,10 @@
package com.laytonsmith.core;
import com.laytonsmith.abstraction.Implementation;
import com.laytonsmith.annotations.breakable;
import com.laytonsmith.annotations.nolinking;
import com.laytonsmith.annotations.unbreakable;
import com.laytonsmith.commandhelper.CommandHelperPlugin;
import com.laytonsmith.core.Optimizable.OptimizationOption;
import com.laytonsmith.core.compiler.FileOptions;
import com.laytonsmith.core.compiler.KeywordList;
@@ -24,6 +26,7 @@
import com.laytonsmith.core.constructs.Token;
import com.laytonsmith.core.constructs.Token.TType;
import com.laytonsmith.core.constructs.Variable;
import com.laytonsmith.core.environments.CommandHelperEnvironment;
import com.laytonsmith.core.environments.Environment;
import com.laytonsmith.core.environments.GlobalEnv;
import com.laytonsmith.core.exceptions.ConfigCompileException;
@@ -36,6 +39,7 @@
import com.laytonsmith.core.functions.FunctionBase;
import com.laytonsmith.core.functions.FunctionList;
import com.laytonsmith.core.functions.IncludeCache;
import com.laytonsmith.core.taskmanager.TaskManager;
import com.laytonsmith.persistence.DataSourceException;
import java.io.File;
import java.io.IOException;
@@ -1788,7 +1792,14 @@ private static void optimize(ParseTree tree, Stack<List<Procedure>> procs, Set<C
Script fakeScript = Script.GenerateScript(root, "*");
Environment env = null;
try {
env = Static.GenerateStandaloneEnvironment(false);
if(Implementation.GetServerType().equals(Implementation.Type.BUKKIT)) {
CommandHelperPlugin plugin = CommandHelperPlugin.self;
GlobalEnv gEnv = new GlobalEnv(plugin.executionQueue, plugin.profiler, plugin.persistenceNetwork,
MethodScriptFileLocations.getDefault().getConfigDirectory(), plugin.profiles, new TaskManager());
env = Environment.createEnvironment(gEnv, new CommandHelperEnvironment());
} else {
env = Static.GenerateStandaloneEnvironment(false);
}
} catch (IOException | DataSourceException | URISyntaxException | Profiles.InvalidProfileException e) {
//
}
@@ -5,7 +5,6 @@
import com.laytonsmith.PureUtilities.SimpleVersion;
import com.laytonsmith.PureUtilities.TermColors;
import com.laytonsmith.PureUtilities.XMLDocument;
import com.laytonsmith.abstraction.Implementation;
import com.laytonsmith.abstraction.MCCommandSender;
import com.laytonsmith.abstraction.MCConsoleCommandSender;
import com.laytonsmith.abstraction.MCEntity;
@@ -1261,14 +1260,8 @@ public static Environment GenerateStandaloneEnvironment(boolean install) throws
options.setWorkingDirectory(platformFolder);
PersistenceNetwork persistenceNetwork = new PersistenceNetwork(MethodScriptFileLocations.getDefault().getPersistenceConfig(),
new URI("sqlite://" + new File(platformFolder, "persistence.db").getCanonicalPath().replace('\\', '/')), options);
Profiler profiler;
if(Implementation.GetServerType().equals(Implementation.Type.BUKKIT) && CommandHelperPlugin.self.profiler != null) {
profiler = CommandHelperPlugin.self.profiler;
} else {
profiler = new Profiler(MethodScriptFileLocations.getDefault().getProfilerConfigFile());
}
GlobalEnv gEnv = new GlobalEnv(new MethodScriptExecutionQueue("MethodScriptExecutionQueue", "default"),
profiler, persistenceNetwork, platformFolder,
new Profiler(MethodScriptFileLocations.getDefault().getProfilerConfigFile()), persistenceNetwork, platformFolder,
new Profiles(MethodScriptFileLocations.getDefault().getProfilesFile()), new TaskManager());
gEnv.SetLabel(GLOBAL_PERMISSION);
return Environment.createEnvironment(gEnv, new CommandHelperEnvironment());

0 comments on commit 1479a35

Please sign in to comment.