Methods Summary |
---|
public java.lang.String | argTypes()
switch (opcode()) {
case opc_putstatic:
case opc_putfield:
{
ConstFieldRef fld = (ConstFieldRef) constValue;
String sig = fld.nameAndType().signature().asString();
if (opcode() == opc_putstatic)
return sig;
else
return descriptorTypeOfObject(fld) + sig;
}
case opc_invokevirtual:
case opc_invokespecial:
case opc_invokestatic:
/* handle interface invoke too */
case opc_invokeinterface:
{
ConstBasicMemberRef meth = (ConstBasicMemberRef) constValue;
String argSig =
Descriptor.extractArgSig(meth.nameAndType().signature().asString());
if (opcode() == opc_invokestatic)
return argSig;
else
return descriptorTypeOfObject(meth) + argSig;
}
default:
return VMOp.ops[opcode()].argTypes();
}
|
public boolean | branches()
/* invokes don't count as a branch */
return false;
|
private void | checkConstant(ConstBasic operand)
switch(opcode()) {
case opc_ldc:
case opc_ldc_w:
case opc_ldc2_w:
/* ConstValue */
if (operand == null ||
(! (operand instanceof ConstValue)))
throw new InsnError ("attempt to create an " + opName(opcode()) +//NOI18N
" without a ConstValue operand");//NOI18N
break;
case opc_getstatic:
case opc_putstatic:
case opc_getfield:
case opc_putfield:
/* ConstFieldRef */
if (operand == null ||
(! (operand instanceof ConstFieldRef)))
throw new InsnError ("attempt to create an " + opName(opcode()) +//NOI18N
" without a ConstFieldRef operand");//NOI18N
break;
case opc_invokevirtual:
case opc_invokespecial:
case opc_invokestatic:
/* ConstMethodRef */
if (operand == null ||
(! (operand instanceof ConstMethodRef)))
throw new InsnError ("attempt to create an " + opName(opcode()) +//NOI18N
" without a ConstMethodRef operand");//NOI18N
break;
case opc_invokeinterface:
/* ConstInterfaceMethodRef */
if (operand == null ||
(! (operand instanceof ConstInterfaceMethodRef)))
throw new InsnError("Attempt to create an " + opName(opcode()) +//NOI18N
" without a ConstInterfaceMethodRef operand");//NOI18N
break;
case opc_new:
case opc_anewarray:
case opc_checkcast:
case opc_instanceof:
/* ConstClass */
if (operand == null ||
(! (operand instanceof ConstClass)))
throw new InsnError ("attempt to create an " + opName(opcode()) +//NOI18N
" without a ConstClass operand");//NOI18N
break;
default:
throw new InsnError ("attempt to create an " + opName(opcode()) +//NOI18N
" with a constant operand");//NOI18N
}
|
private final java.lang.String | descriptorTypeOfObject(ConstBasicMemberRef memRef)
String cname = memRef.className().className().asString();
return "L" + cname + ";";//NOI18N
|
private boolean | isNarrowldc()
return (opcode() == opc_ldc && constValue.getIndex() < 256);
|
public int | nStackArgs()
int n = VMOp.ops[opcode()].nStackArgs();
if (n >= 0)
return n;
switch (opcode()) {
case opc_putstatic:
case opc_putfield:
{
ConstFieldRef fld = (ConstFieldRef) constValue;
String sig = fld.nameAndType().signature().asString();
if (sig.equals("J") || sig.equals("D"))//NOI18N
return (opcode() == opc_putfield) ? 3 : 2;
return (opcode() == opc_putfield) ? 2 : 1;
}
case opc_invokevirtual:
case opc_invokespecial:
case opc_invokestatic:
/* handle interface invoke too */
case opc_invokeinterface:
{
ConstBasicMemberRef meth = (ConstBasicMemberRef) constValue;
String sig = meth.nameAndType().signature().asString();
int nMethodArgWords = Descriptor.countMethodArgWords(sig);
return nMethodArgWords +
((opcode() == opc_invokestatic) ? 0 : 1);
}
default:
throw new InsnError("unexpected variable opcode");//NOI18N
}
|
public int | nStackResults()
int n = VMOp.ops[opcode()].nStackResults();
if (n >= 0)
return n;
switch (opcode()) {
case opc_getstatic:
case opc_getfield:
{
ConstFieldRef fld = (ConstFieldRef) constValue;
String sig = fld.nameAndType().signature().asString();
if (sig.equals("J") || sig.equals("D"))//NOI18N
return 2;
return 1;
}
case opc_invokevirtual:
case opc_invokespecial:
case opc_invokestatic:
/* handle interface invoke too */
case opc_invokeinterface:
{
ConstBasicMemberRef meth = (ConstBasicMemberRef) constValue;
return Descriptor.countMethodReturnWords(
meth.nameAndType().signature().asString());
}
default:
throw new InsnError("unexpected variable opcode");//NOI18N
}
|
void | print(java.io.PrintStream out, int indent)
ClassPrint.spaces(out, indent);
out.println(offset() + " " + opName(opcode()) + " pool(" + //NOI18N
constValue.getIndex() + ")");//NOI18N
|
public java.lang.String | resultTypes()
switch (opcode()) {
case opc_invokevirtual:
case opc_invokespecial:
case opc_invokestatic:
/* handle interface invoke too */
case opc_invokeinterface:
{
ConstBasicMemberRef meth = (ConstBasicMemberRef) constValue;
String resultSig = Descriptor.extractResultSig(
meth.nameAndType().signature().asString());
if (resultSig.equals("V"))//NOI18N
return "";//NOI18N
return resultSig;
}
case opc_getstatic:
case opc_getfield:
{
ConstFieldRef fld = (ConstFieldRef) constValue;
return fld.nameAndType().signature().asString();
}
case opc_ldc:
case opc_ldc_w:
case opc_ldc2_w:
{
ConstValue constVal = (ConstValue) constValue;
return constVal.descriptor();
}
default:
return VMOp.ops[opcode()].resultTypes();
}
|
public void | setValue(ConstBasic newValue)Modify the referenced constant
checkConstant(newValue);
constValue = newValue;
|
int | size()
return isNarrowldc() ? 2 : 3;
|
int | store(byte[] buf, int index)
if (opcode() == opc_ldc && !isNarrowldc())
buf[index++] = (byte) opc_ldc_w;
else
buf[index++] = (byte) opcode();
int constIndex = constValue.getIndex();
if (size() == 3)
buf[index++] = (byte) (constIndex >> 8);
buf[index++] = (byte)(constIndex & 0xff);
return index;
|
public ConstBasic | value()Return the constant pool entry which is the immediate operand
return constValue;
|