@@ -155,19 +155,22 @@ private static boolean processMethod(BufferedReader in, ClassWriter c, String cl
155
155
List <String > criLex = new ArrayList <String >();
156
156
List <String > crnLex = new ArrayList <String >();
157
157
List <String > crsLex = new ArrayList <String >();
158
+ Label beginAll = new Label ();
159
+ Label endAll = new Label ();
158
160
long [] crHandlers = null ;
159
161
int curArgIndex = 1 ;
160
162
161
163
MethodVisitor m = null ;
164
+ boolean contAfter = false ;
162
165
163
166
boolean inMethodHeader = true ;
164
167
while ((curLine = in .readLine ()) != null ) {
165
168
// See if we need to move to the next method.
166
169
if (curLine .equals ("+ method" )) {
167
170
if (inMethodHeader )
168
171
throw new Exception ("Unexpected + method in method header" );
169
- finishMethod ( m ) ;
170
- return true ;
172
+ contAfter = true ;
173
+ break ;
171
174
}
172
175
173
176
// Is it a header line?
@@ -195,7 +198,7 @@ else if (curLine.startsWith("++ local ")) {
195
198
if (localVariables .containsKey (bits [2 ]))
196
199
throw new Exception ("Duplicate local name: " + bits [2 ]);
197
200
Type t = processType (bits [3 ]);
198
- localVariables .put (bits [2 ], new VariableDef (curArgIndex , t .getDescriptor ()));
201
+ localVariables .put (bits [2 ], new VariableDef (curArgIndex , t .getDescriptor (), beginAll , endAll ));
199
202
curArgIndex += (t == Type .LONG_TYPE || t == Type .DOUBLE_TYPE ? 2 : 1 );
200
203
}
201
204
else if (curLine .startsWith ("++ crname " ))
@@ -273,11 +276,8 @@ else if (curLine.startsWith("++ handlers ")) {
273
276
av .visitEnd ();
274
277
}
275
278
276
- // Add locals.
277
- for (Map .Entry <String , VariableDef > e : localVariables .entrySet ()) {
278
- VariableDef def = e .getValue ();
279
- m .visitLocalVariable (e .getKey (), def .type , null , def .start , def .end , def .index );
280
- }
279
+ m .visitCode ();
280
+ m .visitLabel (beginAll );
281
281
}
282
282
283
283
// Check if it's a label.
@@ -363,8 +363,23 @@ else if (curLine.startsWith(".line ")) {
363
363
}
364
364
if (inMethodHeader )
365
365
throw new Exception ("Unexpected end of file in method header" );
366
- finishMethod (m );
367
- return false ;
366
+
367
+ // Add locals.
368
+ m .visitLabel (endAll );
369
+ for (Map .Entry <String , VariableDef > e : localVariables .entrySet ()) {
370
+ VariableDef def = e .getValue ();
371
+ m .visitLocalVariable (e .getKey (), def .type , null , def .start , def .end , def .index );
372
+ }
373
+ if (!isStatic )
374
+ m .visitLocalVariable ("this" , "L" +className +";" , null , beginAll , endAll , 0 );
375
+ for (int i = 0 ; i < argTypes .size (); i ++) {
376
+ m .visitLocalVariable (argNames .get (i ), argTypes .get (i ).getDescriptor (), null ,
377
+ beginAll , endAll , argIndexes .get (argNames .get (i )));
378
+ }
379
+
380
+ m .visitMaxs (0 , 0 );
381
+ m .visitEnd ();
382
+ return contAfter ;
368
383
}
369
384
370
385
private static String decodeString (String value ) {
@@ -832,11 +847,6 @@ private static void emitTableSwitchInstruction(MethodVisitor m, Map<String, Labe
832
847
m .visitTableSwitchInsn (0 , labels .length - 1 , defaultLabel , labels );
833
848
}
834
849
835
- private static void finishMethod (MethodVisitor m ) throws Exception {
836
- // Finalize method.
837
- m .visitMaxs (0 , 0 );
838
- }
839
-
840
850
private static Type processType (String typeName ) {
841
851
// Long needs special treatment; getType doesn't cope with it.
842
852
if (typeName .equals ("Long" ))
@@ -851,11 +861,11 @@ private static void usage()
851
861
}
852
862
853
863
static class VariableDef {
854
- public VariableDef (int i , String t ) {
864
+ public VariableDef (int i , String t , Label s , Label e ) {
855
865
index = i ;
856
866
type = t ;
857
- start = new Label () ;
858
- end = new Label () ;
867
+ start = s ;
868
+ end = e ;
859
869
}
860
870
861
871
public final int index ;
0 commit comments