@Override public void visit(MathFunctionCall node) { resultValue = null; node.getOperand().accept(this); if (resultValue != null) { node.setOperand(resultValue); resultValue = null; } else { Variable var = getNewTemporaryVariable(); toInsert.put(var, node.getOperand()); toInsertVars.add(var); node.setOperand(var); } Variable var2 = getNewTemporaryVariable(); toInsert.put(var2, node); toInsertVars.add(var2); resultValue = var2; } };