/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* This class is used to assemble the local variable table.
*
* WARNING: The contents of this source file are not part of any
* supported API. Code that depends on them does so at its own risk:
* they are subject to change or removal without notice.
*
* @author Arthur van Hoff
*/
final
class LocalVariableTable {
int len;
/**
* Define a new local variable. Merge entries where possible.
*/
return;
}
for (int i = 0 ; i < len ; i++) {
return;
}
}
}
}
/**
* Trim overlapping local ranges. Java forbids shadowing of
* locals in nested scopes, but non-nested scopes may still declare
* locals with the same name. Because local variable ranges are
* computed using flow analysis as part of assembly, it isn't
* possible to simply make sure variable ranges end where the
* enclosing lexical scope ends. This method makes sure that
* variables with the same name don't overlap, giving priority to
* fields with higher slot numbers that should have appeared later
* in the source.
*/
private void trim_ranges() {
for (int i=0; i<len; i++) {
for (int j=i+1; j<len; j++) {
// At this point we know that both ranges are
// the same name and there is also overlap or they abut
} else {
// We've detected two local variables with the
// same name, and the one with the greater slot
// number starts before the other. This order
// reversal may happen with locals with the same
// name declared in both a try body and an
// associated catch clause. This is rare, and
// we give up.
}
} else {
// Same situation as above; just give up.
}
} else {
// This case can happen if there are two variables
// with the same name and slot numbers, and ranges
// that abut. AFAIK the only way this can occur
// is with multiple static initializers. Punt.
}
}
}
}
}
/**
* Write out the data.
*/
trim_ranges();
for (int i = 0 ; i < len ; i++) {
//System.out.println("pc=" + locals[i].from + ", len=" + (locals[i].to - locals[i].from) + ", nm=" + locals[i].field.getName() + ", slot=" + locals[i].slot);
}
}
}