Skip to content

Commit 45e9582

Browse files
committed
Change 'environment' to 'env' everywhere
1 parent 6d45acd commit 45e9582

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1324
-1324
lines changed

src/main/java/com/laytonsmith/core/MethodScriptCompiler.java

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,10 +1265,10 @@ public static List<Script> preprocess(TokenStream tokenStream,
12651265
* Compiles the token stream into a valid ParseTree. This also includes optimization and reduction.
12661266
*
12671267
* @param stream The token stream, as generated by {@link #lex(String, Environment, File, boolean) lex}
1268-
* @param environment If an environment is already set up, it can be passed in here. The code will tolerate a null
1268+
* @param env If an environment is already set up, it can be passed in here. The code will tolerate a null
12691269
* value, but if present, should be passed in. If the value is null, a standalone environment will be generated
12701270
* and used.
1271-
* @param envs The environments that are going to be present at runtime. Even if the {@code environment} parameter
1271+
* @param envs The environments that are going to be present at runtime. Even if the {@code env} parameter
12721272
* is null, this still must be non-null and populated with one or more values.
12731273
* @return A fully compiled, optimized, and reduced parse tree. If {@code stream} is null or empty, null is
12741274
* returned.
@@ -1278,20 +1278,20 @@ public static List<Script> preprocess(TokenStream tokenStream,
12781278
* @throws com.laytonsmith.core.exceptions.ConfigCompileGroupException A ConfigCompileGroupException is just
12791279
* a collection of single {@link ConfigCompileException}s.
12801280
*/
1281-
public static ParseTree compile(TokenStream stream, Environment environment,
1281+
public static ParseTree compile(TokenStream stream, Environment env,
12821282
Set<Class<? extends Environment.EnvironmentImpl>> envs) throws ConfigCompileException,
12831283
ConfigCompileGroupException {
1284-
return compile(stream, environment, envs, new StaticAnalysis(true));
1284+
return compile(stream, env, envs, new StaticAnalysis(true));
12851285
}
12861286

12871287
/**
12881288
* Compiles the token stream into a valid ParseTree. This also includes optimization and reduction.
12891289
*
12901290
* @param stream The token stream, as generated by {@link #lex(String, Environment, File, boolean) lex}
1291-
* @param environment If an environment is already set up, it can be passed in here. The code will tolerate a null
1291+
* @param env If an environment is already set up, it can be passed in here. The code will tolerate a null
12921292
* value, but if present, should be passed in. If the value is null, a standalone environment will be generated
12931293
* and used.
1294-
* @param envs The environments that are going to be present at runtime. Even if the {@code environment} parameter
1294+
* @param envs The environments that are going to be present at runtime. Even if the {@code env} parameter
12951295
* is null, this still must be non-null and populated with one or more values.
12961296
* @param staticAnalysis The static analysis object, or {@code null} to not perform static analysis. This object
12971297
* is used to perform static analysis on the AST that results from parsing, before any AST optimizations.
@@ -1304,22 +1304,22 @@ public static ParseTree compile(TokenStream stream, Environment environment,
13041304
* @throws com.laytonsmith.core.exceptions.ConfigCompileGroupException A ConfigCompileGroupException is just
13051305
* a collection of single {@link ConfigCompileException}s.
13061306
*/
1307-
public static ParseTree compile(TokenStream stream, Environment environment,
1307+
public static ParseTree compile(TokenStream stream, Environment env,
13081308
Set<Class<? extends Environment.EnvironmentImpl>> envs, StaticAnalysis staticAnalysis)
13091309
throws ConfigCompileException, ConfigCompileGroupException {
13101310
Objects.requireNonNull(envs, "envs parameter must not be null");
13111311
Objects.requireNonNull(staticAnalysis, "Static Analysis may be disabled, but cannot be null.");
13121312
try {
1313-
if(environment == null) {
1313+
if(env == null) {
13141314
// We MUST have a CompilerEnvironment. It doesn't need to be used, but we have to create it at
13151315
// this stage.
1316-
environment = Static.GenerateStandaloneEnvironment(false);
1316+
env = Static.GenerateStandaloneEnvironment(false);
13171317
}
1318-
if(!environment.hasEnv(CompilerEnvironment.class)) {
1318+
if(!env.hasEnv(CompilerEnvironment.class)) {
13191319
Environment e = Static.GenerateStandaloneEnvironment(false);
1320-
environment = environment.cloneAndAdd(e.getEnv(CompilerEnvironment.class));
1320+
env = env.cloneAndAdd(e.getEnv(CompilerEnvironment.class));
13211321
}
1322-
environment.getEnv(CompilerEnvironment.class).setStaticAnalysis(staticAnalysis);
1322+
env.getEnv(CompilerEnvironment.class).setStaticAnalysis(staticAnalysis);
13231323
} catch (IOException | DataSourceException | URISyntaxException | Profiles.InvalidProfileException ex) {
13241324
throw new RuntimeException(ex);
13251325
}
@@ -1328,7 +1328,7 @@ public static ParseTree compile(TokenStream stream, Environment environment,
13281328
// Return a null AST when the program is empty.
13291329
// Do run static analysis to allow for including this empty file in another file.
13301330
if(stream == null || stream.isEmpty()) {
1331-
staticAnalysis.analyze(null, environment, envs, compilerErrors);
1331+
staticAnalysis.analyze(null, env, envs, compilerErrors);
13321332
return null;
13331333
}
13341334

@@ -1348,7 +1348,7 @@ public static ParseTree compile(TokenStream stream, Environment environment,
13481348
}
13491349
}
13501350

1351-
processEarlyKeywords(stream, environment, compilerErrors);
1351+
processEarlyKeywords(stream, env, compilerErrors);
13521352
// All early keyword errors are handled, but then we halt compilation at this stage, since most
13531353
// further errors are likley meaningless.
13541354
if(!compilerErrors.isEmpty()) {
@@ -1547,7 +1547,7 @@ public static ParseTree compile(TokenStream stream, Environment environment,
15471547
+ " usage.";
15481548
CompilerWarning warning = new CompilerWarning(msg, t.target,
15491549
FileOptions.SuppressWarning.CodeUpgradeNotices);
1550-
environment.getEnv(CompilerEnvironment.class).addCodeUpgradeNotice(fileOptions, warning);
1550+
env.getEnv(CompilerEnvironment.class).addCodeUpgradeNotice(fileOptions, warning);
15511551
}
15521552
} catch (ConfigCompileException ex) {
15531553
// The function doesn't exist. It may be a compile error later (or maybe not, if it's
@@ -1576,7 +1576,7 @@ public static ParseTree compile(TokenStream stream, Environment environment,
15761576
+ " this warning will go away. If it is intended, move this parenthesis up to the same"
15771577
+ " line to actually execute it.", t.target,
15781578
SuppressWarning.PossibleUnexpectedExecution);
1579-
environment.getEnv(CompilerEnvironment.class).addCompilerWarning(fileOptions, warning);
1579+
env.getEnv(CompilerEnvironment.class).addCompilerWarning(fileOptions, warning);
15801580
f = new ParseTree(new CFunction(Compiler.__autoconcat__.NAME, unknown), fileOptions);
15811581
} else {
15821582
f = new ParseTree(new CFunction(Compiler.p.NAME, t.getTarget()), fileOptions);
@@ -1922,21 +1922,21 @@ public static ParseTree compile(TokenStream stream, Environment environment,
19221922
// Process the AST.
19231923
Stack<List<Procedure>> procs = new Stack<>();
19241924
procs.add(new ArrayList<>());
1925-
processKeywords(tree, environment, compilerErrors);
1926-
addSelfStatements(tree, environment, envs, compilerErrors);
1927-
rewriteAutoconcats(tree, environment, envs, compilerErrors, true);
1928-
processLateKeywords(tree, environment, compilerErrors);
1929-
checkLinearComponents(tree, environment, compilerErrors);
1930-
postParseRewrite(rootNode, environment, envs, compilerErrors, true); // Pass rootNode since this might rewrite 'tree'.
1925+
processKeywords(tree, env, compilerErrors);
1926+
addSelfStatements(tree, env, envs, compilerErrors);
1927+
rewriteAutoconcats(tree, env, envs, compilerErrors, true);
1928+
processLateKeywords(tree, env, compilerErrors);
1929+
checkLinearComponents(tree, env, compilerErrors);
1930+
postParseRewrite(rootNode, env, envs, compilerErrors, true); // Pass rootNode since this might rewrite 'tree'.
19311931
tree = rootNode.getChildAt(0);
19321932
moveNodeModifiersOffSyntheticNodes(tree);
1933-
staticAnalysis.analyze(tree, environment, envs, compilerErrors);
1934-
optimize(tree, environment, envs, procs, compilerErrors);
1933+
staticAnalysis.analyze(tree, env, envs, compilerErrors);
1934+
optimize(tree, env, envs, procs, compilerErrors);
19351935
link(tree, compilerErrors);
19361936
checkFunctionsExist(tree, compilerErrors, envs);
19371937
checkBreaks(tree, compilerErrors);
19381938
if(!staticAnalysis.isLocalEnabled()) {
1939-
checkUnhandledCompilerConstructs(tree, environment, compilerErrors);
1939+
checkUnhandledCompilerConstructs(tree, env, compilerErrors);
19401940
}
19411941
if(!compilerErrors.isEmpty()) {
19421942
if(compilerErrors.size() == 1) {
@@ -1946,7 +1946,7 @@ public static ParseTree compile(TokenStream stream, Environment environment,
19461946
throw new ConfigCompileGroupException(compilerErrors);
19471947
}
19481948
}
1949-
eliminateDeadCode(tree, environment, envs);
1949+
eliminateDeadCode(tree, env, envs);
19501950
return rootNode;
19511951
}
19521952

src/main/java/com/laytonsmith/core/Static.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -984,12 +984,12 @@ public static MCCommandSender GetCommandSender(String name, Target t) throws Con
984984
/**
985985
* If the sender is a player, it is returned, otherwise a ConfigRuntimeException is thrown.
986986
*
987-
* @param environment
987+
* @param env
988988
* @param t
989989
* @return
990990
*/
991-
public static MCPlayer getPlayer(Environment environment, Target t) {
992-
MCPlayer player = environment.getEnv(CommandHelperEnvironment.class).GetPlayer();
991+
public static MCPlayer getPlayer(Environment env, Target t) {
992+
MCPlayer player = env.getEnv(CommandHelperEnvironment.class).GetPlayer();
993993
if(player != null) {
994994
return player;
995995
} else {
@@ -1518,16 +1518,16 @@ public static File GetFileFromArgument(String arg, Environment env, Target t, Fi
15181518
* Returns true if currently running in cmdline mode. If the environment is null, or the GlobalEnv is not available,
15191519
* then defaultValue is returned.
15201520
*
1521-
* @param environment
1521+
* @param env
15221522
* @param defaultValue What should be returned if the environment is null or GlobalEnv is not present. (Happens
15231523
* during compile time.)
15241524
* @return
15251525
*/
1526-
public static boolean InCmdLine(Environment environment, boolean defaultValue) {
1527-
if(environment == null || !environment.hasEnv(GlobalEnv.class)) {
1526+
public static boolean InCmdLine(Environment env, boolean defaultValue) {
1527+
if(env == null || !env.hasEnv(GlobalEnv.class)) {
15281528
return defaultValue;
15291529
}
1530-
return environment.getEnv(GlobalEnv.class).inCmdlineMode();
1530+
return env.getEnv(GlobalEnv.class).inCmdlineMode();
15311531
}
15321532

15331533
/** @deprecated Use {@link #AssertType(Class, Mixed[], int, Function, Target, Environment)} instead. */

src/main/java/com/laytonsmith/core/StrictMode.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ public class StrictMode {
1414
* There are a couple of factors that go into determining if strict mode is enabled or not. This method
1515
* combines all the reasons into a single function call.
1616
* @param fileOptions This parameter is mandatory, and should be provided by the compiler or other source object.
17-
* @param environment This parameter is optional, and may be set to null. This is going to be the case on the first
17+
* @param env This parameter is optional, and may be set to null. This is going to be the case on the first
1818
* compiler pass, but in dynamic code instances, may be present.
1919
* @param t The code target, for error messages
2020
* @return True if strict mode rules should be followed for this object.
2121
*/
22-
public static boolean isStrictMode(FileOptions fileOptions, Environment environment, Target t) {
22+
public static boolean isStrictMode(FileOptions fileOptions, Environment env, Target t) {
2323
boolean runtimeSetting = false;
24-
if(environment != null) {
25-
GlobalEnv env = environment.getEnv(GlobalEnv.class);
26-
runtimeSetting = env.GetRuntimeSetting("system.strict_mode.enabled", false, t);
24+
if(env != null) {
25+
GlobalEnv gEnv = env.getEnv(GlobalEnv.class);
26+
runtimeSetting = gEnv.GetRuntimeSetting("system.strict_mode.enabled", false, t);
2727
}
2828
return fileOptions.isStrict() || runtimeSetting;
2929
}

src/main/java/com/laytonsmith/core/asm/LLVMFunction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public Boolean runAsync() {
107107
}
108108

109109
@Override
110-
public final Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException {
110+
public final Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException {
111111
throw new UnsupportedOperationException("Not supported.");
112112
}
113113

src/main/java/com/laytonsmith/core/constructs/CClosure.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -207,16 +207,16 @@ protected void execute(Mixed... values) throws ConfigRuntimeException, ProgramFl
207207
if(node == null) {
208208
return;
209209
}
210-
Environment environment;
210+
Environment env;
211211
try {
212212
synchronized(this) {
213-
environment = env.clone();
213+
env = this.env.clone();
214214
}
215215
} catch (CloneNotSupportedException ex) {
216216
Logger.getLogger(CClosure.class.getName()).log(Level.SEVERE, null, ex);
217217
return;
218218
}
219-
StackTraceManager stManager = environment.getEnv(GlobalEnv.class).GetStackTraceManager();
219+
StackTraceManager stManager = env.getEnv(GlobalEnv.class).GetStackTraceManager();
220220
stManager.addStackTraceElement(new ConfigRuntimeException.StackTraceElement("<<closure>>", getTarget()));
221221
try {
222222
CArray arguments = new CArray(node.getData().getTarget());
@@ -244,7 +244,7 @@ protected void execute(Mixed... values) throws ConfigRuntimeException, ProgramFl
244244
if(vararg == null) {
245245
// TODO: Once generics are added, add the type
246246
vararg = new CArray(value.getTarget());
247-
environment.getEnv(GlobalEnv.class).GetVarList().set(new IVariable(CArray.TYPE,
247+
env.getEnv(GlobalEnv.class).GetVarList().set(new IVariable(CArray.TYPE,
248248
name, vararg, value.getTarget()));
249249
varargType = this.types[this.types.length - 1];
250250
}
@@ -257,8 +257,8 @@ protected void execute(Mixed... values) throws ConfigRuntimeException, ProgramFl
257257
}
258258
vararg.push(value, value.getTarget());
259259
} else {
260-
IVariable var = new IVariable(types[i], name, value, getTarget(), environment);
261-
environment.getEnv(GlobalEnv.class).GetVarList().set(var);
260+
IVariable var = new IVariable(types[i], name, value, getTarget(), env);
261+
env.getEnv(GlobalEnv.class).GetVarList().set(var);
262262
}
263263
}
264264
}
@@ -272,7 +272,7 @@ protected void execute(Mixed... values) throws ConfigRuntimeException, ProgramFl
272272
}
273273

274274
if(!hasArgumentsParam) {
275-
environment.getEnv(GlobalEnv.class).GetVarList().set(new IVariable(CArray.TYPE, "@arguments", arguments,
275+
env.getEnv(GlobalEnv.class).GetVarList().set(new IVariable(CArray.TYPE, "@arguments", arguments,
276276
node.getData().getTarget()));
277277
}
278278

@@ -281,29 +281,29 @@ protected void execute(Mixed... values) throws ConfigRuntimeException, ProgramFl
281281
children.add(node);
282282
newNode.setChildren(children);
283283
try {
284-
MethodScriptCompiler.execute(newNode, environment, null, environment.getEnv(GlobalEnv.class)
284+
MethodScriptCompiler.execute(newNode, env, null, env.getEnv(GlobalEnv.class)
285285
.GetScript());
286286
} catch (LoopManipulationException e) {
287287
//This shouldn't ever happen.
288288
LoopManipulationException lme = ((LoopManipulationException) e);
289289
Target t = lme.getTarget();
290290
ConfigRuntimeException.HandleUncaughtException(ConfigRuntimeException.CreateUncatchableException("A "
291291
+ lme.getName() + "() bubbled up to the top of"
292-
+ " a closure, which is unexpected behavior.", t), environment);
292+
+ " a closure, which is unexpected behavior.", t), env);
293293
} catch (FunctionReturnException ex) {
294294
// Check the return type of the closure to see if it matches the defined type
295295
// Normal execution.
296296
Mixed ret = ex.getReturn();
297-
if(!InstanceofUtil.isInstanceof(ret.typeof(environment), returnType, environment)) {
297+
if(!InstanceofUtil.isInstanceof(ret.typeof(env), returnType, env)) {
298298
throw new CRECastException("Expected closure to return a value of type " + returnType.val()
299-
+ " but a value of type " + ret.typeof(environment) + " was returned instead", ret.getTarget());
299+
+ " but a value of type " + ret.typeof(env) + " was returned instead", ret.getTarget());
300300
}
301301
// Now rethrow it
302302
throw ex;
303303
} catch (CancelCommandException e) {
304304
// die()
305305
} catch (ConfigRuntimeException ex) {
306-
ex.setEnv(environment);
306+
ex.setEnv(env);
307307
if(ex instanceof AbstractCREException) {
308308
((AbstractCREException) ex).freezeStackTraceElements(stManager);
309309
}

src/main/java/com/laytonsmith/core/constructs/CIClosure.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ public CIClosure(ParseTree node, Environment env, CClassType returnType, String[
3131
// StackTraceManager stManager = env.getEnv(GlobalEnv.class).GetStackTraceManager();
3232
// stManager.addStackTraceElement(new ConfigRuntimeException.StackTraceElement("<<iclosure>>", getTarget()));
3333
// try {
34-
// Environment environment;
34+
// Environment env;
3535
// synchronized(this) {
36-
// environment = env.clone();
36+
// env = env.clone();
3737
// }
3838
// if(values != null) {
3939
// for(int i = 0; i < names.length; i++) {
@@ -44,8 +44,8 @@ public CIClosure(ParseTree node, Environment env, CClassType returnType, String[
4444
// } catch (Exception e) {
4545
// value = defaults[i].clone();
4646
// }
47-
// environment.getEnv(GlobalEnv.class).GetVarList().set(new IVariable(types[i], name, value,
48-
// getTarget(), environment));
47+
// env.getEnv(GlobalEnv.class).GetVarList().set(new IVariable(types[i], name, value,
48+
// getTarget(), env));
4949
// }
5050
// }
5151
// boolean hasArgumentsParam = false;
@@ -63,7 +63,7 @@ public CIClosure(ParseTree node, Environment env, CClassType returnType, String[
6363
// arguments.push(value, node.getData().getTarget());
6464
// }
6565
// }
66-
// environment.getEnv(GlobalEnv.class).GetVarList().set(new IVariable(CArray.TYPE, "@arguments", arguments,
66+
// env.getEnv(GlobalEnv.class).GetVarList().set(new IVariable(CArray.TYPE, "@arguments", arguments,
6767
// node.getData().getTarget()));
6868
// }
6969
//
@@ -72,7 +72,7 @@ public CIClosure(ParseTree node, Environment env, CClassType returnType, String[
7272
// children.add(node);
7373
// newNode.setChildren(children);
7474
// try {
75-
// MethodScriptCompiler.execute(newNode, environment, null, environment.getEnv(GlobalEnv.class)
75+
// MethodScriptCompiler.execute(newNode, env, null, env.getEnv(GlobalEnv.class)
7676
// .GetScript());
7777
// } catch (LoopManipulationException e) {
7878
// //This shouldn't ever happen.
@@ -84,7 +84,7 @@ public CIClosure(ParseTree node, Environment env, CClassType returnType, String[
8484
// } catch (FunctionReturnException ex) {
8585
// // Check the return type of the closure to see if it matches the defined type
8686
// Mixed ret = ex.getReturn();
87-
// if(!InstanceofUtil.isInstanceof(ret, returnType, environment)) {
87+
// if(!InstanceofUtil.isInstanceof(ret, returnType, env)) {
8888
// throw new CRECastException("Expected closure to return a value of type " + returnType.val()
8989
// + " but a value of type " + ret.typeof() + " was returned instead", ret.getTarget());
9090
// }

src/main/java/com/laytonsmith/core/constructs/CNativeClosure.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ public boolean isDynamic() {
3939
}
4040

4141
@Override
42-
public Mixed executeCallable(Environment environment, Target t, Mixed... values) throws ConfigRuntimeException, ProgramFlowManipulationException, CancelCommandException {
43-
return runnable.execute(t, environment, values);
42+
public Mixed executeCallable(Environment env, Target t, Mixed... values) throws ConfigRuntimeException, ProgramFlowManipulationException, CancelCommandException {
43+
return runnable.execute(t, env, values);
4444
}
4545

4646
@Override

src/main/java/com/laytonsmith/core/constructs/ProcedureUsage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ public Set<ObjectModifier> getObjectModifiers() {
7676
}
7777

7878
@Override
79-
public Mixed executeCallable(Environment environment, Target t, Mixed... values) throws ConfigRuntimeException,
79+
public Mixed executeCallable(Environment env, Target t, Mixed... values) throws ConfigRuntimeException,
8080
ProgramFlowManipulationException, CancelCommandException {
81-
return proc.execute(Arrays.asList(values), environment, t);
81+
return proc.execute(Arrays.asList(values), env, t);
8282
}
8383

8484
@Override

0 commit comments

Comments
 (0)