< prev index next >

test/testlibrary/jittester/src/jdk/test/lib/jittester/TypeList.java

Print this page




  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 package jdk.test.lib.jittester;
  25 
  26 import java.util.ArrayList;
  27 import java.util.Collection;
  28 import java.util.List;
  29 import java.util.function.Predicate;
  30 import jdk.test.lib.jittester.types.TypeArray;
  31 import jdk.test.lib.jittester.types.TypeBoolean;
  32 import jdk.test.lib.jittester.types.TypeByte;
  33 import jdk.test.lib.jittester.types.TypeChar;
  34 import jdk.test.lib.jittester.types.TypeDouble;
  35 import jdk.test.lib.jittester.types.TypeFloat;
  36 import jdk.test.lib.jittester.types.TypeInt;

  37 import jdk.test.lib.jittester.types.TypeLong;
  38 import jdk.test.lib.jittester.types.TypeShort;
  39 import jdk.test.lib.jittester.types.TypeVoid;
  40 
  41 public class TypeList {
  42     private static final TypeVoid TYPE_VOID = new TypeVoid();











  43     private static final List<Type> TYPES = new ArrayList<>();
  44     private static final List<Type> BUILTIN_TYPES = new ArrayList<>();
  45     private static final List<Type> BUILTIN_INT_TYPES = new ArrayList<>();
  46     private static final List<Type> BUILTIN_FP_TYPES = new ArrayList<>();
  47     private static final List<Type> REFERENCE_TYPES = new ArrayList<>();
  48 
  49     static {
  50         BUILTIN_INT_TYPES.add(new TypeBoolean());
  51         BUILTIN_INT_TYPES.add(new TypeByte());
  52         BUILTIN_INT_TYPES.add(new TypeChar());
  53         BUILTIN_INT_TYPES.add(new TypeShort());
  54         BUILTIN_INT_TYPES.add(new TypeInt());
  55         BUILTIN_INT_TYPES.add(new TypeLong());
  56         BUILTIN_FP_TYPES.add(new TypeFloat());
  57         BUILTIN_FP_TYPES.add(new TypeDouble());
  58 
  59         BUILTIN_TYPES.addAll(BUILTIN_INT_TYPES);
  60         BUILTIN_TYPES.addAll(BUILTIN_FP_TYPES);
  61 
  62         TYPES.addAll(BUILTIN_TYPES);
  63 
  64         if (!ProductionParams.disableArrays.value()) {
  65             REFERENCE_TYPES.add(new TypeArray().produce());
  66             TYPES.addAll(REFERENCE_TYPES);
  67         }
  68     }
  69 
  70     public static TypeVoid getVoid() {
  71         return TYPE_VOID;


  72     }
  73 
  74     public static Collection<Type> getAll() {
  75         return TYPES;
  76     }
  77 
  78     public static Collection<Type> getBuiltIn() {
  79         return BUILTIN_TYPES;
  80     }
  81 
  82     public static Collection<Type> getBuiltInInt() {
  83         return BUILTIN_INT_TYPES;
  84     }
  85 
  86     protected static Collection<Type> getBuiltInFP() {
  87         return BUILTIN_FP_TYPES;
  88     }
  89 
  90     protected static Collection<Type> getReferenceTypes() {
  91         return REFERENCE_TYPES;
  92     }
  93 
  94     protected static boolean isBuiltInFP(Type t) {
  95         return BUILTIN_FP_TYPES.contains(t);
  96     }
  97 
  98     public static boolean isBuiltInInt(Type t) {
  99         return BUILTIN_INT_TYPES.contains(t);
 100     }
 101 
 102     public static boolean isBuiltIn(Type t) {
 103         return isBuiltInInt(t) || isBuiltInFP(t);
 104     }
 105 
 106     protected static boolean isIn(Type t) {
 107         return TYPES.contains(t);
 108     }
 109 
 110     protected static boolean isReferenceType(Type t) {
 111         return REFERENCE_TYPES.contains(t);
 112     }
 113 
 114     public static Type find(Type t) {
 115         int i = TYPES.indexOf(t);
 116         if (i != -1) {
 117             return TYPES.get(i);
 118         }
 119         return null;
 120     }
 121 
 122     protected static Type findReferenceType(Type t) {
 123         int i = REFERENCE_TYPES.indexOf(t);
 124         if (i != -1) {
 125             return REFERENCE_TYPES.get(i);
 126         }
 127         return null;
 128     }
 129 
 130     public static Type find(String name) {




  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 package jdk.test.lib.jittester;
  25 
  26 import java.util.ArrayList;
  27 import java.util.Collection;
  28 import java.util.List;
  29 import java.util.function.Predicate;
  30 
  31 import jdk.test.lib.jittester.types.TypeBoolean;
  32 import jdk.test.lib.jittester.types.TypeByte;
  33 import jdk.test.lib.jittester.types.TypeChar;
  34 import jdk.test.lib.jittester.types.TypeDouble;
  35 import jdk.test.lib.jittester.types.TypeFloat;
  36 import jdk.test.lib.jittester.types.TypeInt;
  37 import jdk.test.lib.jittester.types.TypeKlass;
  38 import jdk.test.lib.jittester.types.TypeLong;
  39 import jdk.test.lib.jittester.types.TypeShort;
  40 import jdk.test.lib.jittester.types.TypeVoid;
  41 
  42 public class TypeList {
  43     public static final TypeVoid VOID = new TypeVoid();
  44     public static final TypeBoolean BOOLEAN = new TypeBoolean();
  45     public static final TypeByte BYTE = new TypeByte();
  46     public static final TypeChar CHAR = new TypeChar();
  47     public static final TypeShort SHORT = new TypeShort();
  48     public static final TypeInt INT = new TypeInt();
  49     public static final TypeLong LONG = new TypeLong();
  50     public static final TypeFloat FLOAT = new TypeFloat();
  51     public static final TypeDouble DOUBLE = new TypeDouble();
  52     public static final TypeKlass OBJECT = new TypeKlass("java.lang.Object");
  53     public static final TypeKlass STRING = new TypeKlass("java.lang.String", TypeKlass.FINAL);
  54 
  55     private static final List<Type> TYPES = new ArrayList<>();
  56     private static final List<Type> BUILTIN_TYPES = new ArrayList<>();
  57     private static final List<Type> BUILTIN_INT_TYPES = new ArrayList<>();
  58     private static final List<Type> BUILTIN_FP_TYPES = new ArrayList<>();
  59     private static final List<Type> REFERENCE_TYPES = new ArrayList<>();
  60 
  61     static {
  62         BUILTIN_INT_TYPES.add(BOOLEAN);
  63         BUILTIN_INT_TYPES.add(BYTE);
  64         BUILTIN_INT_TYPES.add(CHAR);
  65         BUILTIN_INT_TYPES.add(SHORT);
  66         BUILTIN_INT_TYPES.add(INT);
  67         BUILTIN_INT_TYPES.add(LONG);
  68         BUILTIN_FP_TYPES.add(FLOAT);
  69         BUILTIN_FP_TYPES.add(DOUBLE);
  70 
  71         BUILTIN_TYPES.addAll(BUILTIN_INT_TYPES);
  72         BUILTIN_TYPES.addAll(BUILTIN_FP_TYPES);
  73 
  74         TYPES.addAll(BUILTIN_TYPES);
  75 
  76         if (!ProductionParams.disableArrays.value()) {

  77             TYPES.addAll(REFERENCE_TYPES);
  78         }

  79 
  80         STRING.addParent(OBJECT.getName());
  81         STRING.setParent(OBJECT);
  82         add(STRING);
  83         add(OBJECT);
  84     }
  85 
  86     public static Collection<Type> getAll() {
  87         return TYPES;
  88     }
  89 
  90     public static Collection<Type> getBuiltIn() {
  91         return BUILTIN_TYPES;
  92     }
  93 
  94     public static Collection<Type> getBuiltInInt() {
  95         return BUILTIN_INT_TYPES;
  96     }
  97 
  98     protected static Collection<Type> getBuiltInFP() {
  99         return BUILTIN_FP_TYPES;
 100     }
 101 
 102     protected static Collection<Type> getReferenceTypes() {
 103         return REFERENCE_TYPES;
 104     }
 105 
 106     protected static boolean isBuiltInFP(Type t) {
 107         return BUILTIN_FP_TYPES.contains(t);
 108     }
 109 
 110     public static boolean isBuiltInInt(Type t) {
 111         return BUILTIN_INT_TYPES.contains(t);
 112     }
 113 
 114     public static boolean isBuiltIn(Type t) {
 115         return isBuiltInInt(t) || isBuiltInFP(t) || t.equals(VOID);
 116     }
 117 
 118     protected static boolean isIn(Type t) {
 119         return TYPES.contains(t);
 120     }
 121 
 122     public static boolean isReferenceType(Type t) {
 123         return REFERENCE_TYPES.contains(t);
 124     }
 125 
 126     public static Type find(Type t) {
 127         int i = TYPES.indexOf(t);
 128         if (i != -1) {
 129             return TYPES.get(i);
 130         }
 131         return null;
 132     }
 133 
 134     protected static Type findReferenceType(Type t) {
 135         int i = REFERENCE_TYPES.indexOf(t);
 136         if (i != -1) {
 137             return REFERENCE_TYPES.get(i);
 138         }
 139         return null;
 140     }
 141 
 142     public static Type find(String name) {


< prev index next >