Refactor creation of ModuleDescriptor

Add storageManager to ModuleDescriptorImpl (to be used later)
Extract ModuleParameters to hold default imports and platform class map
Introduce MutableModuleContext to simplify module creation code
This commit is contained in:
Pavel V. Talanov
2015-05-19 16:34:31 +03:00
parent 6a3cb0eff8
commit cfdb1f4ec3
30 changed files with 304 additions and 234 deletions
@@ -20,11 +20,14 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.builtins.ReflectionTypes;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl;
import org.jetbrains.kotlin.descriptors.impl.MutableClassDescriptor;
import org.jetbrains.kotlin.descriptors.impl.MutablePackageFragmentDescriptor;
import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.resolve.jvm.TopDownAnalyzerFacadeForJVM;
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
import org.jetbrains.kotlin.types.*;
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils;
@@ -34,7 +37,6 @@ import java.util.Collection;
import java.util.List;
import static org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilPackage.getBuiltIns;
import static org.jetbrains.kotlin.resolve.jvm.TopDownAnalyzerFacadeForJVM.createJavaModule;
public class JvmRuntimeTypes {
private final ReflectionTypes reflectionTypes;
@@ -46,10 +48,10 @@ public class JvmRuntimeTypes {
public JvmRuntimeTypes(@NotNull ReflectionTypes reflectionTypes) {
this.reflectionTypes = reflectionTypes;
PackageFragmentDescriptor kotlinJvmInternal = new MutablePackageFragmentDescriptor(
createJavaModule("<jvm functions impl>"),
new FqName("kotlin.jvm.internal")
);
ModuleDescriptorImpl module = new ModuleDescriptorImpl(Name.special("<jvm functions impl>"),
LockBasedStorageManager.NO_LOCKS,
TopDownAnalyzerFacadeForJVM.JVM_MODULE_PARAMETERS);
PackageFragmentDescriptor kotlinJvmInternal = new MutablePackageFragmentDescriptor(module, new FqName("kotlin.jvm.internal"));
this.functionImpl = createClass(kotlinJvmInternal, "FunctionImpl", "out R");
this.memberFunctionImpl = createClass(kotlinJvmInternal, "MemberFunctionImpl", "in T", "out R");