/** * Replace this VariableReference where appropriate by a more efficient implementation. This * can only be done after all slot numbers are allocated. The efficiency is gained by binding the * VariableReference directly to a local or global slot, rather than going via the Binding object * @param parent the parent expression of this variable reference */ public void refineVariableReference(Expression parent) { if (binding instanceof Assignation || binding instanceof LocalParam || binding instanceof UserFunctionParameter) { // A LocalVariableReference can be evaluated directly, without going via the Binding object. int slot = binding.getLocalSlotNumber(); if (slot < 0) { // if slots haven't been allocated yet, we've come here too early. // See test group036 with -T option for an example. return; } LocalVariableReference ref = new LocalVariableReference(); ref.setSlotNumber(slot); ref.binding = binding; ref.staticType = staticType; ref.displayName = displayName; ExpressionTool.copyLocationInfo(this, ref); boolean found = parent.replaceSubExpression(this, ref); if (!found) { throw new IllegalStateException("Child expression not found in parent"); } } }
/** * Replace this VariableReference where appropriate by a more efficient implementation. This * can only be done after all slot numbers are allocated. The efficiency is gained by binding the * VariableReference directly to a local or global slot, rather than going via the Binding object * @param parent the parent expression of this variable reference */ public void refineVariableReference(Expression parent) { if (binding instanceof Assignation || binding instanceof LocalParam || binding instanceof UserFunctionParameter) { // A LocalVariableReference can be evaluated directly, without going via the Binding object. int slot = binding.getLocalSlotNumber(); if (slot < 0) { // if slots haven't been allocated yet, we've come here too early. // See test group036 with -T option for an example. return; } LocalVariableReference ref = new LocalVariableReference(); ref.setSlotNumber(slot); ref.binding = binding; ref.staticType = staticType; ref.displayName = displayName; ExpressionTool.copyLocationInfo(this, ref); boolean found = parent.replaceSubExpression(this, ref); if (!found) { throw new IllegalStateException("Child expression not found in parent"); } } }
Binding binding = var.getBinding(); if (exp instanceof LocalVariableReference) { ((LocalVariableReference)var).setSlotNumber(binding.getLocalSlotNumber());
Binding binding = var.getBinding(); if (exp instanceof LocalVariableReference) { ((LocalVariableReference)var).setSlotNumber(binding.getLocalSlotNumber());
Binding binding = var.getBinding(); if (exp instanceof LocalVariableReference) { ((LocalVariableReference) var).setSlotNumber(((LocalBinding) binding).getLocalSlotNumber());
Binding binding = var.getBinding(); if (exp instanceof LocalVariableReference) { ((LocalVariableReference) var).setSlotNumber(((LocalBinding) binding).getLocalSlotNumber());