/** * Add an existing equation to the system * * @param eq the equation */ void addEquation(DF_Equation eq) { equations.addGraphNode(eq); newEquations.add(eq); DF_LatticeCell lhs = eq.getLHS(); if (!(lhs.getDefs().hasNext() || lhs.getUses().hasNext())) { lhs.addDef(eq); equations.addGraphNode(lhs); } else { lhs.addDef(eq); } DF_LatticeCell[] operands = eq.getOperands(); for (int i = 1; i < operands.length; i++) { DF_LatticeCell op = operands[i]; if (!(op.getDefs().hasNext() || op.getUses().hasNext())) { op.addUse(eq); equations.addGraphNode(op); } else { op.addUse(eq); } } if (EAGER && eq.evaluate()) changedCell(lhs); }
/** * Update the worklist, assuming that a particular equation has been re-evaluated * * @param eq the equation that has been re-evaluated. */ protected void updateWorkList(DF_Equation eq) { // find each equation which uses this lattice cell, and // add it to the work list Iterator<DF_Equation> e = eq.getLHS().getUses(); while (e.hasNext()) { workList.add(e.next()); } }