summaryrefslogtreecommitdiff
path: root/dice-lang/src/bjc/dicelang/v1/ast/DiceASTInliner.java
diff options
context:
space:
mode:
authorEVE <EVE@EVE-PC>2017-03-14 12:08:11 -0400
committerEVE <EVE@EVE-PC>2017-03-14 12:08:11 -0400
commit635d3150e3e85c01b777ff165e21fa8965d58440 (patch)
tree3389128f83a5a79f8d0eec0a0e19f54b9d117b66 /dice-lang/src/bjc/dicelang/v1/ast/DiceASTInliner.java
parente59e2a97773f93bdd25bd4680809c10699f0feb3 (diff)
Cleanup
Diffstat (limited to 'dice-lang/src/bjc/dicelang/v1/ast/DiceASTInliner.java')
-rw-r--r--dice-lang/src/bjc/dicelang/v1/ast/DiceASTInliner.java32
1 files changed, 13 insertions, 19 deletions
diff --git a/dice-lang/src/bjc/dicelang/v1/ast/DiceASTInliner.java b/dice-lang/src/bjc/dicelang/v1/ast/DiceASTInliner.java
index 38e1361..74e59c6 100644
--- a/dice-lang/src/bjc/dicelang/v1/ast/DiceASTInliner.java
+++ b/dice-lang/src/bjc/dicelang/v1/ast/DiceASTInliner.java
@@ -4,21 +4,21 @@ import bjc.dicelang.v1.ast.nodes.DiceASTType;
import bjc.dicelang.v1.ast.nodes.IDiceASTNode;
import bjc.dicelang.v1.ast.nodes.VariableDiceNode;
import bjc.utils.data.ITree;
+import bjc.utils.data.Tree;
import bjc.utils.funcdata.FunctionalList;
import bjc.utils.funcdata.IList;
import bjc.utils.funcdata.IMap;
-import bjc.utils.data.Tree;
/**
* Inline variables in a dice AST
- *
+ *
* @author ben
*
*/
public class DiceASTInliner {
/**
* Inline all the variables in the AST
- *
+ *
* @param ast
* The AST to inline variables into
* @param enviroment
@@ -35,22 +35,18 @@ public class DiceASTInliner {
private static ITree<IDiceASTNode> inlineNode(IDiceASTNode node, IMap<String, ITree<IDiceASTNode>> enviroment,
boolean specificInline, IList<String> variableNames) {
// Only variables get inlined
- if (node.getType() != DiceASTType.VARIABLE) {
- return new Tree<>(node);
- }
+ if(node.getType() != DiceASTType.VARIABLE) return new Tree<>(node);
// Get the name of what we're inlining
String variableName = ((VariableDiceNode) node).getVariable();
// If we're inlining only certain variables, do so
- if (specificInline) {
+ if(specificInline) {
// Only inline the variable if we're supposed to
- if (variableNames.contains(variableName)) {
+ if(variableNames.contains(variableName)) {
// You can't inline non-existent variables
- if (!enviroment.containsKey(variableName)) {
- throw new UnsupportedOperationException(
- "Attempted to inline non-existant variable " + variableName);
- }
+ if(!enviroment.containsKey(variableName)) throw new UnsupportedOperationException(
+ "Attempted to inline non-existant variable " + variableName);
// Return the tree for the variable
return enviroment.get(variableName);
@@ -61,10 +57,8 @@ public class DiceASTInliner {
}
// You can't inline non-existent variables
- if (!enviroment.containsKey(variableName)) {
- throw new UnsupportedOperationException(
- "Attempted to inline non-existant variable " + variableName);
- }
+ if(!enviroment.containsKey(variableName)) throw new UnsupportedOperationException(
+ "Attempted to inline non-existant variable " + variableName);
// Return the tree for the variable
return enviroment.get(variableName);
@@ -72,7 +66,7 @@ public class DiceASTInliner {
/**
* Inline the specified variables in the AST
- *
+ *
* @param ast
* The AST to inline variables into
* @param enviroment
@@ -89,7 +83,7 @@ public class DiceASTInliner {
/**
* Inline the specified variables in the AST
- *
+ *
* @param ast
* The AST to inline variables into
* @param enviroment
@@ -101,7 +95,7 @@ public class DiceASTInliner {
public static ITree<IDiceASTNode> selectiveInline(ITree<IDiceASTNode> ast,
IMap<String, ITree<IDiceASTNode>> enviroment, String... variables) {
// If we're selectively inlining, do so
- if (variables != null && variables.length > 0) {
+ if(variables != null && variables.length > 0) {
IList<String> variableNames = new FunctionalList<>(variables);
// Selectively inline each tree node