001/* 002 * Forge Mod Loader 003 * Copyright (c) 2012-2013 cpw. 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser Public License v2.1 006 * which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 008 * 009 * Contributors: 010 * cpw - implementation 011 */ 012 013package cpw.mods.fml.common.discovery.asm; 014 015import java.util.Collections; 016 017import org.objectweb.asm.AnnotationVisitor; 018import org.objectweb.asm.ClassVisitor; 019import org.objectweb.asm.FieldVisitor; 020import org.objectweb.asm.MethodVisitor; 021import org.objectweb.asm.Opcodes; 022import org.objectweb.asm.Type; 023 024public class ModClassVisitor extends ClassVisitor 025{ 026 private ASMModParser discoverer; 027 028 public ModClassVisitor(ASMModParser discoverer) 029 { 030 super(Opcodes.ASM4); 031 this.discoverer = discoverer; 032 } 033 034 035 @Override 036 public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) 037 { 038 discoverer.beginNewTypeName(name, version, superName); 039 } 040 041 @Override 042 public AnnotationVisitor visitAnnotation(String annotationName, boolean runtimeVisible) 043 { 044 discoverer.startClassAnnotation(annotationName); 045 return new ModAnnotationVisitor(discoverer); 046 } 047 048 049 @Override 050 public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) 051 { 052 return new ModFieldVisitor(name, discoverer); 053 } 054 055 @Override 056 public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) 057 { 058 if (discoverer.isBaseMod(Collections.<String>emptyList()) && name.equals("getPriorities") && desc.equals(Type.getMethodDescriptor(Type.getType(String.class)))) 059 { 060 return new ModMethodVisitor(name, discoverer); 061 } 062 return null; 063 } 064}