From 1fecd60496f8b89c15acf00792a10675ed17704e Mon Sep 17 00:00:00 2001 From: jochen Date: Thu, 11 Mar 1999 22:48:34 +0000 Subject: [PATCH] new types of integer constants git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@361 379699f6-c40d-0410-875b-85095c16579e --- jode/jode/bytecode/ConstantPool.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/jode/jode/bytecode/ConstantPool.java b/jode/jode/bytecode/ConstantPool.java index 85c0ced..c82b112 100644 --- a/jode/jode/bytecode/ConstantPool.java +++ b/jode/jode/bytecode/ConstantPool.java @@ -133,16 +133,7 @@ public class ConstantPool { if (i == 0) throw new ClassFormatException("null constant"); switch(tags[i]) { - case INTEGER: { - 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 INTEGER: return Type.tInt; case FLOAT : return Type.tFloat ; case LONG : return Type.tLong ; case DOUBLE : return Type.tDouble; @@ -193,6 +184,12 @@ public class ConstantPool { 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 { if (i == 0) throw new ClassFormatException("null constant"); @@ -205,7 +202,7 @@ public class ConstantPool { case ConstantPool.STRING: 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 {