001 /*
002 * Copyright 2010-2015 JetBrains s.r.o.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017 package org.jetbrains.kotlin.load.kotlin;
018
019 import org.jetbrains.annotations.NotNull;
020 import org.jetbrains.annotations.Nullable;
021 import org.jetbrains.kotlin.descriptors.SourceElement;
022 import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader;
023 import org.jetbrains.kotlin.name.ClassId;
024 import org.jetbrains.kotlin.name.Name;
025
026 public interface KotlinJvmBinaryClass {
027 @NotNull
028 ClassId getClassId();
029
030 /**
031 * @return path to the class file (to be reported to the user upon error)
032 */
033 @NotNull
034 String getLocation();
035
036 void loadClassAnnotations(@NotNull AnnotationVisitor visitor);
037
038 void visitMembers(@NotNull MemberVisitor visitor);
039
040 @NotNull
041 KotlinClassHeader getClassHeader();
042
043 interface MemberVisitor {
044 // TODO: abstract signatures for methods and fields instead of ASM 'desc' strings?
045
046 @Nullable
047 MethodAnnotationVisitor visitMethod(@NotNull Name name, @NotNull String desc);
048
049 @Nullable
050 AnnotationVisitor visitField(@NotNull Name name, @NotNull String desc, @Nullable Object initializer);
051 }
052
053 interface AnnotationVisitor {
054 @Nullable
055 AnnotationArgumentVisitor visitAnnotation(@NotNull ClassId classId, @NotNull SourceElement source);
056
057 void visitEnd();
058 }
059
060 interface MethodAnnotationVisitor extends AnnotationVisitor {
061 @Nullable
062 AnnotationArgumentVisitor visitParameterAnnotation(int index, @NotNull ClassId classId, @NotNull SourceElement source);
063 }
064
065 interface AnnotationArgumentVisitor {
066 // TODO: class literals
067 void visit(@Nullable Name name, @Nullable Object value);
068
069 void visitEnum(@NotNull Name name, @NotNull ClassId enumClassId, @NotNull Name enumEntryName);
070
071 @Nullable
072 AnnotationArgumentVisitor visitAnnotation(@NotNull Name name, @NotNull ClassId classId);
073
074 @Nullable
075 AnnotationArrayArgumentVisitor visitArray(@NotNull Name name);
076
077 void visitEnd();
078 }
079
080 interface AnnotationArrayArgumentVisitor {
081 void visit(@Nullable Object value);
082
083 void visitEnum(@NotNull ClassId enumClassId, @NotNull Name enumEntryName);
084
085 void visitEnd();
086 }
087 }