1010import java .util .Collections ;
1111import java .util .List ;
1212
13+ import org .python .objectweb .asm .AnnotationVisitor ;
1314import org .python .objectweb .asm .Attribute ;
1415import org .python .objectweb .asm .ClassWriter ;
1516import org .python .objectweb .asm .FieldVisitor ;
@@ -26,7 +27,6 @@ public class ClassFile
2627 String [] interfaces ;
2728 List <MethodVisitor > methodVisitors ;
2829 List <FieldVisitor > fieldVisitors ;
29- List <Attribute > attributes ;
3030
3131 public static String fixName (String n ) {
3232 if (n .indexOf ('.' ) == -1 )
@@ -53,7 +53,6 @@ public ClassFile(String name, String superclass, int access) {
5353
5454 methodVisitors = Collections .synchronizedList (new ArrayList ());
5555 fieldVisitors = Collections .synchronizedList (new ArrayList ());
56- attributes = Collections .synchronizedList (new ArrayList ());
5756 }
5857
5958 public void setSource (String name ) {
@@ -67,7 +66,6 @@ public void addInterface(String name) throws IOException {
6766 interfaces = new_interfaces ;
6867 }
6968
70- //FIXME: Should really return a MethodVisitor
7169 public Code addMethod (String name , String type , int access )
7270 throws IOException
7371 {
@@ -84,14 +82,6 @@ public void addField(String name, String type, int access)
8482 fieldVisitors .add (fv );
8583 }
8684
87- public void endAttributes ()
88- throws IOException
89- {
90- for (Attribute attr : attributes ) {
91- cw .visitAttribute (attr );
92- }
93- }
94-
9585 public void endFields ()
9686 throws IOException
9787 {
@@ -110,17 +100,16 @@ public void endMethods()
110100 }
111101 }
112102
113- public void addAttribute (Attribute attr ) throws IOException {
114- //FIXME: Do nothing for now.
115- //attributes.add(attr);
116- }
117-
118103 public void write (OutputStream stream ) throws IOException {
119104 cw .visit (Opcodes .V1_5 , Opcodes .ACC_PUBLIC + Opcodes .ACC_SUPER , this .name , null , this .superclass , interfaces );
105+ AnnotationVisitor av = cw .visitAnnotation ("Lorg/python/compiler/APIVersion;" , true );
106+ //XXX: should imp.java really house this value or should imp.java point into org.python.compiler?
107+ av .visit ("value" , new Integer (org .python .core .imp .APIVersion ));
108+ av .visitEnd ();
109+
120110 if (sfilename != null ) {
121111 cw .visitSource (sfilename , null );
122112 }
123- endAttributes ();
124113 endFields ();
125114 endMethods ();
126115
0 commit comments