diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-03-28 08:47:23 -0400 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-03-28 08:47:23 -0400 |
| commit | 62e94ef994a59e87543445bb3c0ce0a37017a70a (patch) | |
| tree | dfa1a488d3929e3f93e2a91669cdaf97c6d707f3 /dice-lang/src/bjc/utils/dice/ast/DiceASTFreezer.java | |
| parent | 78d9c539e25f16fd15f06c2b2c48c0ad37a21540 (diff) | |
Renamed packages to suit updated project
Diffstat (limited to 'dice-lang/src/bjc/utils/dice/ast/DiceASTFreezer.java')
| -rw-r--r-- | dice-lang/src/bjc/utils/dice/ast/DiceASTFreezer.java | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/dice-lang/src/bjc/utils/dice/ast/DiceASTFreezer.java b/dice-lang/src/bjc/utils/dice/ast/DiceASTFreezer.java deleted file mode 100644 index efe37c0..0000000 --- a/dice-lang/src/bjc/utils/dice/ast/DiceASTFreezer.java +++ /dev/null @@ -1,92 +0,0 @@ -package bjc.utils.dice.ast; - -import java.util.Map; - -import bjc.utils.parserutils.AST; - -/** - * Freeze references in a dice AST, replacing variable references with what - * the variables refer to - * - * @author ben - * - */ -public class DiceASTFreezer { - /** - * Expand a reference - * - * @param vnode - * The node containing the reference to expand - * @param env - * The enviroment to expand against - * @return The expanded reference - */ - private static AST<IDiceASTNode> expandNode(VariableDiceNode vnode, - Map<String, AST<IDiceASTNode>> env) { - return env.get(vnode.getVariable()); - } - - /** - * Expand a reference - * - * @param vnode - * The node containing the reference to expand - * @param env - * The enviroment to expand against - * @return The expanded reference - */ - private static AST<IDiceASTNode> expandNode2(VariableDiceNode vnode, - Map<String, DiceASTExpression> env) { - return env.get(vnode.getVariable()).getAst(); - } - - /** - * Freeze the references in an AST - * - * @param tree - * The tree to freeze references in - * @param env - * The enviroment to get reference values from - * @return The tree with references frozen - */ - @SuppressWarnings("unused") - public static AST<IDiceASTNode> freezeAST(AST<IDiceASTNode> tree, - Map<String, AST<IDiceASTNode>> env) { - return tree.collapse((nod) -> { - if (nod instanceof VariableDiceNode) { - return expandNode((VariableDiceNode) nod, env); - } else { - // Type is specified here so compiler can know the type - // we're using - return new AST<IDiceASTNode>(nod); - } - } , (op) -> (left, right) -> { - return new AST<IDiceASTNode>(op, left, right); - } , (r) -> r); - } - - /** - * Freeze the references in an expression backed by an AST - * - * @param tree - * The tree-backed expression to freeze references in - * @param env - * The enviroment to get reference values from - * @return The tree with references frozen - */ - @SuppressWarnings("unused") - public static AST<IDiceASTNode> freezeAST(DiceASTExpression tree, - Map<String, DiceASTExpression> env) { - return tree.getAst().collapse((nod) -> { - if (nod instanceof VariableDiceNode) { - return expandNode2((VariableDiceNode) nod, env); - } else { - // Type is specified here so compiler can know the type - // we're using - return new AST<IDiceASTNode>(nod); - } - } , (op) -> (left, right) -> { - return new AST<IDiceASTNode>(op, left, right); - } , (r) -> r); - } -} |
