Пример #1
0
 private void generateRemoveInIterator() {
   // generates stub 'remove' function for subclasses of Iterator to be compatible with
   // java.util.Iterator
   if (DescriptorUtils.isIteratorWithoutRemoveImpl(descriptor)) {
     MethodVisitor mv = v.getVisitor().visitMethod(ACC_PUBLIC, "remove", "()V", null, null);
     genMethodThrow(
         mv,
         "java/lang/UnsupportedOperationException",
         "Mutating method called on a Kotlin Iterator");
   }
 }
Пример #2
0
  private void generateStaticInitializer() {
    if (staticInitializerChunks.size() > 0) {
      MethodVisitor mv = v.newMethod(null, ACC_PUBLIC | ACC_STATIC, "<clinit>", "()V", null, null);
      if (state.getClassBuilderMode() == ClassBuilderMode.FULL) {
        mv.visitCode();

        InstructionAdapter v = new InstructionAdapter(mv);

        for (CodeChunk chunk : staticInitializerChunks) {
          chunk.generate(v);
        }

        mv.visitInsn(RETURN);
        FunctionCodegen.endVisit(v, "static initializer", myClass);
      }
    }
  }
Пример #3
0
 private void generatePrimaryConstructorProperties(
     PropertyCodegen propertyCodegen, JetClassOrObject origin) {
   boolean isAnnotation = origin instanceof JetClass && ((JetClass) origin).isAnnotation();
   for (JetParameter p : getPrimaryConstructorParameters()) {
     if (p.getValOrVarNode() != null) {
       PropertyDescriptor propertyDescriptor =
           state.getBindingContext().get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, p);
       if (propertyDescriptor != null) {
         if (!isAnnotation) {
           propertyCodegen.generatePrimaryConstructorProperty(p, propertyDescriptor);
         } else {
           Type type = state.getTypeMapper().mapType(propertyDescriptor);
           v.newMethod(
               p, ACC_PUBLIC | ACC_ABSTRACT, p.getName(), "()" + type.getDescriptor(), null, null);
         }
       }
     }
   }
 }