Delete JvmPrimitiveType.getAsmType()

Create PrimitiveTypesUtil in frontend.java for this and other utilities
This commit is contained in:
Alexander Udalov
2013-09-30 16:25:22 +04:00
parent 18df0de2d5
commit 521496b188
5 changed files with 68 additions and 30 deletions
@@ -33,6 +33,8 @@ import org.jetbrains.jet.lang.types.lang.PrimitiveType;
import java.util.HashMap;
import java.util.Map;
import static org.jetbrains.jet.lang.resolve.java.mapping.PrimitiveTypesUtil.asmTypeForPrimitive;
public class KotlinToJavaTypesMap extends JavaToKotlinClassMapBuilder {
private static KotlinToJavaTypesMap instance = null;
@@ -56,7 +58,7 @@ public class KotlinToJavaTypesMap extends JavaToKotlinClassMapBuilder {
FqName builtInsFqName = KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME;
for (JvmPrimitiveType jvmPrimitiveType : JvmPrimitiveType.values()) {
PrimitiveType primitiveType = jvmPrimitiveType.getPrimitiveType();
Type asmType = jvmPrimitiveType.getAsmType();
Type asmType = asmTypeForPrimitive(jvmPrimitiveType);
FqName fqName = builtInsFqName.child(primitiveType.getTypeName());
register(fqName, asmType);
@@ -0,0 +1,42 @@
/*
* Copyright 2010-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.lang.resolve.java.mapping;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.asm4.Type;
import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType;
import static org.jetbrains.asm4.Type.*;
public class PrimitiveTypesUtil {
private PrimitiveTypesUtil() {
}
public static Type asmTypeForPrimitive(@NotNull JvmPrimitiveType jvmPrimitiveType) {
switch (jvmPrimitiveType) {
case BOOLEAN: return BOOLEAN_TYPE;
case CHAR: return CHAR_TYPE;
case BYTE: return BYTE_TYPE;
case SHORT: return SHORT_TYPE;
case INT: return INT_TYPE;
case FLOAT: return FLOAT_TYPE;
case LONG: return LONG_TYPE;
case DOUBLE: return DOUBLE_TYPE;
default: throw new IllegalStateException("Unknown primitive type: " + jvmPrimitiveType);
}
}
}