/** * Creates an expression node that negates the given expression. * * @param value The expression that should be negated. A deep copy will be created. * @return A Negation object that negates the given expression. */ public static Negation negate(Expression value) { return new Negation(value.copy()); }
/** * Creates an exponentation node that squares the given expression. * * @param base The expression that should be squared. A deep copy will be created. * @return An exponentation object that exponentiates the given base with a float constant of 2.0. */ public static Multiplication square(Expression base) { return new Multiplication(base, base.copy()); }
@Override public Expression copy() { // create a deep copy of args list List<Expression> newArgs = new ArrayList<Expression>(); for (Expression e : args) { newArgs.add(e.copy()); } return new MacroCall(name, newArgs); }
@Override public void visit(Variable node) { if (replaceMap.containsKey(node.getName())) result = replaceMap.get(node.getName()).copy(); super.visit(node); }
@Override public Macro copyElements() { List<SequentialNode> bodyCopy = new ArrayList<SequentialNode>(); for (SequentialNode node : body) { bodyCopy.add(node.copy()); } return new Macro(getGraph(), name, bodyCopy, returnValue.copy()); }
@Override public Expression copy() { return new Negation(getOperand().copy()); }
@Override public Expression copy() { return new MathFunctionCall(getOperand().copy(), function); }
@Override public void visit(StoreResultNode node) { if (replaceMap.containsKey(node.getValue().getName())) { Expression replacement = replaceMap.get(node.getValue().getName()); if (replacement instanceof Variable) { node.setValue((Variable) replacement.copy()); } } }
@Override public void visit(AssignmentNode node) { node.getValue().accept(dfgReplacer); if (dfgReplacer.result != null) { node.setValue(dfgReplacer.result); dfgReplacer.result = null; } if (replaceMap.containsKey(node.getVariable().getName())) node.setVariable((Variable) replaceMap.get(node.getVariable().getName()).copy()); }
@Override public AssignmentNode copyElements() { AssignmentNode result = new AssignmentNode(getGraph(), variable.copy(), value.copy()); result.setGAPP(copyGAPP()); return result; }