Methods Summary |
---|
public void | countConstantReferences(boolean isRelocatable)
if (isRelocatable) {
// Is this the right thing??
for (int i = 0; i < locals.length; i++) {
locals[i].incReference();
}
for (int i = 0; i < stack.length; i++) {
stack[i].incReference();
}
}
|
public void | externalize(ConstantPool p)
// do nothing
|
private boolean[] | getBitmap(ConstantObject[] table)
int extra = 0;
// Count the actual number of values, since doubles and longs take up
// two slots
for (int i = 0; i < table.length; i++) {
if (table[i] instanceof SingleValueConstant) {
int value = ((SingleValueConstant)table[i]).value;
if (value == ITEM_Long || value == ITEM_Double) {
extra++;
}
}
}
boolean result[] = new boolean[table.length + extra];
extra = 0;
// Fill in the table
for (int i = 0; i < table.length; i++) {
if (table[i] instanceof SingleValueConstant) {
int value = ((SingleValueConstant)table[i]).value;
if (value == ITEM_Long || value == ITEM_Double) {
extra++;
} else if (value < 0 || value == ITEM_InitObject) {
result[i + extra] = true;
}
} else if (table[i] instanceof ClassConstant) {
result[i + extra] = true;
} else {
throw new RuntimeException("Unknown table type");
}
}
return result;
|
public boolean[] | getLocalsBitmap()
return getBitmap(locals);
|
public int | getOffset()
return offset;
|
public boolean[] | getStackBitmap()
return getBitmap(stack);
|
public int | getStackSize()
ConstantObject table[] = stack;
int extra = 0;
for (int i = 0; i < table.length; i++) {
if (table[i] instanceof SingleValueConstant) {
int value = ((SingleValueConstant)table[i]).value;
if (value == ITEM_Long || value == ITEM_Double) {
extra++;
}
}
}
return table.length + extra;
|
private ConstantObject[] | readOneTable(java.io.DataInput in, ConstantObject[] globals)
int length = in.readShort();
ConstantObject result[] = new ConstantObject[length];
for (int i = 0; i < length; i++) {
int tag = in.readByte();
switch(tag) {
case ITEM_Bogus:
case ITEM_Integer: case ITEM_Float:
case ITEM_Double: case ITEM_Long:
case ITEM_Null: case ITEM_InitObject:
// Small non-negative values represent the corresponding
// type.
result[i] = new SingleValueConstant(tag);
break;
case ITEM_Object:
result[i] = globals[in.readShort()];
break;
case ITEM_NewObject:
// This is a hack, but it's not really worth creating a new
// type to represent this. Negative numbers represent new
// objects.
result[i] = new SingleValueConstant(~in.readShort());
break;
default:
System.out.println("Unknown tag");
}
}
return result;
|
public int | writeData(java.io.DataOutput out)
out.writeShort(offset);
// Return the number of bytes that we've written
return 2 + writeData(out, locals) + writeData(out, stack);
|
public int | writeData(java.io.DataOutput out, ConstantObject[] table)
int count = 0;
out.writeShort(table.length);
count += 2;
for (int i = 0; i < table.length; i++) {
if (table[i] instanceof SingleValueConstant) {
int value = ((SingleValueConstant)table[i]).value;
if (value < 0) {
out.writeByte(ITEM_NewObject);
out.writeShort(~value);
count += 3;
} else {
out.writeShort(value);
count += 2;
}
} else if (table[i] instanceof ClassConstant) {
out.writeByte(ITEM_Object);
out.writeShort(((ClassConstant)table[i]).name.index);
count += 3;
}
}
return count;
|