Пример #1
0
  private void makePrimitive(@NotNull PrimitiveType primitiveType) {
    KotlinType type = getBuiltInTypeByClassName(primitiveType.getTypeName().asString());
    KotlinType arrayType = getBuiltInTypeByClassName(primitiveType.getArrayTypeName().asString());

    primitiveTypeToArrayKotlinType.put(primitiveType, arrayType);
    primitiveKotlinTypeToKotlinArrayType.put(type, arrayType);
    kotlinArrayTypeToPrimitiveKotlinType.put(arrayType, type);
  }
Пример #2
0
 {
   fqNameToPrimitiveType = new HashMap<FqNameUnsafe, PrimitiveType>(0);
   arrayClassFqNameToPrimitiveType = new HashMap<FqNameUnsafe, PrimitiveType>(0);
   for (PrimitiveType primitiveType : PrimitiveType.values()) {
     fqNameToPrimitiveType.put(
         fqNameUnsafe(primitiveType.getTypeName().asString()), primitiveType);
     arrayClassFqNameToPrimitiveType.put(
         fqNameUnsafe(primitiveType.getArrayTypeName().asString()), primitiveType);
   }
 }
Пример #3
0
  protected KotlinBuiltIns() {
    LockBasedStorageManager storageManager = new LockBasedStorageManager();
    builtInsModule =
        new ModuleDescriptorImpl(
            Name.special("<built-ins module>"),
            storageManager,
            ModuleParameters.Empty.INSTANCE,
            this);

    PackageFragmentProvider packageFragmentProvider =
        BuiltInsPackageFragmentProviderKt.createBuiltInPackageFragmentProvider(
            storageManager,
            builtInsModule,
            BUILT_INS_PACKAGE_FQ_NAMES,
            new BuiltInFictitiousFunctionClassFactory(storageManager, builtInsModule),
            getAdditionalSupertypesProvider(),
            new Function1<String, InputStream>() {
              @Override
              public InputStream invoke(String path) {
                return KotlinBuiltIns.class.getClassLoader().getResourceAsStream(path);
              }
            });

    builtInsModule.initialize(packageFragmentProvider);
    builtInsModule.setDependencies(builtInsModule);

    builtinsPackageFragment =
        (BuiltinsPackageFragment)
            single(packageFragmentProvider.getPackageFragments(BUILT_INS_PACKAGE_FQ_NAME));
    annotationPackageFragment =
        (BuiltinsPackageFragment)
            single(packageFragmentProvider.getPackageFragments(ANNOTATION_PACKAGE_FQ_NAME));

    primitiveTypeToArrayKotlinType = new EnumMap<PrimitiveType, KotlinType>(PrimitiveType.class);
    primitiveKotlinTypeToKotlinArrayType = new HashMap<KotlinType, KotlinType>();
    kotlinArrayTypeToPrimitiveKotlinType = new HashMap<KotlinType, KotlinType>();
    for (PrimitiveType primitive : PrimitiveType.values()) {
      makePrimitive(primitive);
    }
  }
Пример #4
0
 @NotNull
 public ClassDescriptor getPrimitiveArrayClassDescriptor(@NotNull PrimitiveType type) {
   return getBuiltInClassByName(type.getArrayTypeName().asString());
 }