1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 package org.kit.furia.fragment.soot.representation;
33
34 import soot.*;
35 import soot.jimple.*;
36 import soot.jimple.internal.JCaughtExceptionRef;
37 import soot.jimple.internal.JNewExpr;
38
39 import org.kit.furia.fragment.soot.representation.internal.*;
40
41 import soot.shimple.PhiExpr;
42 import soot.shimple.internal.SPhiExpr;
43 import soot.util.*;
44
45 import java.util.*;
46 import org.apache.log4j.Logger;
47
48
49
50
51
52
53
54
55
56
57
58 public class Frimp
59 {
60
61 private final static Logger logger = Logger.getLogger(Frimp.class);
62
63 private static Frimp v = new Frimp();
64
65 public Frimp( Singletons.Global g ) {}
66
67 public Frimp(){}
68
69 public static Frimp v() { return v; }
70
71
72
73
74
75 public XorExpr newXorExpr(Value op1, Value op2)
76 {
77 return new FXorExpr(op1, op2);
78 }
79
80
81
82
83
84
85 public UshrExpr newUshrExpr(Value op1, Value op2)
86 {
87 return new FUshrExpr(op1, op2);
88 }
89
90
91
92
93
94
95 public SubExpr newSubExpr(Value op1, Value op2)
96 {
97 return new FSubExpr(op1, op2);
98 }
99
100
101
102
103
104
105
106
107 public ShrExpr newShrExpr(Value op1, Value op2)
108 {
109 return new FShrExpr(op1, op2);
110 }
111
112
113
114
115
116
117 public ShlExpr newShlExpr(Value op1, Value op2)
118 {
119 return new FShlExpr(op1, op2);
120 }
121
122
123
124
125
126
127 public RemExpr newRemExpr(Value op1, Value op2)
128 {
129 return new FRemExpr(op1, op2);
130 }
131
132
133
134
135
136
137 public OrExpr newOrExpr(Value op1, Value op2)
138 {
139 return new FOrExpr(op1, op2);
140 }
141
142
143
144
145
146
147 public NeExpr newNeExpr(Value op1, Value op2)
148 {
149 return new FNeExpr(op1, op2);
150 }
151
152
153
154
155
156
157 public MulExpr newMulExpr(Value op1, Value op2)
158 {
159 return new FMulExpr(op1, op2);
160 }
161
162
163
164
165
166
167 public LeExpr newLeExpr(Value op1, Value op2)
168 {
169 return new FLeExpr(op1, op2);
170 }
171
172
173
174
175
176
177 public GeExpr newGeExpr(Value op1, Value op2)
178 {
179 return new FGeExpr(op1, op2);
180 }
181
182
183
184
185
186
187 public EqExpr newEqExpr(Value op1, Value op2)
188 {
189 return new FEqExpr(op1, op2);
190 }
191
192
193
194
195
196 public DivExpr newDivExpr(Value op1, Value op2)
197 {
198 return new FDivExpr(op1, op2);
199 }
200
201
202
203
204
205
206 public CmplExpr newCmplExpr(Value op1, Value op2)
207 {
208 return new FCmplExpr(op1, op2);
209 }
210
211
212
213
214
215
216 public CmpgExpr newCmpgExpr(Value op1, Value op2)
217 {
218 return new FCmpgExpr(op1, op2);
219 }
220
221
222
223
224
225
226 public CmpExpr newCmpExpr(Value op1, Value op2)
227 {
228 return new FCmpExpr(op1, op2);
229 }
230
231
232
233
234
235
236 public GtExpr newGtExpr(Value op1, Value op2)
237 {
238 return new FGtExpr(op1, op2);
239 }
240
241
242
243
244
245
246 public LtExpr newLtExpr(Value op1, Value op2)
247 {
248 return new FLtExpr(op1, op2);
249 }
250
251
252
253
254
255 public AddExpr newAddExpr(Value op1, Value op2)
256 {
257 return new FAddExpr(op1, op2);
258 }
259
260
261
262
263
264
265 public AndExpr newAndExpr(Value op1, Value op2)
266 {
267 return new FAndExpr(op1, op2);
268 }
269
270
271
272
273
274
275 public NegExpr newNegExpr(Value op)
276 {
277 return new FNegExpr(op);
278 }
279
280
281
282
283
284
285 public LengthExpr newLengthExpr(Value op)
286 {
287 return new FLengthExpr(op);
288 }
289
290
291
292
293
294
295 public CastExpr newCastExpr(Value op1, Type t)
296 {
297 return new FCastExpr(op1, t);
298 }
299
300
301
302
303
304
305 public InstanceOfExpr newInstanceOfExpr(Value op1, Type t)
306 {
307 return new FInstanceOfExpr(op1, t);
308 }
309
310
311
312
313
314
315 NewExpr newNewExpr(RefType type)
316 {
317 return Jimple.v().newNewExpr(type);
318 }
319
320
321
322
323
324
325 public NewArrayExpr newNewArrayExpr(Type type, Value size)
326 {
327 return new FNewArrayExpr(type, size);
328 }
329
330
331
332
333
334 public NewMultiArrayExpr newNewMultiArrayExpr(ArrayType type, List sizes)
335 {
336 return new FNewMultiArrayExpr(type, sizes);
337 }
338
339
340
341
342
343 public NewInvokeExpr newNewInvokeExpr(RefType base, SootMethodRef method, List args)
344 {
345 return (NewInvokeExpr)new FNewInvokeExpr(base, method, args);
346 }
347
348
349
350
351
352 public StaticInvokeExpr newStaticInvokeExpr(SootMethodRef method, List args)
353 {
354 return new FStaticInvokeExpr(method, args);
355 }
356
357
358
359
360
361
362 public SpecialInvokeExpr newSpecialInvokeExpr(Local base, SootMethodRef method, List args)
363 {
364 return new FSpecialInvokeExpr(base, method, args);
365 }
366
367
368
369
370
371
372 public VirtualInvokeExpr newVirtualInvokeExpr(Local base, SootMethodRef method, List args)
373 {
374 return new FVirtualInvokeExpr(base, method, args);
375 }
376
377
378
379
380
381
382 public InterfaceInvokeExpr newInterfaceInvokeExpr(Local base, SootMethodRef method, List args)
383 {
384 return new FInterfaceInvokeExpr(base, method, args);
385 }
386
387
388
389
390
391
392 public ThrowStmt newThrowStmt(Value op)
393 {
394 return new FThrowStmt(op);
395 }
396
397 public ThrowStmt newThrowStmt(ThrowStmt s)
398 {
399 return new FThrowStmt(s.getOp());
400 }
401
402
403
404
405
406 public ExitMonitorStmt newExitMonitorStmt(Value op)
407 {
408 return new FExitMonitorStmt(op);
409 }
410
411 public ExitMonitorStmt newExitMonitorStmt(ExitMonitorStmt s)
412 {
413 return new FExitMonitorStmt(s.getOp());
414 }
415
416
417
418
419
420 public EnterMonitorStmt newEnterMonitorStmt(Value op)
421 {
422 return new FEnterMonitorStmt(op);
423 }
424
425 public EnterMonitorStmt newEnterMonitorStmt(EnterMonitorStmt s)
426 {
427 return new FEnterMonitorStmt(s.getOp());
428 }
429
430
431
432
433
434 public BreakpointStmt newBreakpointStmt()
435 {
436 return Jimple.v().newBreakpointStmt();
437 }
438
439 public BreakpointStmt newBreakpointStmt(BreakpointStmt s)
440 {
441 return Jimple.v().newBreakpointStmt();
442 }
443
444
445
446
447
448 public GotoStmt newGotoStmt(Unit target)
449 {
450 return Jimple.v().newGotoStmt(target);
451 }
452
453 public GotoStmt newGotoStmt(GotoStmt s)
454 {
455 return Jimple.v().newGotoStmt(s.getTarget());
456 }
457
458
459
460
461
462 public NopStmt newNopStmt()
463 {
464 return Jimple.v().newNopStmt();
465 }
466
467 public NopStmt newNopStmt(NopStmt s)
468 {
469 return Jimple.v().newNopStmt();
470 }
471
472
473
474
475
476 public ReturnVoidStmt newReturnVoidStmt()
477 {
478 return Jimple.v().newReturnVoidStmt();
479 }
480
481 public ReturnVoidStmt newReturnVoidStmt(ReturnVoidStmt s)
482 {
483 return Jimple.v().newReturnVoidStmt();
484 }
485
486
487
488
489
490 public ReturnStmt newReturnStmt(Value op)
491 {
492 return new FReturnStmt(op);
493 }
494
495 public ReturnStmt newReturnStmt(ReturnStmt s)
496 {
497 return new FReturnStmt(s.getOp());
498 }
499
500
501
502
503
504 public IfStmt newIfStmt(Value condition, Unit target)
505 {
506 return new FIfStmt(condition, target);
507 }
508
509 public IfStmt newIfStmt(IfStmt s)
510 {
511 return new FIfStmt(s.getCondition(), s.getTarget());
512 }
513
514
515
516
517
518 public IdentityStmt newIdentityStmt(Value local, Value identityRef)
519 {
520 return new FIdentityStmt(local, identityRef);
521 }
522
523 public IdentityStmt newIdentityStmt(IdentityStmt s)
524 {
525 return new FIdentityStmt(s.getLeftOp(), s.getRightOp());
526 }
527
528
529
530
531
532 public AssignStmt newAssignStmt(Value variable, Value rvalue)
533 {
534 return new FAssignStmt(variable, rvalue);
535 }
536
537 public AssignStmt newAssignStmt(AssignStmt s)
538 {
539 return new FAssignStmt(s.getLeftOp(), s.getRightOp());
540 }
541
542
543
544
545
546 public InvokeStmt newInvokeStmt(Value op)
547 {
548 return new FInvokeStmt(op);
549 }
550
551 public InvokeStmt newInvokeStmt(InvokeStmt s)
552 {
553 return new FInvokeStmt(s.getInvokeExpr());
554 }
555
556
557
558
559
560 public TableSwitchStmt newTableSwitchStmt(Value key, int lowIndex, int highIndex, List targets, Unit defaultTarget)
561 {
562 return new FTableSwitchStmt(key, lowIndex, highIndex, targets, defaultTarget);
563 }
564
565 public TableSwitchStmt newTableSwitchStmt(TableSwitchStmt s)
566 {
567 return new FTableSwitchStmt(s.getKey(), s.getLowIndex(),
568 s.getHighIndex(), s.getTargets(),
569 s.getDefaultTarget());
570 }
571
572
573
574
575
576 public LookupSwitchStmt newLookupSwitchStmt(Value key, List lookupValues, List targets, Unit defaultTarget)
577 {
578 return new FLookupSwitchStmt(key, lookupValues, targets, defaultTarget);
579 }
580
581 public LookupSwitchStmt newLookupSwitchStmt(LookupSwitchStmt s)
582 {
583 return new FLookupSwitchStmt(s.getKey(), s.getLookupValues(),
584 s.getTargets(), s.getDefaultTarget());
585 }
586
587
588
589
590
591 public Local newLocal(String name, Type t)
592 {
593 return Jimple.v().newLocal(name, t);
594 }
595
596
597
598
599
600 public Trap newTrap(SootClass exception, Unit beginStmt, Unit endStmt, Unit handlerStmt)
601 {
602 return new FTrap(exception, beginStmt, endStmt, handlerStmt);
603 }
604
605 public Trap newTrap(Trap trap)
606 {
607 return new FTrap(trap.getException(), trap.getBeginUnit(),
608 trap.getEndUnit(), trap.getHandlerUnit());
609 }
610
611
612
613
614
615 public StaticFieldRef newStaticFieldRef(SootFieldRef f)
616 {
617 return Jimple.v().newStaticFieldRef(f);
618 }
619
620
621
622
623
624
625 public ThisRef newThisRef(RefType t)
626 {
627 return Jimple.v().newThisRef(t);
628 }
629
630
631
632
633
634
635 public ParameterRef newParameterRef(Type paramType, int number)
636 {
637 return Jimple.v().newParameterRef(paramType, number);
638 }
639
640
641
642
643
644 public InstanceFieldRef newInstanceFieldRef(Value base, SootFieldRef f)
645 {
646 return new FInstanceFieldRef(base, f);
647 }
648
649
650
651
652
653
654 public CaughtExceptionRef newCaughtExceptionRef()
655 {
656 return Jimple.v().newCaughtExceptionRef();
657 }
658
659
660
661
662
663
664 public ArrayRef newArrayRef(Value base, Value index)
665 {
666 return new FArrayRef(base, index);
667 }
668
669 public ValueBox newVariableBox(Value value)
670 {
671 return Jimple.v().newVariableBox(value);
672 }
673
674 public ValueBox newLocalBox(Value value)
675 {
676 return Jimple.v().newLocalBox(value);
677 }
678
679 public ValueBox newRValueBox(Value value)
680 {
681 return new FRValueBox(value);
682 }
683
684 public ValueBox newImmediateBox(Value value)
685 {
686 return Jimple.v().newImmediateBox(value);
687 }
688
689 public ValueBox newExprBox(Value value)
690 {
691 return new FExprBox(value);
692 }
693
694 public ValueBox newArgBox(Value value)
695 {
696 return new FExprBox(value);
697 }
698
699 public ValueBox newObjExprBox(Value value)
700 {
701 return new FObjExprBox(value);
702 }
703
704 public ValueBox newIdentityRefBox(Value value)
705 {
706 return Jimple.v().newIdentityRefBox(value);
707 }
708
709 public ValueBox newConditionExprBox(Value value)
710 {
711 return Jimple.v().newConditionExprBox(value);
712 }
713
714 public ValueBox newInvokeExprBox(Value value)
715 {
716 return Jimple.v().newInvokeExprBox(value);
717 }
718
719 public UnitBox newStmtBox(Unit unit)
720 {
721 return Jimple.v().newStmtBox((Stmt) unit);
722 }
723
724
725
726
727
728
729
730
731
732
733 public PhiExpr newPhiExpr(List args, List preds)
734 {
735 return new FPhiExpr(args, preds);
736 }
737
738
739
740
741
742
743
744 public static List valueBoxToValue(List valueBoxes){
745 Iterator it = valueBoxes.iterator();
746 Vector res = new Vector();
747 while(it.hasNext()){
748 ValueBox vb = (ValueBox) it.next();
749 res.addElement(vb.getValue());
750 }
751 return res;
752 }
753
754
755 public Value newExpr(Value value)
756 {
757 if (value instanceof SPhiExpr){
758 final FExprBox returnedExpr = new FExprBox(IntConstant.v(0));
759 returnedExpr.setValue
760 (newPhiExpr( valueBoxToValue( ((SPhiExpr)value).getArgs()) ,
761 ((SPhiExpr)value).getPreds()));
762 return returnedExpr.getValue();
763 }else
764 if (value instanceof Expr)
765 {
766 final FExprBox returnedExpr = new FExprBox(IntConstant.v(0));
767 ((Expr)value).apply(new AbstractExprSwitch()
768 {
769
770
771 public void caseAddExpr(AddExpr v)
772 {
773 returnedExpr.setValue
774 (newAddExpr(newExpr(v.getOp1()),
775 newExpr(v.getOp2())));
776 }
777
778 public void caseAndExpr(AndExpr v)
779 {
780 returnedExpr.setValue
781 (newAndExpr(newExpr(v.getOp1()),
782 newExpr(v.getOp2())));
783 }
784
785 public void caseCmpExpr(CmpExpr v)
786 {
787 returnedExpr.setValue
788 (newCmpExpr(newExpr(v.getOp1()),
789 newExpr(v.getOp2())));
790 }
791
792 public void caseCmpgExpr(CmpgExpr v)
793 {
794 returnedExpr.setValue
795 (newCmpgExpr(newExpr(v.getOp1()),
796 newExpr(v.getOp2())));
797 }
798
799 public void caseCmplExpr(CmplExpr v)
800 {
801 returnedExpr.setValue
802 (newCmplExpr(newExpr(v.getOp1()),
803 newExpr(v.getOp2())));
804 }
805
806 public void caseDivExpr(DivExpr v)
807 {
808 returnedExpr.setValue
809 (newDivExpr(newExpr(v.getOp1()),
810 newExpr(v.getOp2())));
811 }
812
813 public void caseEqExpr(EqExpr v)
814 {
815 returnedExpr.setValue
816 (newEqExpr(newExpr(v.getOp1()),
817 newExpr(v.getOp2())));
818 }
819
820 public void caseNeExpr(NeExpr v)
821 {
822 returnedExpr.setValue
823 (newNeExpr(newExpr(v.getOp1()),
824 newExpr(v.getOp2())));
825 }
826
827 public void caseGeExpr(GeExpr v)
828 {
829 returnedExpr.setValue
830 (newGeExpr(newExpr(v.getOp1()),
831 newExpr(v.getOp2())));
832 }
833
834 public void caseGtExpr(GtExpr v)
835 {
836 returnedExpr.setValue
837 (newGtExpr(newExpr(v.getOp1()),
838 newExpr(v.getOp2())));
839 }
840
841 public void caseLeExpr(LeExpr v)
842 {
843 returnedExpr.setValue
844 (newLeExpr(newExpr(v.getOp1()),
845 newExpr(v.getOp2())));
846 }
847
848 public void caseLtExpr(LtExpr v)
849 {
850 returnedExpr.setValue
851 (newLtExpr(newExpr(v.getOp1()),
852 newExpr(v.getOp2())));
853 }
854
855 public void caseMulExpr(MulExpr v)
856 {
857 returnedExpr.setValue
858 (newMulExpr(newExpr(v.getOp1()),
859 newExpr(v.getOp2())));
860 }
861
862 public void caseOrExpr(OrExpr v)
863 {
864 returnedExpr.setValue
865 (newOrExpr(newExpr(v.getOp1()),
866 newExpr(v.getOp2())));
867 }
868
869 public void caseRemExpr(RemExpr v)
870 {
871 returnedExpr.setValue
872 (newRemExpr(newExpr(v.getOp1()),
873 newExpr(v.getOp2())));
874 }
875
876 public void caseShlExpr(ShlExpr v)
877 {
878 returnedExpr.setValue
879 (newShlExpr(newExpr(v.getOp1()),
880 newExpr(v.getOp2())));
881 }
882
883 public void caseShrExpr(ShrExpr v)
884 {
885 returnedExpr.setValue
886 (newShrExpr(newExpr(v.getOp1()),
887 newExpr(v.getOp2())));
888 }
889
890 public void caseUshrExpr(UshrExpr v)
891 {
892 returnedExpr.setValue
893 (newUshrExpr(newExpr(v.getOp1()),
894 newExpr(v.getOp2())));
895 }
896
897 public void caseSubExpr(SubExpr v)
898 {
899 returnedExpr.setValue
900 (newSubExpr(newExpr(v.getOp1()),
901 newExpr(v.getOp2())));
902 }
903
904 public void caseXorExpr(XorExpr v)
905 {
906 returnedExpr.setValue
907 (newXorExpr(newExpr(v.getOp1()),
908 newExpr(v.getOp2())));
909 }
910
911 public void caseInterfaceInvokeExpr(InterfaceInvokeExpr v)
912 {
913 ArrayList newArgList = new ArrayList();
914 for (int i = 0; i < v.getArgCount(); i++)
915 newArgList.add(newExpr(v.getArg(i)));
916 returnedExpr.setValue
917 (newInterfaceInvokeExpr((Local)(v.getBase()),
918 v.getMethodRef(),
919 newArgList));
920 }
921
922 public void caseSpecialInvokeExpr(SpecialInvokeExpr v)
923 {
924 ArrayList newArgList = new ArrayList();
925 for (int i = 0; i < v.getArgCount(); i++)
926 newArgList.add(newExpr(v.getArg(i)));
927 returnedExpr.setValue
928 (newSpecialInvokeExpr((Local)(v.getBase()),
929 v.getMethodRef(),
930 newArgList));
931 }
932
933 public void caseStaticInvokeExpr(StaticInvokeExpr v)
934 {
935 ArrayList newArgList = new ArrayList();
936 for (int i = 0; i < v.getArgCount(); i++)
937 newArgList.add(newExpr(v.getArg(i)));
938 returnedExpr.setValue
939 (newStaticInvokeExpr(v.getMethodRef(),
940 newArgList));
941 }
942
943 public void caseVirtualInvokeExpr(VirtualInvokeExpr v)
944 {
945 ArrayList newArgList = new ArrayList();
946 for (int i = 0; i < v.getArgCount(); i++)
947 newArgList.add(newExpr(v.getArg(i)));
948 returnedExpr.setValue
949 (newVirtualInvokeExpr((Local)(v.getBase()),
950 v.getMethodRef(),
951 newArgList));
952 }
953
954 public void caseCastExpr(CastExpr v)
955 {
956 returnedExpr.setValue(newCastExpr(newExpr(v.getOp()),
957 v.getType()));
958 }
959
960 public void caseInstanceOfExpr(InstanceOfExpr v)
961 {
962 returnedExpr.setValue(newInstanceOfExpr
963 (newExpr(v.getOp()),
964 v.getCheckType()));
965 }
966
967 public void caseNewArrayExpr(NewArrayExpr v)
968 {
969 returnedExpr.setValue(newNewArrayExpr(v.getBaseType(),
970 v.getSize()));
971 }
972
973 public void caseNewMultiArrayExpr(NewMultiArrayExpr v)
974 {
975 returnedExpr.setValue(newNewMultiArrayExpr
976 (v.getBaseType(),
977 v.getSizes()));
978 }
979
980 public void caseNewExpr(NewExpr v)
981 {
982 returnedExpr.setValue(newNewExpr(v.getBaseType()));
983 }
984
985 public void caseLengthExpr(LengthExpr v)
986 {
987 returnedExpr.setValue(newLengthExpr
988 (newExpr(v.getOp())));
989 }
990
991 public void caseNegExpr(NegExpr v)
992 {
993 returnedExpr.setValue(newNegExpr(newExpr(v.getOp())));
994 }
995
996 public void defaultCase(Object v)
997 {
998 returnedExpr.setValue((Expr)v);
999 }
1000 });
1001 return returnedExpr.getValue();
1002 }
1003 else
1004 {
1005 if (value instanceof ArrayRef)
1006 return newArrayRef(((ArrayRef)value).getBase(),
1007 newExpr(((ArrayRef)value).getIndex()));
1008 if (value instanceof InstanceFieldRef)
1009 return newInstanceFieldRef
1010 (newExpr((((InstanceFieldRef)value).getBase())),
1011 ((InstanceFieldRef)value).getFieldRef());
1012
1013 return value;
1014 }
1015 }
1016
1017
1018 public FrimpBody newBody(SootMethod m)
1019 {
1020 return new FrimpBody(m);
1021 }
1022
1023
1024 public FrimpBody newBody(Body b, String phase)
1025 {
1026 return new FrimpBody(b);
1027 }
1028
1029 public static Value cloneIfNecessary(Value val)
1030 {
1031 if( val instanceof Local || val instanceof Constant )
1032 return val;
1033 else
1034 return (Value) val.clone();
1035 }
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074 public static String toQ(Type x){
1075 return FuriaConstructDefinitions.FURIA_ftype + "(" + ")";
1076 }
1077
1078 public static String toQ(SootFieldRef x){
1079 return FuriaConstructDefinitions.FURIA_ffieldRef + "(" + ")";
1080 }
1081
1082 public static String toQ(SootMethodRef x){
1083
1084 return FuriaConstructDefinitions.FURIA_fmethodRef + "(" + ")";
1085 }
1086
1087 public static String quote(String x){
1088 String res = x;
1089 res = StringTools.getEscapedStringOf(x);
1090 res = res.replaceAll("\\n", "n");
1091 res = res.replaceAll("\\\"", "&q" );
1092 res = res.replaceAll("[\"]", "&q" );
1093 res = res.replace('"' , 'q' );
1094 res = res.replace('"' , 'q' );
1095
1096 res = res.replace('\\' , 'b' );
1097
1098 return "\"" + res + "\"";
1099 }
1100
1101 public static String toQ(Value x)throws Exception {
1102 String res = "(x . x)";
1103
1104
1105 assert x != null;
1106
1107 if (x instanceof Qable) {
1108
1109 Qable t = (Qable) x;
1110 res = t.toQ();
1111
1112 } else if (x instanceof Local) {
1113
1114 res = FuriaConstructDefinitions.FURIA_flocalRef + "(" + ")";
1115
1116 }else if (x instanceof NullConstant) {
1117
1118 res = FuriaConstructDefinitions.FURIA_fnull + "()";
1119
1120 }else if (x instanceof ParameterRef) {
1121
1122 ParameterRef p = (ParameterRef)x;
1123 res = FuriaConstructDefinitions.FURIA_fparameterRef + "(" + ")";
1124
1125 }else if (x instanceof JNewExpr) {
1126 JNewExpr n = (JNewExpr)x;
1127
1128 res = FuriaConstructDefinitions.FURIA_fnew + "(" +")";
1129
1130 }else if (x instanceof IntConstant) {
1131
1132 res = FuriaConstructDefinitions.FURIA_fintConstant + "(" + formatNum((IntConstant)x) + ")";
1133
1134 }else if (x instanceof FloatConstant) {
1135
1136 res = FuriaConstructDefinitions.FURIA_ffloatConstant + "(" + formatNum((FloatConstant)x) + ")";
1137
1138 }else if (x instanceof DoubleConstant) {
1139
1140 res = FuriaConstructDefinitions.FURIA_fdoubleConstant + "(" + formatNum((DoubleConstant)x) + ")";
1141
1142 }else if (x instanceof JCaughtExceptionRef) {
1143
1144 res = FuriaConstructDefinitions.FURIA_fcaughtException + "()";
1145
1146 }else if (x instanceof StringConstant) {
1147
1148 res = FuriaConstructDefinitions.FURIA_fstringConstant + "(" + ")";
1149
1150 }else if (x instanceof StaticFieldRef) {
1151
1152 StaticFieldRef s = (StaticFieldRef)x;
1153
1154 res = FuriaConstructDefinitions.FURIA_fstaticFieldRef + "(" +")";
1155
1156 }else if (x instanceof ThisRef) {
1157
1158 res = FuriaConstructDefinitions.FURIA_fthisRef + "(" + ")";
1159 }else if (x instanceof LongConstant){
1160
1161 res = FuriaConstructDefinitions.FURIA_flongConstant + "(" + formatNum((LongConstant)x) + ")";
1162
1163 }else if(x instanceof ClassConstant){
1164
1165 res = FuriaConstructDefinitions.FURIA_fclassConstant + "(" + ")";
1166
1167 }else {
1168 String msg = "This value is not Q-able: " + x
1169 + " Value class name: " + x.getClass().getName();
1170 logger.error(msg);
1171 logger.error("This furia process is screwed up from now on!");
1172 assert false : msg;
1173 }
1174
1175 return res;
1176 }
1177
1178 public static String formatNum(LongConstant x){
1179 float r = x.value;
1180 return "" + r;
1181 }
1182
1183 public static String formatNum(FloatConstant x){
1184 float r = x.value;
1185 return "" + r;
1186 }
1187
1188 public static String formatNum(IntConstant x){
1189 int r = x.value;
1190 return "" + r;
1191 }
1192
1193 public static String formatNum(DoubleConstant x){
1194 double r = x.value;
1195 return "" + r;
1196 }
1197
1198
1199
1200 public static List convertUseBoxesListToValues(List useBoxes){
1201 Iterator it = useBoxes.iterator();
1202 List res = new LinkedList();
1203 while(it.hasNext()){
1204 Value v = ((ValueBox)it.next()).getValue();
1205 res.add(v);
1206 }
1207 return res;
1208 }
1209
1210 }