@@ -42,19 +42,18 @@ public static String fixName(String n) {
4242 }
4343 return new String (c );
4444 }
45-
4645
4746 public static void visitAnnotations (AnnotationVisitor av , Map <String , Object > fields ) {
4847 for (Entry <String , Object >field : fields .entrySet ()) {
4948 visitAnnotation (av , field .getKey (), field .getValue ());
5049 }
5150 }
52-
51+
5352 // See org.objectweb.asm.AnnotationVisitor for details
5453 // TODO Support annotation annotations and annotation array annotations
5554 public static void visitAnnotation (AnnotationVisitor av , String fieldName , Object fieldValue ) {
5655 Class <?> fieldValueClass = fieldValue .getClass ();
57-
56+
5857 if (fieldValue instanceof Class ) {
5958 av .visit (fieldName , Type .getType ((Class <?>)fieldValue ));
6059 } else if (fieldValueClass .isEnum ()) {
@@ -79,13 +78,14 @@ public ClassFile(String name) {
7978 public ClassFile (String name , String superclass , int access ) {
8079 this (name , superclass , access , org .python .core .imp .NO_MTIME );
8180 }
81+
8282 public ClassFile (String name , String superclass , int access , long mtime ) {
8383 this .name = fixName (name );
8484 this .superclass = fixName (superclass );
8585 this .interfaces = new String [0 ];
8686 this .access = access ;
8787 this .mtime = mtime ;
88-
88+
8989 cw = new ClassWriter (ClassWriter .COMPUTE_FRAMES );
9090 methodVisitors = Collections .synchronizedList (new ArrayList <MethodVisitor >());
9191 fieldVisitors = Collections .synchronizedList (new ArrayList <FieldVisitor >());
@@ -96,7 +96,9 @@ public void setSource(String name) {
9696 sfilename = name ;
9797 }
9898
99- public void addInterface (String name ) throws IOException {
99+ public void addInterface (String name )
100+ throws IOException
101+ {
100102 String [] new_interfaces = new String [interfaces .length +1 ];
101103 System .arraycopy (interfaces , 0 , new_interfaces , 0 , interfaces .length );
102104 new_interfaces [interfaces .length ] = name ;
@@ -111,15 +113,16 @@ public Code addMethod(String name, String type, int access)
111113 methodVisitors .add (pmv );
112114 return pmv ;
113115 }
116+
114117 public Code addMethod (String name , String type , int access , String [] exceptions )
115- throws IOException
116- {
117- MethodVisitor mv = cw .visitMethod (access , name , type , null , exceptions );
118- Code pmv = new Code (mv , type , access );
119- methodVisitors .add (pmv );
120- return pmv ;
121- }
122-
118+ throws IOException
119+ {
120+ MethodVisitor mv = cw .visitMethod (access , name , type , null , exceptions );
121+ Code pmv = new Code (mv , type , access );
122+ methodVisitors .add (pmv );
123+ return pmv ;
124+ }
125+
123126 public Code addMethod (String name , String type , int access , String [] exceptions ,
124127 AnnotationDescr []methodAnnotationDescrs , AnnotationDescr [][] parameterAnnotationDescrs )
125128 throws IOException
@@ -134,7 +137,7 @@ public Code addMethod(String name, String type, int access, String[] exceptions,
134137 }
135138 av .visitEnd ();
136139 }
137-
140+
138141 // parameter annotations
139142 for (int i = 0 ; i < parameterAnnotationDescrs .length ; i ++) {
140143 for (AnnotationDescr ad : parameterAnnotationDescrs [i ]) {
@@ -145,20 +148,20 @@ public Code addMethod(String name, String type, int access, String[] exceptions,
145148 av .visitEnd ();
146149 }
147150 }
148-
151+
149152 Code pmv = new Code (mv , type , access );
150153 methodVisitors .add (pmv );
151154 return pmv ;
152155 }
153-
156+
154157 public void addClassAnnotation (AnnotationDescr annotationDescr ) {
155158 AnnotationVisitor av = cw .visitAnnotation (annotationDescr .getName (), true );
156159 if (annotationDescr .hasFields ()) {
157160 visitAnnotations (av , annotationDescr .getFields ());
158161 }
159162 annotationVisitors .add (av );
160163 }
161-
164+
162165 public void addField (String name , String type , int access )
163166 throws IOException
164167 {
@@ -190,7 +193,7 @@ public void endFields()
190193 fv .visitEnd ();
191194 }
192195 }
193-
196+
194197 public void endMethods ()
195198 throws IOException
196199 {
@@ -204,10 +207,12 @@ public void endMethods()
204207 public void endClassAnnotations () {
205208 for (AnnotationVisitor av : annotationVisitors ) {
206209 av .visitEnd ();
207- }
210+ }
208211 }
209212
210- public void write (OutputStream stream ) throws IOException {
213+ public void write (OutputStream stream )
214+ throws IOException
215+ {
211216 cw .visit (Opcodes .V1_5 , Opcodes .ACC_PUBLIC + Opcodes .ACC_SUPER , this .name , null , this .superclass , interfaces );
212217 AnnotationVisitor av = cw .visitAnnotation ("Lorg/python/compiler/APIVersion;" , true );
213218 // XXX: should imp.java really house this value or should imp.java point into
0 commit comments