/* * Compilers/VMs can have byte code ranges for variables of the * same names that overlap. This is because the byte code ranges * aren't necessarily scopes; they may have more to do with the * lifetime of the variable's slot, depending on implementation. * * This method determines whether this variable hides an * identically named variable; ie, their byte code ranges overlap * this one starts after the given one. If it returns true this * variable should be preferred when looking for a single variable * with its name when both variables are visible. */ boolean hides(LocalVariable other) { LocalVariableImpl otherImpl = (LocalVariableImpl) other; if (!method.equals(otherImpl.method) || !name.equals(otherImpl.name)) { return false; } else { return (scopeStart.compareTo(otherImpl.scopeStart) > 0); } }
public boolean isVisible(StackFrame frame) { validateMirror(frame); Method frameMethod = frame.location().method(); if (!frameMethod.equals(method)) { throw new IllegalArgumentException("frame method different than variable's method"); } // this is here to cover the possibility that we will // allow LocalVariables for native methods. If we do // so we will have to re-examinine this. if (frameMethod.isNative()) { return false; } return ((scopeStart.compareTo(frame.location()) <= 0) && (scopeEnd.compareTo(frame.location()) >= 0)); }