@Override public void visit(AssignmentNode node) { node.getValue().accept(expressionVisitor); if (resultValue != null) { //Direct MathFunctionCalls won't need an extra temporary variable, //because they will be assigned to the AssignmentNode variable! //For this optimization the variable must be removed from the toInsertVars list toInsertVars.remove((Variable) resultValue); resultValue = null; } for (Variable var : toInsertVars) { AssignmentNode newNode = new AssignmentNode(node.getGraph(), var, toInsert.get(var)); node.insertBefore(newNode); } toInsertVars.clear(); toInsert.clear(); super.visit(node); } }
public String getReplacementID (Expression e){ OperationToken optok = ReplaceAbleOpsSet.get(e.toString().hashCode()); if (!optok.isUsedToReplace()) { optok.getAssignment().insertBefore(new AssignmentNode(optok.getAssignment().getGraph(), new Variable(optok.getIdentifier()), optok.getExpression())); optok.setUsedToReplace(true); } return ReplaceAbleOpsSet.get(e.toString().hashCode()).getIdentifier(); }
@Override public void visit(AssignmentNode node) { String variable = node.getVariable().getName(); if (assigned.contains(variable)) { String message = "Variable " + variable + " has been reset for reuse."; log.warn(message); Notifications.addWarning(message); code.append("\n"); appendIndentation(); code.append("memset("); code.append(variable); code.append(", 0, sizeof("); code.append(variable); code.append(")); // Reset variable for reuse.\n"); assigned.remove(variable); } appendIndentation(); node.getVariable().accept(this); code.append(" = "); node.getValue().accept(this); code.append(";"); if (node.getVariable() instanceof MultivectorComponent) { code.append(" // "); MultivectorComponent component = (MultivectorComponent) node.getVariable(); code.append(node.getGraph().getAlgebraDefinitionFile().getBladeString(component.getBladeIndex())); } code.append('\n'); node.getSuccessor().accept(this); }
AssignmentNode node = listIterator.next(); Expression exp = MaximaRoutines.getExpressionFromMaximaOutput(io); result.add(new AssignmentNode(node.getGraph(), new MultivectorComponent(node.getVariable().getName(), 0), exp));
@Override public AssignmentNode copyElements() { AssignmentNode result = new AssignmentNode(getGraph(), variable.copy(), value.copy()); result.setGAPP(copyGAPP()); return result; }
code.append(assignmentNode.getGraph().getAlgebraDefinitionFile().getBladeString(component.getBladeIndex()));
@Override public void visit(AssignmentNode node) { appendIndentation(); declaredLocal.add(getVarName(node.getVariable())); node.getVariable().accept(this); append(" = "); node.getValue().accept(this); if (node.getVariable() instanceof MultivectorComponent) { append(';'); append(" // "); MultivectorComponent component = (MultivectorComponent) node.getVariable(); append(node.getGraph().getAlgebraDefinitionFile().getBladeString(component.getBladeIndex())); } append(";\n"); node.getSuccessor().accept(this); }