Drop PrimitiveTypesUtil, store desc in JvmPrimitiveType

This commit is contained in:
Alexander Udalov
2015-02-24 15:11:52 +03:00
parent 27978a7e25
commit fca7a8c4a2
5 changed files with 24 additions and 64 deletions
@@ -32,8 +32,6 @@ import org.jetbrains.org.objectweb.asm.Type;
import java.util.HashMap;
import java.util.Map;
import static org.jetbrains.kotlin.resolve.jvm.types.PrimitiveTypesUtil.asmTypeForPrimitive;
public class KotlinToJavaTypesMap extends JavaToKotlinClassMapBuilder {
private static KotlinToJavaTypesMap instance = null;
@@ -56,18 +54,17 @@ public class KotlinToJavaTypesMap extends JavaToKotlinClassMapBuilder {
private void initPrimitives() {
FqName builtInsFqName = KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME;
for (JvmPrimitiveType jvmPrimitiveType : JvmPrimitiveType.values()) {
PrimitiveType primitiveType = jvmPrimitiveType.getPrimitiveType();
Type asmType = asmTypeForPrimitive(jvmPrimitiveType);
for (JvmPrimitiveType type : JvmPrimitiveType.values()) {
PrimitiveType primitiveType = type.getPrimitiveType();
FqName fqName = builtInsFqName.child(primitiveType.getTypeName());
register(fqName, asmType);
register(fqName, Type.getType(type.getDesc()));
FqName wrapperFqName = jvmPrimitiveType.getWrapperFqName();
FqName wrapperFqName = type.getWrapperFqName();
registerNullable(fqName, Type.getObjectType(JvmClassName.byFqNameWithoutInnerClasses(wrapperFqName).getInternalName()));
registerFqName(fqName, wrapperFqName);
register(builtInsFqName.child(primitiveType.getArrayTypeName()), Type.getType("[" + asmType.getDescriptor()));
register(builtInsFqName.child(primitiveType.getArrayTypeName()), Type.getType("[" + type.getDesc()));
}
}
@@ -1,42 +0,0 @@
/*
* Copyright 2010-2015 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.kotlin.resolve.jvm.types;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.resolve.jvm.JvmPrimitiveType;
import org.jetbrains.org.objectweb.asm.Type;
import static org.jetbrains.org.objectweb.asm.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);
}
}
}