Exemplo n.º 1
0
 public Map<String, ClassDescriptor> getPrimitiveWrappersClassDescriptorMap() {
   if (classDescriptorMap == null) {
     classDescriptorMap = new HashMap<String, ClassDescriptor>();
     for (JvmPrimitiveType jvmPrimitiveType : JvmPrimitiveType.values()) {
       PrimitiveType primitiveType = jvmPrimitiveType.getPrimitiveType();
       classDescriptorMap.put(
           jvmPrimitiveType.getWrapper().getFqName(),
           standardLibrary.getPrimitiveClassDescriptor(primitiveType));
     }
     classDescriptorMap.put("java.lang.String", standardLibrary.getString());
     classDescriptorMap.put("java.lang.CharSequence", standardLibrary.getCharSequence());
     classDescriptorMap.put("java.lang.Throwable", standardLibrary.getThrowable());
   }
   return classDescriptorMap;
 }
Exemplo n.º 2
0
 public Map<String, JetType> getClassTypesMap() {
   if (classTypesMap == null) {
     classTypesMap = new HashMap<String, JetType>();
     for (JvmPrimitiveType jvmPrimitiveType : JvmPrimitiveType.values()) {
       PrimitiveType primitiveType = jvmPrimitiveType.getPrimitiveType();
       classTypesMap.put(
           jvmPrimitiveType.getWrapper().getFqName(),
           standardLibrary.getNullablePrimitiveJetType(primitiveType));
     }
     classTypesMap.put("java.lang.Object", JetStandardClasses.getNullableAnyType());
     classTypesMap.put("java.lang.String", standardLibrary.getNullableStringType());
     classTypesMap.put("java.lang.CharSequence", standardLibrary.getNullableCharSequenceType());
     classTypesMap.put("java.lang.Throwable", standardLibrary.getThrowableType());
   }
   return classTypesMap;
 }
Exemplo n.º 3
0
 @Override
 public void setUp() throws Exception {
   super.setUp();
   library = JetStandardLibrary.getJetStandardLibrary(getProject());
   semanticServices = JetSemanticServices.createSemanticServices(library);
   descriptorResolver = semanticServices.getClassDescriptorResolver(JetTestUtils.DUMMY_TRACE);
 }
Exemplo n.º 4
0
 public Map<String, JetType> getPrimitiveTypesMap() {
   if (primitiveTypesMap == null) {
     primitiveTypesMap = new HashMap<String, JetType>();
     for (JvmPrimitiveType jvmPrimitiveType : JvmPrimitiveType.values()) {
       PrimitiveType primitiveType = jvmPrimitiveType.getPrimitiveType();
       primitiveTypesMap.put(
           jvmPrimitiveType.getName(), standardLibrary.getPrimitiveJetType(primitiveType));
       primitiveTypesMap.put(
           "[" + jvmPrimitiveType.getName(),
           standardLibrary.getPrimitiveArrayJetType(primitiveType));
       primitiveTypesMap.put(
           jvmPrimitiveType.getWrapper().getFqName(),
           standardLibrary.getNullablePrimitiveJetType(primitiveType));
     }
     primitiveTypesMap.put("void", JetStandardClasses.getUnitType());
   }
   return primitiveTypesMap;
 }
Exemplo n.º 5
0
 public GenerationState(
     Project project,
     ClassBuilderFactory builderFactory,
     FileNameTransformer fileNameTransformer) {
   this.project = project;
   this.standardLibrary = JetStandardLibrary.getInstance();
   this.factory = new ClassFileFactory(builderFactory, this);
   this.intrinsics = new IntrinsicMethods(project, standardLibrary);
   this.fileNameTransformer = fileNameTransformer;
 }
Exemplo n.º 6
0
 private JetType getPrimitiveType(char descriptor, boolean nullable) {
   if (!nullable) {
     for (JvmPrimitiveType jvmPrimitiveType : JvmPrimitiveType.values()) {
       if (jvmPrimitiveType.getJvmLetter() == descriptor) {
         return jetStandardLibrary.getPrimitiveJetType(jvmPrimitiveType.getPrimitiveType());
       }
     }
     if (descriptor == 'V') {
       return JetStandardClasses.getUnitType();
     }
   } else {
     for (JvmPrimitiveType jvmPrimitiveType : JvmPrimitiveType.values()) {
       if (jvmPrimitiveType.getJvmLetter() == descriptor) {
         return jetStandardLibrary.getNullablePrimitiveJetType(
             jvmPrimitiveType.getPrimitiveType());
       }
     }
     if (descriptor == 'V') {
       throw new IllegalStateException("incorrect signature: nullable void");
     }
   }
   throw new IllegalStateException("incorrect signature");
 }
Exemplo n.º 7
0
 private FunctionDescriptor makeFunction(String funDecl) {
   JetNamedFunction function = JetPsiFactory.createFunction(getProject(), funDecl);
   return descriptorResolver.resolveFunctionDescriptor(root, library.getLibraryScope(), function);
 }