001 /*
002 * Copyright 2010-2014 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.jet.codegen;
018
019 import com.intellij.psi.PsiElement;
020 import org.jetbrains.annotations.NotNull;
021 import org.jetbrains.annotations.Nullable;
022 import org.jetbrains.jet.lang.resolve.java.diagnostics.JvmDeclarationOrigin;
023 import org.jetbrains.org.objectweb.asm.AnnotationVisitor;
024 import org.jetbrains.org.objectweb.asm.ClassVisitor;
025 import org.jetbrains.org.objectweb.asm.FieldVisitor;
026 import org.jetbrains.org.objectweb.asm.MethodVisitor;
027
028 public abstract class DelegatingClassBuilder implements ClassBuilder {
029 @NotNull
030 protected abstract ClassBuilder getDelegate();
031
032 @NotNull
033 @Override
034 public FieldVisitor newField(
035 @NotNull JvmDeclarationOrigin origin,
036 int access,
037 @NotNull String name,
038 @NotNull String desc,
039 @Nullable String signature,
040 @Nullable Object value
041 ) {
042 return getDelegate().newField(origin, access, name, desc, signature, value);
043 }
044
045 @NotNull
046 @Override
047 public MethodVisitor newMethod(
048 @NotNull JvmDeclarationOrigin origin,
049 int access,
050 @NotNull String name,
051 @NotNull String desc,
052 @Nullable String signature,
053 @Nullable String[] exceptions
054 ) {
055 return getDelegate().newMethod(origin, access, name, desc, signature, exceptions);
056 }
057
058 @NotNull
059 @Override
060 public JvmSerializationBindings getSerializationBindings() {
061 return getDelegate().getSerializationBindings();
062 }
063
064 @NotNull
065 @Override
066 public AnnotationVisitor newAnnotation(@NotNull String desc, boolean visible) {
067 return getDelegate().newAnnotation(desc, visible);
068 }
069
070 @Override
071 public void done() {
072 getDelegate().done();
073 }
074
075 @NotNull
076 @Override
077 public ClassVisitor getVisitor() {
078 return getDelegate().getVisitor();
079 }
080
081 @Override
082 public void defineClass(
083 @Nullable PsiElement origin,
084 int version,
085 int access,
086 @NotNull String name,
087 @Nullable String signature,
088 @NotNull String superName,
089 @NotNull String[] interfaces
090 ) {
091 getDelegate().defineClass(origin, version, access, name, signature, superName, interfaces);
092 }
093
094 @Override
095 public void visitSource(@NotNull String name, @Nullable String debug) {
096 getDelegate().visitSource(name, debug);
097 }
098
099 @Override
100 public void visitOuterClass(@NotNull String owner, @Nullable String name, @Nullable String desc) {
101 getDelegate().visitOuterClass(owner, name, desc);
102 }
103
104 @Override
105 public void visitInnerClass(@NotNull String name, @Nullable String outerName, @Nullable String innerName, int access) {
106 getDelegate().visitInnerClass(name, outerName, innerName, access);
107 }
108
109 @NotNull
110 @Override
111 public String getThisName() {
112 return getDelegate().getThisName();
113 }
114 }