001/* 002 * Copyright 2010-2013 JetBrains s.r.o. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.jetbrains.jet.lang.resolve.java; 018 019import com.google.common.collect.Maps; 020import org.jetbrains.annotations.NotNull; 021import org.jetbrains.asm4.Type; 022 023import java.util.Map; 024 025public class AsmTypeConstants { 026 private static final Map<Class<?>, Type> TYPES_MAP = Maps.newHashMap(); 027 028 public static final Type OBJECT_TYPE = getType(Object.class); 029 public static final Type JAVA_STRING_TYPE = getType(String.class); 030 public static final Type JAVA_THROWABLE_TYPE = getType(Throwable.class); 031 public static final Type JAVA_ARRAY_GENERIC_TYPE = getType(Object[].class); 032 033 public static final Type JET_NOTHING_TYPE = Type.getObjectType("jet/Nothing"); 034 public static final Type JET_UNIT_TYPE = Type.getObjectType("jet/Unit"); 035 public static final Type JET_FUNCTION0_TYPE = Type.getObjectType("jet/Function0"); 036 public static final Type JET_FUNCTION1_TYPE = Type.getObjectType("jet/Function1"); 037 public static final Type JET_ITERATOR_TYPE = Type.getObjectType("jet/Iterator"); 038 public static final Type JET_INT_RANGE_TYPE = Type.getObjectType("jet/IntRange"); 039 public static final Type JET_SHARED_VAR_TYPE = Type.getObjectType("jet/runtime/SharedVar$Object"); 040 public static final Type JET_SHARED_INT_TYPE = Type.getObjectType("jet/runtime/SharedVar$Int"); 041 public static final Type JET_SHARED_DOUBLE_TYPE = Type.getObjectType("jet/runtime/SharedVar$Double"); 042 public static final Type JET_SHARED_FLOAT_TYPE = Type.getObjectType("jet/runtime/SharedVar$Float"); 043 public static final Type JET_SHARED_BYTE_TYPE = Type.getObjectType("jet/runtime/SharedVar$Byte"); 044 public static final Type JET_SHARED_SHORT_TYPE = Type.getObjectType("jet/runtime/SharedVar$Short"); 045 public static final Type JET_SHARED_CHAR_TYPE = Type.getObjectType("jet/runtime/SharedVar$Char"); 046 public static final Type JET_SHARED_LONG_TYPE = Type.getObjectType("jet/runtime/SharedVar$Long"); 047 public static final Type JET_SHARED_BOOLEAN_TYPE = Type.getObjectType("jet/runtime/SharedVar$Boolean"); 048 049 050 public static Type getType(@NotNull Class<?> javaClass) { 051 Type type = TYPES_MAP.get(javaClass); 052 if (type == null) { 053 type = Type.getType(javaClass); 054 TYPES_MAP.put(javaClass, type); 055 } 056 return type; 057 } 058 059 private AsmTypeConstants() { 060 } 061}