new types of integer constants

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@361 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent 633f044a20
commit 1fecd60496
  1. 19
      jode/jode/bytecode/ConstantPool.java

@ -133,16 +133,7 @@ public class ConstantPool {
if (i == 0) if (i == 0)
throw new ClassFormatException("null constant"); throw new ClassFormatException("null constant");
switch(tags[i]) { switch(tags[i]) {
case INTEGER: { case INTEGER: return Type.tInt;
int value = ((Integer)constants[i]).intValue();
return ((value < Short.MIN_VALUE || value > Character.MAX_VALUE)
? Type.tInt
: (value < Byte.MIN_VALUE || value > Byte.MAX_VALUE)
? Type.tRange(Type.tInt, Type.tChar)
: (value == 0 || value == 1)
? Type.tBoolInt
: Type.tUInt);
}
case FLOAT : return Type.tFloat ; case FLOAT : return Type.tFloat ;
case LONG : return Type.tLong ; case LONG : return Type.tLong ;
case DOUBLE : return Type.tDouble; case DOUBLE : return Type.tDouble;
@ -193,6 +184,12 @@ public class ConstantPool {
return result.append("\"").toString(); return result.append("\"").toString();
} }
public int getConstantInt(int i) throws ClassFormatException {
if (i == 0 || tags[i] != ConstantPool.INTEGER)
throw new ClassFormatException("not an integer "+tags[i]);
return ((Integer)constants[i]).intValue();
}
public String getConstantString(int i) throws ClassFormatException { public String getConstantString(int i) throws ClassFormatException {
if (i == 0) if (i == 0)
throw new ClassFormatException("null constant"); throw new ClassFormatException("null constant");
@ -205,7 +202,7 @@ public class ConstantPool {
case ConstantPool.STRING: case ConstantPool.STRING:
return quoted(getUTF8(indices1[i])); return quoted(getUTF8(indices1[i]));
} }
throw new ClassFormatException("unknown constant tag"); throw new ClassFormatException("unknown constant tag: "+tags[i]);
} }
public String getClassName(int i) throws ClassFormatException { public String getClassName(int i) throws ClassFormatException {

Loading…
Cancel
Save