01: /**
02: * Copyright (C) 2001-2005 France Telecom R&D
03: */package org.objectweb.speedo.genclass.merger;
04:
05: import org.objectweb.asm.Attribute;
06: import org.objectweb.asm.CodeVisitor;
07: import org.objectweb.asm.Constants;
08: import org.objectweb.speedo.generation.enhancer.common.LoggedClassVisitor;
09: import org.objectweb.util.monolog.api.BasicLevel;
10: import org.objectweb.util.monolog.api.Logger;
11:
12: import java.util.HashSet;
13: import java.util.Set;
14:
15: /**
16: * This visitor checks if the class is abstract.
17: *
18: * @author S.Chassande-Barrioz
19: */
20: public class GenClassAnalyzer extends LoggedClassVisitor {
21:
22: GCInfo gc;
23:
24: public GenClassAnalyzer(Logger logger, GCInfo gci) {
25: super (logger);
26: this .gc = gci;
27: }
28:
29: public void visit(final int version, final int access,
30: final String name, final String super name,
31: final String[] interfaces, final String sourceFile) {
32: gc.isAbstract = (access & Constants.ACC_ABSTRACT) != 0;
33: gc.setSuperName(super name);
34: gc.itfs = interfaces;
35: }
36:
37: /**
38: * Add only non abstract method. Avoid method duplication
39: */
40: public CodeVisitor visitMethod(final int access, final String name,
41: final String desc, final String[] exceptions,
42: final Attribute attrs) {
43: String method = name + " " + desc;
44: if ((access & Constants.ACC_ABSTRACT) == 0) {
45: gc.nonAbstractMethods.add(method);
46: }
47: return null;
48: }
49: }
|