--- /dev/null
+/*\r
+\r
+ Derby - Class org.apache.derby.impl.services.bytecode.Type\r
+\r
+ Licensed to the Apache Software Foundation (ASF) under one or more\r
+ contributor license agreements. See the NOTICE file distributed with\r
+ this work for additional information regarding copyright ownership.\r
+ The ASF licenses this file to you under the Apache License, Version 2.0\r
+ (the "License"); you may not use this file except in compliance with\r
+ the License. You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+\r
+ */\r
+\r
+package org.apache.derby.impl.services.bytecode;\r
+\r
+import org.apache.derby.iapi.services.classfile.VMDescriptor;\r
+import org.apache.derby.iapi.services.classfile.ClassHolder;\r
+\r
+final class Type {\r
+\r
+ static final Type LONG = new Type("long", VMDescriptor.LONG);\r
+ static final Type INT = new Type("int", VMDescriptor.INT);\r
+ static final Type SHORT = new Type("short", VMDescriptor.SHORT);\r
+ static final Type BYTE = new Type("byte", VMDescriptor.BYTE);\r
+ static final Type BOOLEAN = new Type("boolean", VMDescriptor.BOOLEAN);\r
+ static final Type FLOAT = new Type("float", VMDescriptor.FLOAT);\r
+ static final Type DOUBLE = new Type("double", VMDescriptor.DOUBLE);\r
+ static final Type STRING = new Type("java.lang.String", "Ljava/lang/String;");\r
+\r
+ private final String javaName; // e.g. java.lang.Object\r
+ private final short vmType; // e.g. BCExpr.vm_reference\r
+ private final String vmName; // e.g. Ljava/lang/Object;\r
+ final String vmNameSimple; // e.g. java/lang/Object\r
+\r
+ Type(String javaName, String vmName) {\r
+ this.vmName = vmName;\r
+ this.javaName = javaName;\r
+ vmType = BCJava.vmTypeId(vmName);\r
+ vmNameSimple = ClassHolder.convertToInternalClassName(javaName);\r
+ }\r
+\r
+ /*\r
+ ** Class specific methods.\r
+ */\r
+ \r
+ String javaName() {\r
+ return javaName;\r
+ }\r
+\r
+ /**\r
+ * Get the VM Type name (java/lang/Object)\r
+ */\r
+ String vmName() {\r
+ return vmName;\r
+ }\r
+ /**\r
+ Get the VM type (eg. VMDescriptor.INT)\r
+ */\r
+ short vmType() {\r
+ return vmType;\r
+ }\r
+\r
+ int width() {\r
+ return Type.width(vmType);\r
+ }\r
+\r
+ static int width(short type) {\r
+ switch (type) {\r
+ case BCExpr.vm_void:\r
+ return 0;\r
+ case BCExpr.vm_long:\r
+ case BCExpr.vm_double:\r
+ return 2;\r
+ default:\r
+ return 1;\r
+ }\r
+ }\r
+}\r