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.load.kotlin.header.KotlinClassHeader;
022 import org.jetbrains.kotlin.name.ClassId;
023 import org.jetbrains.kotlin.name.Name;
024
025 public interface KotlinJvmBinaryClass {
026 @NotNull
027 ClassId getClassId();
028
029 /**
030 * @return path to the class file (to be reported to the user upon error)
031 */
032 @NotNull
033 String getLocation();
034
035 void loadClassAnnotations(@NotNull AnnotationVisitor visitor);
036
037 void visitMembers(@NotNull MemberVisitor visitor);
038
039 @NotNull
040 KotlinClassHeader getClassHeader();
041
042 interface MemberVisitor {
043 // TODO: abstract signatures for methods and fields instead of ASM 'desc' strings?
044
045 @Nullable
046 MethodAnnotationVisitor visitMethod(@NotNull Name name, @NotNull String desc);
047
048 @Nullable
049 AnnotationVisitor visitField(@NotNull Name name, @NotNull String desc, @Nullable Object initializer);
050 }
051
052 interface AnnotationVisitor {
053 @Nullable
054 AnnotationArgumentVisitor visitAnnotation(@NotNull ClassId classId);
055
056 void visitEnd();
057 }
058
059 interface MethodAnnotationVisitor extends AnnotationVisitor {
060 @Nullable
061 AnnotationArgumentVisitor visitParameterAnnotation(int index, @NotNull ClassId classId);
062 }
063
064 interface AnnotationArgumentVisitor {
065 // TODO: class literals
066 void visit(@Nullable Name name, @Nullable Object value);
067
068 void visitEnum(@NotNull Name name, @NotNull ClassId enumClassId, @NotNull Name enumEntryName);
069
070 @Nullable
071 AnnotationArgumentVisitor visitAnnotation(@NotNull Name name, @NotNull ClassId classId);
072
073 @Nullable
074 AnnotationArrayArgumentVisitor visitArray(@NotNull Name name);
075
076 void visitEnd();
077 }
078
079 interface AnnotationArrayArgumentVisitor {
080 void visit(@Nullable Object value);
081
082 void visitEnum(@NotNull ClassId enumClassId, @NotNull Name enumEntryName);
083
084 void visitEnd();
085 }
086 }