@@ -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 ()) {
@@ -1493,7 +1493,7 @@ public static ParseTree compile(TokenStream stream, Environment environment,
14931493 myIndex .addChild (tree .getChildAt (j ));
14941494 }
14951495 } else {
1496- myIndex = new ParseTree (new CSlice ("0..-1" , t .target , environment ), fileOptions , true );
1496+ myIndex = new ParseTree (new CSlice ("0..-1" , t .target , env ), fileOptions , true );
14971497 }
14981498 tree .setChildren (tree .getChildren ().subList (0 , array ));
14991499 ParseTree arrayGet = new ParseTree (new CFunction (array_get .NAME , t .target ), fileOptions , true );
@@ -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 );
@@ -1676,7 +1676,7 @@ public static ParseTree compile(TokenStream stream, Environment environment,
16761676 value = next1 .val () + next2 .val ();
16771677 i ++;
16781678 }
1679- slice = new CSlice (".." + value , t .getTarget (), environment );
1679+ slice = new CSlice (".." + value , t .getTarget (), env );
16801680 i ++;
16811681 tree .addChild (new ParseTree (slice , fileOptions ));
16821682 constructCount .peek ().incrementAndGet ();
@@ -1699,7 +1699,7 @@ public static ParseTree compile(TokenStream stream, Environment environment,
16991699 value = next2 .val () + next3 .val ();
17001700 i ++;
17011701 }
1702- slice = new CSlice (".." + value , next1 .getTarget (), environment );
1702+ slice = new CSlice (".." + value , next1 .getTarget (), env );
17031703 if (t .type .isKeyword ()) {
17041704 tree .addChild (new ParseTree (new CKeyword (t .val (), t .getTarget ()), fileOptions ));
17051705 constructCount .peek ().incrementAndGet ();
@@ -1712,7 +1712,7 @@ public static ParseTree compile(TokenStream stream, Environment environment,
17121712 modifier = prev1 .val ();
17131713 tree .removeChildAt (tree .getChildren ().size () - 1 );
17141714 }
1715- slice = new CSlice (modifier + t .value + ".." , t .target , environment );
1715+ slice = new CSlice (modifier + t .value + ".." , t .target , env );
17161716 } else {
17171717 //both are provided
17181718 String modifier1 = "" ;
@@ -1734,7 +1734,7 @@ public static ParseTree compile(TokenStream stream, Environment environment,
17341734 second = next3 ;
17351735 i ++;
17361736 }
1737- slice = new CSlice (modifier1 + first .value + ".." + modifier2 + second .value , t .target , environment );
1737+ slice = new CSlice (modifier1 + first .value + ".." + modifier2 + second .value , t .target , env );
17381738 }
17391739 i ++;
17401740 tree .addChild (new ParseTree (slice , fileOptions ));
@@ -1754,12 +1754,12 @@ public static ParseTree compile(TokenStream stream, Environment environment,
17541754 if (!(previous .getData () instanceof SourceType st )) {
17551755 throw new ConfigCompileException ("Unexpected varargs token (\" ...\" ). This can only be used with types." , t .target );
17561756 }
1757- previous .setData (st .asVariadicType (environment ));
1757+ previous .setData (st .asVariadicType (env ));
17581758 continue ;
17591759 } else if (t .type == TType .LIT ) {
17601760 Construct c ;
17611761 try {
1762- c = Static .resolveConstruct (t .val (), t .target , true , environment );
1762+ c = Static .resolveConstruct (t .val (), t .target , true , env );
17631763 } catch (ConfigRuntimeException ex ) {
17641764 throw new ConfigCompileException (ex );
17651765 }
@@ -1805,7 +1805,7 @@ public static ParseTree compile(TokenStream stream, Environment environment,
18051805 tree .addChild (new ParseTree (new IVariable (t .val (), t .target ), fileOptions ));
18061806 constructCount .peek ().incrementAndGet ();
18071807 } else if (t .type .equals (TType .UNKNOWN )) {
1808- tree .addChild (new ParseTree (Static .resolveConstruct (t .val (), t .target , environment ), fileOptions ));
1808+ tree .addChild (new ParseTree (Static .resolveConstruct (t .val (), t .target , env ), fileOptions ));
18091809 constructCount .peek ().incrementAndGet ();
18101810 } else if (t .type .isSymbol ()) { //Logic and math symbols
18111811
@@ -1918,21 +1918,21 @@ public static ParseTree compile(TokenStream stream, Environment environment,
19181918 // Process the AST.
19191919 Stack <List <Procedure >> procs = new Stack <>();
19201920 procs .add (new ArrayList <>());
1921- processKeywords (tree , environment , compilerErrors );
1922- addSelfStatements (tree , environment , envs , compilerErrors );
1923- rewriteAutoconcats (tree , environment , envs , compilerErrors , true );
1924- processLateKeywords (tree , environment , compilerErrors );
1925- checkLinearComponents (tree , environment , compilerErrors );
1926- postParseRewrite (rootNode , environment , envs , compilerErrors , true ); // Pass rootNode since this might rewrite 'tree'.
1921+ processKeywords (tree , env , compilerErrors );
1922+ addSelfStatements (tree , env , envs , compilerErrors );
1923+ rewriteAutoconcats (tree , env , envs , compilerErrors , true );
1924+ processLateKeywords (tree , env , compilerErrors );
1925+ checkLinearComponents (tree , env , compilerErrors );
1926+ postParseRewrite (rootNode , env , envs , compilerErrors , true ); // Pass rootNode since this might rewrite 'tree'.
19271927 tree = rootNode .getChildAt (0 );
19281928 moveNodeModifiersOffSyntheticNodes (tree );
1929- staticAnalysis .analyze (tree , environment , envs , compilerErrors );
1930- optimize (tree , environment , envs , procs , compilerErrors );
1929+ staticAnalysis .analyze (tree , env , envs , compilerErrors );
1930+ optimize (tree , env , envs , procs , compilerErrors );
19311931 link (tree , compilerErrors );
19321932 checkFunctionsExist (tree , compilerErrors , envs );
19331933 checkBreaks (tree , compilerErrors );
19341934 if (!staticAnalysis .isLocalEnabled ()) {
1935- checkUnhandledCompilerConstructs (tree , environment , compilerErrors );
1935+ checkUnhandledCompilerConstructs (tree , env , compilerErrors );
19361936 }
19371937 if (!compilerErrors .isEmpty ()) {
19381938 if (compilerErrors .size () == 1 ) {
@@ -1942,7 +1942,7 @@ public static ParseTree compile(TokenStream stream, Environment environment,
19421942 throw new ConfigCompileGroupException (compilerErrors );
19431943 }
19441944 }
1945- eliminateDeadCode (tree , environment , envs );
1945+ eliminateDeadCode (tree , env , envs );
19461946 return rootNode ;
19471947 }
19481948
0 commit comments