4
4
import hasnaer .java .bytecode .attribute .LocalVariableTable ;
5
5
import hasnaer .java .bytecode .cp .CP_Info ;
6
6
import hasnaer .java .bytecode .cp .ConstantPool ;
7
+ import hasnaer .java .bytecode .cp .Double_Info ;
7
8
import hasnaer .java .bytecode .cp .Float_Info ;
8
9
import hasnaer .java .bytecode .cp .Integer_Info ;
10
+ import hasnaer .java .bytecode .cp .Long_Info ;
9
11
import hasnaer .java .bytecode .cp .String_Info ;
10
12
import hasnaer .java .bytecode .nodes .AssignNode ;
11
13
import hasnaer .java .bytecode .nodes .FieldNode ;
12
14
import hasnaer .java .bytecode .nodes .InvocationNode ;
13
15
import hasnaer .java .bytecode .nodes .JVMNode ;
14
16
import hasnaer .java .bytecode .nodes .MethodNode ;
17
+ import hasnaer .java .bytecode .nodes .OperationNode ;
15
18
import hasnaer .java .bytecode .nodes .PrimitiveNode ;
16
19
import hasnaer .java .bytecode .nodes .ReferenceNode ;
17
20
import hasnaer .java .bytecode .nodes .ValueNode ;
@@ -140,6 +143,12 @@ public List<JVMNode> build() {
140
143
i = consumeLDC (i , code ()[i + 1 ]);
141
144
break ;
142
145
146
+ case Opcode .LDC_W :
147
+ case Opcode .LDC2_W :
148
+ System .err .println ("consumeLDC" );
149
+ i = consumeLDC (i + 1 , unsignedShortAt (i + 1 ));
150
+ break ;
151
+
143
152
case Opcode .INVOKESPECIAL :
144
153
System .err .println ("consumeINVOKESPECIAL" );
145
154
i = consumeINVOKEMETHOD (i );
@@ -248,6 +257,47 @@ public List<JVMNode> build() {
248
257
System .err .println ("consumeLOADNULLCONST" );
249
258
i = consumeLOADNULLCONST (i );
250
259
break ;
260
+
261
+ case Opcode .IADD :
262
+ case Opcode .FADD :
263
+ case Opcode .DADD :
264
+ case Opcode .LADD :
265
+ System .err .println ("consumeOPERATION" );
266
+ i = consumeOPERATION (i , OperationNode .Type .ADD );
267
+ break ;
268
+
269
+ case Opcode .ISUB :
270
+ case Opcode .LSUB :
271
+ case Opcode .DSUB :
272
+ case Opcode .FSUB :
273
+ System .err .println ("consumeOPERATION" );
274
+ i = consumeOPERATION (i , OperationNode .Type .SUB );
275
+ break ;
276
+
277
+ case Opcode .IDIV :
278
+ case Opcode .LDIV :
279
+ case Opcode .DDIV :
280
+ case Opcode .FDIV :
281
+ System .err .println ("consumeOPERATION" );
282
+ i = consumeOPERATION (i , OperationNode .Type .DIV );
283
+ break ;
284
+
285
+ case Opcode .IMUL :
286
+ case Opcode .FMUL :
287
+ case Opcode .DMUL :
288
+ case Opcode .LMUL :
289
+ System .err .println ("consumeOPERATION" );
290
+ i = consumeOPERATION (i , OperationNode .Type .MUL );
291
+ break ;
292
+
293
+ case Opcode .IREM :
294
+ case Opcode .FREM :
295
+ case Opcode .DREM :
296
+ case Opcode .LREM :
297
+ System .err .println ("consumeOPERATION" );
298
+ i = consumeOPERATION (i , OperationNode .Type .REM );
299
+ break ;
300
+
251
301
}
252
302
}
253
303
@@ -257,6 +307,15 @@ public List<JVMNode> build() {
257
307
return statements ;
258
308
}
259
309
310
+ private int consumeOPERATION (int pos , OperationNode .Type type ){
311
+ ValueNode right = (ValueNode ) stack .pop ();
312
+ ValueNode left = (ValueNode ) stack .pop ();
313
+
314
+ stack .push (new OperationNode (left , right , type ));
315
+
316
+ return pos + 1 ;
317
+ }
318
+
260
319
private int consumeLOADNULLCONST (int pos ){
261
320
stack .push (new ReferenceNode ("null" , "null" ));
262
321
return pos + 1 ;
@@ -357,8 +416,6 @@ private int consumeINVOKEMETHOD(int pos) {
357
416
358
417
private int consumeLDC (int pos , int index ) {
359
418
360
-
361
-
362
419
CP_Info cp_info = pool ().getCP_Info (index );
363
420
System .err .println ("index= " + index );
364
421
System .err .println ("tag= " + cp_info .getTag ());
@@ -376,6 +433,14 @@ private int consumeLDC(int pos, int index) {
376
433
String_Info str_info = (String_Info ) cp_info ;
377
434
stack .push (new ReferenceNode ("java.lang.String" , escapeSTR (pool ().getUTF8_Info (str_info .getString_Index ()).getValue ())));
378
435
break ;
436
+ case DOUBLE :
437
+ Double_Info double_info = (Double_Info ) cp_info ;
438
+ stack .push (new PrimitiveNode (PrimitiveNode .Type .DOUBLE , double_info .getStringValue ()));
439
+ break ;
440
+ case LONG :
441
+ Long_Info long_info = (Long_Info ) cp_info ;
442
+ stack .push (new PrimitiveNode (PrimitiveNode .Type .LONG , long_info .getStringValue ()));
443
+ break ;
379
444
}
380
445
381
446
return pos + 2 ;
@@ -427,6 +492,7 @@ private int consumeSTOREVARIABLE(int pos, int index) {
427
492
428
493
if (value instanceof PrimitiveNode ) {
429
494
variable = new PrimitiveNode (type_name [0 ], type_name [1 ]);
495
+ value = new PrimitiveNode (type_name [0 ], value .getName ());
430
496
} else {
431
497
variable = new ReferenceNode (type_name [0 ], type_name [1 ]);
432
498
}
0 commit comments