Minor. Simplified code in KotlinBuiltIns.
This commit is contained in:
@@ -32,7 +32,6 @@ import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
|||||||
import org.jetbrains.jet.lang.types.*;
|
import org.jetbrains.jet.lang.types.*;
|
||||||
import org.jetbrains.jet.storage.LockBasedStorageManager;
|
import org.jetbrains.jet.storage.LockBasedStorageManager;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static org.jetbrains.jet.lang.types.lang.PrimitiveType.*;
|
import static org.jetbrains.jet.lang.types.lang.PrimitiveType.*;
|
||||||
@@ -94,6 +93,7 @@ public class KotlinBuiltIns {
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
private final ModuleDescriptorImpl builtInsModule;
|
private final ModuleDescriptorImpl builtInsModule;
|
||||||
|
private final BuiltinsPackageFragment builtinsPackageFragment;
|
||||||
|
|
||||||
private volatile ImmutableSet<ClassDescriptor> nonPhysicalClasses;
|
private volatile ImmutableSet<ClassDescriptor> nonPhysicalClasses;
|
||||||
|
|
||||||
@@ -124,40 +124,31 @@ public class KotlinBuiltIns {
|
|||||||
private volatile JetType annotationType;
|
private volatile JetType annotationType;
|
||||||
|
|
||||||
private KotlinBuiltIns() {
|
private KotlinBuiltIns() {
|
||||||
try {
|
this.builtInsModule = new ModuleDescriptorImpl(Name.special("<built-ins lazy module>"),
|
||||||
this.builtInsModule = new ModuleDescriptorImpl(Name.special("<built-ins lazy module>"),
|
Collections.<ImportPath>emptyList(),
|
||||||
Collections.<ImportPath>emptyList(),
|
PlatformToKotlinClassMap.EMPTY);
|
||||||
PlatformToKotlinClassMap.EMPTY);
|
builtinsPackageFragment = new BuiltinsPackageFragment(new LockBasedStorageManager(), builtInsModule);
|
||||||
loadBuiltIns(builtInsModule);
|
builtInsModule.addFragmentProvider(builtinsPackageFragment.packageFragmentProvider);
|
||||||
|
|
||||||
this.functionClassesSet = computeIndexedClasses("Function", FUNCTION_TRAIT_COUNT);
|
this.functionClassesSet = computeIndexedClasses("Function", FUNCTION_TRAIT_COUNT);
|
||||||
this.extensionFunctionClassesSet = computeIndexedClasses("ExtensionFunction", FUNCTION_TRAIT_COUNT);
|
this.extensionFunctionClassesSet = computeIndexedClasses("ExtensionFunction", FUNCTION_TRAIT_COUNT);
|
||||||
|
|
||||||
this.primitiveTypeToClass = new EnumMap<PrimitiveType, ClassDescriptor>(PrimitiveType.class);
|
this.primitiveTypeToClass = new EnumMap<PrimitiveType, ClassDescriptor>(PrimitiveType.class);
|
||||||
this.primitiveTypeToJetType = new EnumMap<PrimitiveType, JetType>(PrimitiveType.class);
|
this.primitiveTypeToJetType = new EnumMap<PrimitiveType, JetType>(PrimitiveType.class);
|
||||||
this.primitiveTypeToNullableJetType = new EnumMap<PrimitiveType, JetType>(PrimitiveType.class);
|
this.primitiveTypeToNullableJetType = new EnumMap<PrimitiveType, JetType>(PrimitiveType.class);
|
||||||
this.primitiveTypeToArrayClass = new EnumMap<PrimitiveType, ClassDescriptor>(PrimitiveType.class);
|
this.primitiveTypeToArrayClass = new EnumMap<PrimitiveType, ClassDescriptor>(PrimitiveType.class);
|
||||||
this.primitiveTypeToArrayJetType = new EnumMap<PrimitiveType, JetType>(PrimitiveType.class);
|
this.primitiveTypeToArrayJetType = new EnumMap<PrimitiveType, JetType>(PrimitiveType.class);
|
||||||
this.primitiveJetTypeToJetArrayType = new HashMap<JetType, JetType>();
|
this.primitiveJetTypeToJetArrayType = new HashMap<JetType, JetType>();
|
||||||
this.jetArrayTypeToPrimitiveJetType = new HashMap<JetType, JetType>();
|
this.jetArrayTypeToPrimitiveJetType = new HashMap<JetType, JetType>();
|
||||||
|
|
||||||
this.nothingClass = getBuiltInClassByName("Nothing");
|
this.nothingClass = getBuiltInClassByName("Nothing");
|
||||||
this.arrayClass = getBuiltInClassByName("Array");
|
this.arrayClass = getBuiltInClassByName("Array");
|
||||||
this.deprecatedAnnotationClass = getBuiltInClassByName("deprecated");
|
this.deprecatedAnnotationClass = getBuiltInClassByName("deprecated");
|
||||||
this.dataAnnotationClass = getBuiltInClassByName("data");
|
this.dataAnnotationClass = getBuiltInClassByName("data");
|
||||||
this.functionClasses = new ClassDescriptor[FUNCTION_TRAIT_COUNT];
|
this.functionClasses = new ClassDescriptor[FUNCTION_TRAIT_COUNT];
|
||||||
for (int i = 0; i < functionClasses.length; i++) {
|
for (int i = 0; i < functionClasses.length; i++) {
|
||||||
functionClasses[i] = getBuiltInClassByName("Function" + i);
|
functionClasses[i] = getBuiltInClassByName("Function" + i);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
|
||||||
throw new IllegalStateException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void loadBuiltIns(@NotNull ModuleDescriptorImpl module) throws IOException {
|
|
||||||
BuiltinsPackageFragment builtinsPackageFragment = new BuiltinsPackageFragment(new LockBasedStorageManager(), module);
|
|
||||||
module.addFragmentProvider(builtinsPackageFragment.packageFragmentProvider);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doInitialize() {
|
private void doInitialize() {
|
||||||
@@ -200,12 +191,12 @@ public class KotlinBuiltIns {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public PackageFragmentDescriptor getBuiltInsPackageFragment() {
|
public PackageFragmentDescriptor getBuiltInsPackageFragment() {
|
||||||
return builtInsModule.getPackageFragmentProvider().getPackageFragments(BUILT_INS_PACKAGE_FQ_NAME).get(0);
|
return builtinsPackageFragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetScope getBuiltInsPackageScope() {
|
public JetScope getBuiltInsPackageScope() {
|
||||||
return getBuiltInsPackageFragment().getMemberScope();
|
return builtinsPackageFragment.getMemberScope();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
Reference in New Issue
Block a user