ref.binding = newBinding; ref.binding.addReference(ref, isInLoop()); return ref;
private static void countReferences(Binding binding, Expression exp, List<VariableReference> references, int[] results) { // results[0] = nominal reference count // results[1] = quota nodes visited if (exp instanceof LocalVariableReference) { LocalVariableReference ref = (LocalVariableReference) exp; if (ref.getBinding() == binding) { ref.recomputeInLoop(); results[0] += ref.isInLoop() ? 10 : 1; references.add((LocalVariableReference) exp); } } else if ((exp.getDependencies() & StaticProperty.DEPENDS_ON_LOCAL_VARIABLES) != 0) { if (--results[1] <= 0) { // abandon the search results[0] = 100; results[1] = 0; } else { for (Operand o : exp.operands()) { countReferences(binding, o.getChildExpression(), references, results); } } } }
ref.binding = newBinding; ref.binding.addReference(ref, isInLoop()); return ref;
private static void countReferences(Binding binding, Expression exp, List<VariableReference> references, int[] results) { // results[0] = nominal reference count // results[1] = quota nodes visited if (exp instanceof LocalVariableReference) { LocalVariableReference ref = (LocalVariableReference) exp; if (ref.getBinding() == binding) { ref.recomputeInLoop(); results[0] += ref.isInLoop() ? 10 : 1; references.add((LocalVariableReference) exp); } } else if ((exp.getDependencies() & StaticProperty.DEPENDS_ON_LOCAL_VARIABLES) != 0) { if (--results[1] <= 0) { // abandon the search results[0] = 100; results[1] = 0; } else { for (Operand o : exp.operands()) { countReferences(binding, o.getChildExpression(), references, results); } } } }
/** * Reset cached static properties within a subtree, meaning that they have to be * recalulated next time they are required * * @param exp the root of the subtree within which static properties should be reset */ public static void resetPropertiesWithinSubtree(Expression exp) { exp.resetLocalStaticProperties(); if (exp instanceof LocalVariableReference) { LocalVariableReference ref = (LocalVariableReference) exp; Binding binding = ref.getBinding(); if (binding instanceof Assignation) { binding.addReference(ref, ref.isInLoop()); } } for (Operand o : exp.operands()) { resetPropertiesWithinSubtree(o.getChildExpression()); o.getChildExpression().setParentExpression(exp); } }
/** * Reset cached static properties within a subtree, meaning that they have to be * recalulated next time they are required * * @param exp the root of the subtree within which static properties should be reset */ public static void resetPropertiesWithinSubtree(Expression exp) { exp.resetLocalStaticProperties(); if (exp instanceof LocalVariableReference) { LocalVariableReference ref = (LocalVariableReference) exp; Binding binding = ref.getBinding(); if (binding instanceof Assignation) { binding.addReference(ref, ref.isInLoop()); } } for (Operand o : exp.operands()) { resetPropertiesWithinSubtree(o.getChildExpression()); o.getChildExpression().setParentExpression(exp); } }