Methods Summary |
---|
protected java.lang.Object | clone()Returns a deep copy of this object; i.e. the clone
operates on a new local variable array.
However, the Type objects in the array are shared.
LocalVariables lvs = new LocalVariables(locals.length);
for (int i=0; i<locals.length; i++){
lvs.locals[i] = this.locals[i];
}
return lvs;
|
public boolean | equals(java.lang.Object o)
if (!(o instanceof LocalVariables)) return false;
LocalVariables lv = (LocalVariables) o;
if (this.locals.length != lv.locals.length) return false;
for (int i=0; i<this.locals.length; i++){
if (!this.locals[i].equals(lv.locals[i])){
//System.out.println(this.locals[i]+" is not "+lv.locals[i]);
return false;
}
}
return true;
|
public com.sun.org.apache.bcel.internal.generic.Type | get(int i)Returns the type of the local variable slot i.
return locals[i];
|
public com.sun.org.apache.bcel.internal.verifier.structurals.LocalVariables | getClone()Returns a (correctly typed) clone of this object.
This is equivalent to ((LocalVariables) this.clone()).
return (LocalVariables) this.clone();
|
public void | initializeObject(UninitializedObjectType u)Replaces all occurences of u in this local variables set
with an "initialized" ObjectType.
for (int i=0; i<locals.length; i++){
if (locals[i] == u){
locals[i] = u.getInitialized();
}
}
|
public int | maxLocals()Returns the number of local variable slots this
LocalVariables instance has.
return locals.length;
|
public void | merge(com.sun.org.apache.bcel.internal.verifier.structurals.LocalVariables lv)Merges two local variables sets as described in the Java Virtual Machine Specification,
Second Edition, section 4.9.2, page 146.
if (this.locals.length != lv.locals.length){
throw new AssertionViolatedException("Merging LocalVariables of different size?!? From different methods or what?!?");
}
for (int i=0; i<locals.length; i++){
merge(lv, i);
}
|
private void | merge(com.sun.org.apache.bcel.internal.verifier.structurals.LocalVariables lv, int i)Merges a single local variable.
// We won't accept an unitialized object if we know it was initialized;
// compare vmspec2, 4.9.4, last paragraph.
if ( (!(locals[i] instanceof UninitializedObjectType)) && (lv.locals[i] instanceof UninitializedObjectType) ){
throw new StructuralCodeConstraintException("Backwards branch with an uninitialized object in the local variables detected.");
}
// Even harder, what about _different_ uninitialized object types?!
if ( (!(locals[i].equals(lv.locals[i]))) && (locals[i] instanceof UninitializedObjectType) && (lv.locals[i] instanceof UninitializedObjectType) ){
throw new StructuralCodeConstraintException("Backwards branch with an uninitialized object in the local variables detected.");
}
// If we just didn't know that it was initialized, we have now learned.
if (locals[i] instanceof UninitializedObjectType){
if (! (lv.locals[i] instanceof UninitializedObjectType)){
locals[i] = ((UninitializedObjectType) locals[i]).getInitialized();
}
}
if ((locals[i] instanceof ReferenceType) && (lv.locals[i] instanceof ReferenceType)){
if (! locals[i].equals(lv.locals[i])){ // needed in case of two UninitializedObjectType instances
Type sup = ((ReferenceType) locals[i]).firstCommonSuperclass((ReferenceType) (lv.locals[i]));
if (sup != null){
locals[i] = sup;
}
else{
// We should have checked this in Pass2!
throw new AssertionViolatedException("Could not load all the super classes of '"+locals[i]+"' and '"+lv.locals[i]+"'.");
}
}
}
else{
if (! (locals[i].equals(lv.locals[i])) ){
/*TODO
if ((locals[i] instanceof com.sun.org.apache.bcel.internal.generic.ReturnaddressType) && (lv.locals[i] instanceof com.sun.org.apache.bcel.internal.generic.ReturnaddressType)){
//System.err.println("merging "+locals[i]+" and "+lv.locals[i]);
throw new AssertionViolatedException("Merging different ReturnAddresses: '"+locals[i]+"' and '"+lv.locals[i]+"'.");
}
*/
locals[i] = Type.UNKNOWN;
}
}
|
public void | set(int i, com.sun.org.apache.bcel.internal.generic.Type type)Sets a new Type for the given local variable slot.
if (type == Type.BYTE || type == Type.SHORT || type == Type.BOOLEAN || type == Type.CHAR){
throw new AssertionViolatedException("LocalVariables do not know about '"+type+"'. Use Type.INT instead.");
}
locals[i] = type;
|
public java.lang.String | toString()Returns a String representation of this object.
String s = new String();
for (int i=0; i<locals.length; i++){
s += Integer.toString(i)+": "+locals[i]+"\n";
}
return s;
|