@@ -144,9 +144,7 @@ private static boolean processMethod(BufferedReader in, ClassWriter c, String cl
144
144
String curLine , methodName = null , returnType = null ;
145
145
String crName = null , crCuid = null , crOuter = null ;
146
146
boolean isStatic = false ;
147
- List <String > argNames = new ArrayList <String >();
148
147
List <Type > argTypes = new ArrayList <Type >();
149
- Map <String , Integer > argIndexes = new HashMap <String , Integer >();
150
148
Map <String , VariableDef > localVariables = new HashMap <String , VariableDef >();
151
149
Map <String , Label > labelMap = new HashMap <String , Label >();
152
150
Stack <Label > tryStartStack = new Stack <Label >();
@@ -162,7 +160,6 @@ private static boolean processMethod(BufferedReader in, ClassWriter c, String cl
162
160
163
161
MethodVisitor m = null ;
164
162
boolean contAfter = false ;
165
-
166
163
boolean inMethodHeader = true ;
167
164
while ((curLine = in .readLine ()) != null ) {
168
165
// See if we need to move to the next method.
@@ -185,21 +182,16 @@ else if (curLine.equals("++ static")) {
185
182
isStatic = true ;
186
183
curArgIndex = 0 ; /* No invocant. */
187
184
}
188
- else if (curLine .startsWith ("++ arg " )) {
189
- String [] bits = curLine .split ("\\ s" , 4 );
190
- Type t = processType (bits [3 ]);
191
- argNames .add (bits [2 ]);
192
- argTypes .add (t );
193
- argIndexes .put (bits [2 ], curArgIndex );
194
- curArgIndex += (t == Type .LONG_TYPE || t == Type .DOUBLE_TYPE ? 2 : 1 );
195
- }
196
- else if (curLine .startsWith ("++ local " )) {
185
+ else if (curLine .startsWith ("++ local " ) || curLine .startsWith ("++ arg" )) {
197
186
String [] bits = curLine .split ("\\ s" , 4 );
198
187
if (localVariables .containsKey (bits [2 ]))
199
188
throw new Exception ("Duplicate local name: " + bits [2 ]);
200
189
Type t = processType (bits [3 ]);
201
190
localVariables .put (bits [2 ], new VariableDef (curArgIndex , t .getDescriptor (), beginAll , endAll ));
202
191
curArgIndex += (t == Type .LONG_TYPE || t == Type .DOUBLE_TYPE ? 2 : 1 );
192
+ if (curLine .startsWith ("++ arg" )) {
193
+ argTypes .add (t );
194
+ }
203
195
}
204
196
else if (curLine .startsWith ("++ crname " ))
205
197
crName = curLine .substring ("++ crname " .length ());
@@ -275,7 +267,11 @@ else if (curLine.startsWith("++ handlers ")) {
275
267
av .visit ("handlers" , crHandlers );
276
268
av .visitEnd ();
277
269
}
278
-
270
+
271
+ if (!isStatic ) {
272
+ localVariables .put ("this" , new VariableDef (0 , "L" +className +";" , beginAll , endAll ));
273
+ }
274
+
279
275
m .visitCode ();
280
276
m .visitLabel (beginAll );
281
277
}
@@ -359,7 +355,7 @@ else if (curLine.startsWith(".line ")) {
359
355
}
360
356
361
357
// Process line as an instruction.
362
- emitInstruction (in , m , labelMap , argIndexes , localVariables , curLine );
358
+ emitInstruction (in , m , labelMap , localVariables , curLine );
363
359
}
364
360
if (inMethodHeader )
365
361
throw new Exception ("Unexpected end of file in method header" );
@@ -370,12 +366,6 @@ else if (curLine.startsWith(".line ")) {
370
366
VariableDef def = e .getValue ();
371
367
m .visitLocalVariable (e .getKey (), def .type , null , def .start , def .end , def .index );
372
368
}
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
369
380
370
m .visitMaxs (0 , 0 );
381
371
m .visitEnd ();
@@ -406,7 +396,6 @@ private static String decodeString(String value) {
406
396
407
397
private static void emitInstruction (BufferedReader in , MethodVisitor m ,
408
398
Map <String , Label > labelMap ,
409
- Map <String , Integer > argIndexes ,
410
399
Map <String , VariableDef > localVariables ,
411
400
String curLine ) throws Exception {
412
401
// Find instruction code and get rest of the string.
@@ -445,8 +434,6 @@ private static void emitInstruction(BufferedReader in, MethodVisitor m,
445
434
case 0x19 : // aload
446
435
if (localVariables .containsKey (rest ))
447
436
m .visitVarInsn (instruction , localVariables .get (rest ).index );
448
- else if (argIndexes .containsKey (rest ))
449
- m .visitVarInsn (instruction , argIndexes .get (rest ));
450
437
else
451
438
throw new Exception ("Undeclared local variable: " + rest );
452
439
break ;
@@ -527,8 +514,6 @@ else if (argIndexes.containsKey(rest))
527
514
case 0x3a : // astore
528
515
if (localVariables .containsKey (rest ))
529
516
m .visitVarInsn (instruction , localVariables .get (rest ).index );
530
- else if (argIndexes .containsKey (rest ))
531
- m .visitVarInsn (instruction , argIndexes .get (rest ));
532
517
else
533
518
throw new Exception ("Undeclared local variable: " + rest );
534
519
break ;
0 commit comments