From 7080788ef4edcc456ff9ac967fdead404ec3f0f7 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 12 Feb 1999 15:21:07 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@258 379699f6-c40d-0410-875b-85095c16579e --- jode/jode/type/RangeType.java | 17 +++++++++++++---- jode/jode/type/Type.java | 26 ++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/jode/jode/type/RangeType.java b/jode/jode/type/RangeType.java index 7be4b60..7c94fcc 100644 --- a/jode/jode/type/RangeType.java +++ b/jode/jode/type/RangeType.java @@ -82,14 +82,23 @@ public class RangeType extends Type { */ public void useType() { /* The topType will be printed */ - if (topType.isClassType() || bottomType == tUnknown) + if (topType.isClassType() || !bottomType.isValidType()) topType.useType(); else bottomType.useType(); } + /** + * Checks if we need to cast to a middle type, before we can cast from + * fromType to this type. + * @return the middle type, or null if it is not necessary. + */ + public Type getCastHelper(Type fromType) { + return topType.getCastHelper(fromType); + } + public String getTypeSignature() { - if (topType.isClassType() || bottomType == tUnknown) + if (topType.isClassType() || !bottomType.isValidType()) return topType.getTypeSignature(); else return bottomType.getTypeSignature(); @@ -99,14 +108,14 @@ public class RangeType extends Type { { if (jode.Decompiler.isTypeDebugging) return "<" + bottomType + "-" + topType + ">"; - if (topType.isClassType() || bottomType == tUnknown) + if (topType.isClassType() || !bottomType.isValidType()) return topType.toString(); else return bottomType.toString(); } public String getDefaultName() { - if (topType.isClassType() || bottomType == tUnknown) + if (topType.isClassType() || !bottomType.isValidType()) return topType.getDefaultName(); else return bottomType.getDefaultName(); diff --git a/jode/jode/type/Type.java b/jode/jode/type/Type.java index e815850..a22dfe2 100644 --- a/jode/jode/type/Type.java +++ b/jode/jode/type/Type.java @@ -48,7 +48,10 @@ import java.util.Hashtable; * * Note that tUnknown is no valid type, so we can replace * with - * with + * with ,
+ * + * Arrays extend Object and implement java.lang.Cloneable and + * java.io.Serializable, as defined in jls. * * The main operation on a type range is the intersection. To do this * on class ranges we need three more operations: specialization, @@ -85,7 +88,6 @@ public class Type { public static final int TC_RANGE = 103; public static final int TC_BOOLBYTE = 105; public static final int TC_BOOLINT = 106; - public static final int TC_UCLASS = 107; protected static JodeEnvironment env; @@ -143,6 +145,7 @@ public class Type { return tClass(type.substring(1, index)); } throw new AssertError("Unknown type signature: "+type); + } public static final Type tClass(String clazzname) { @@ -416,6 +419,25 @@ public class Type { return result; } + /** + * Checks if we need to cast to a middle type, before we can cast from + * fromType to this type. + * @return the middle type, or null if it is not necessary. + */ + public Type getCastHelper(Type fromType) { + return null; + } + + /** + * Checks if this type represents a valid type instead of a list + * of minimum types. + */ + public boolean isValidType() { + return typecode <= TC_DOUBLE + || typecode == TC_BOOLBYTE + || typecode == TC_BOOLINT; + } + /** * Checks if this type represents a class or an array of a class */