    001    package cpw.mods.fml.common.discovery.asm;
    002
    003    import java.util.Collections;
    004
    005    import org.objectweb.asm.AnnotationVisitor;
    006    import org.objectweb.asm.ClassVisitor;
    007    import org.objectweb.asm.FieldVisitor;
    008    import org.objectweb.asm.MethodVisitor;
    009    import org.objectweb.asm.Opcodes;
    010    import org.objectweb.asm.Type;
    011
    012    public class ModClassVisitor extends ClassVisitor
    013    {
    014        private ASMModParser discoverer;
    015
    016        public ModClassVisitor(ASMModParser discoverer)
    017        {
    018            super(Opcodes.ASM4);
    019            this.discoverer = discoverer;
    020        }
    021
    022
    023        @Override
    024        public void visit(int version, int access, String name, String signature, String superName, String[] interfaces)
    025        {
    026            discoverer.beginNewTypeName(name, version, superName);
    027        }
    028
    029        @Override
    030        public AnnotationVisitor visitAnnotation(String annotationName, boolean runtimeVisible)
    031        {
    032            discoverer.startClassAnnotation(annotationName);
    033            return new ModAnnotationVisitor(discoverer);
    034        }
    035
    036
    037        @Override
    038        public FieldVisitor visitField(int access, String name, String desc, String signature, Object value)
    039        {
    040            return new ModFieldVisitor(name, discoverer);
    041        }
    042
    043        @Override
    044        public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions)
    045        {
    046            if (discoverer.isBaseMod(Collections.<String>emptyList()) && name.equals("getPriorities") && desc.equals(Type.getMethodDescriptor(Type.getType(String.class))))
    047            {
    048                return new ModMethodVisitor(name, discoverer);
    049            }
    050            return null;
    051        }
    052    }