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
017 package org.jetbrains.jet.lang.types.lang;
018
019 import com.google.common.collect.ImmutableSet;
020 import org.jetbrains.annotations.NotNull;
021 import org.jetbrains.jet.lang.resolve.name.FqName;
022 import org.jetbrains.jet.lang.resolve.name.Name;
023
024 public enum PrimitiveType {
025
026 BOOLEAN("Boolean"),
027 CHAR("Char"),
028 BYTE("Byte"),
029 SHORT("Short"),
030 INT("Int"),
031 FLOAT("Float"),
032 LONG("Long"),
033 DOUBLE("Double"),
034 ;
035
036 public static final ImmutableSet<PrimitiveType> NUMBER_TYPES = ImmutableSet.of(CHAR, BYTE, SHORT, INT, FLOAT, LONG, DOUBLE);
037
038 private final Name typeName;
039 private final Name arrayTypeName;
040 private final Name rangeTypeName;
041 private final FqName className;
042 private final FqName arrayClassName;
043 private final FqName rangeClassName;
044 private final FqName progressionClassName;
045
046 private PrimitiveType(String typeName) {
047 this.typeName = Name.identifier(typeName);
048 this.arrayTypeName = Name.identifier(typeName + "Array");
049 this.rangeTypeName = Name.identifier(typeName + "Range");
050 FqName builtInsPackageFqName = KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME;
051 this.className = builtInsPackageFqName.child(this.typeName);
052 this.arrayClassName = builtInsPackageFqName.child(this.arrayTypeName);
053 this.rangeClassName = builtInsPackageFqName.child(this.rangeTypeName);
054 this.progressionClassName = builtInsPackageFqName.child(Name.identifier(typeName + "Progression"));
055 }
056
057 @NotNull
058 public Name getTypeName() {
059 return typeName;
060 }
061
062 @NotNull
063 public Name getArrayTypeName() {
064 return arrayTypeName;
065 }
066
067 @NotNull
068 public Name getRangeTypeName() {
069 return rangeTypeName;
070 }
071
072 @NotNull
073 public FqName getClassName() {
074 return className;
075 }
076
077 @NotNull
078 public FqName getArrayClassName() {
079 return arrayClassName;
080 }
081
082 @NotNull
083 public FqName getRangeClassName() {
084 return rangeClassName;
085 }
086
087 @NotNull
088 public FqName getProgressionClassName() {
089 return progressionClassName;
090 }
091 }