+/EE379K
programming paradigms
git clone https://git.julia.blue/+/EE379K
ffe584c
master
1package gov .nasa .jpf ; 2import gov .nasa .jpf .jvm .ClassFile ; 3import gov .nasa .jpf .jvm .bytecode .*; 4import gov .nasa .jpf .report .Publisher ; 5import gov .nasa .jpf .report .PublisherExtension ; 6import gov .nasa .jpf .search .Search ; 7import gov .nasa .jpf .search .SearchListener ; 8import gov .nasa .jpf .vm .ChoiceGenerator ; 9import gov .nasa .jpf .vm .ClassInfo ; 10import gov .nasa .jpf .vm .ElementInfo ; 11import gov .nasa .jpf .vm .Instruction ; 12import gov .nasa .jpf .vm .MethodInfo ; 13import gov .nasa .jpf .vm .ThreadInfo ; 14import gov .nasa .jpf .vm .VM ; 15import gov .nasa .jpf .vm .VMListener ; 16import java .io .*; 17import java .util .*; 18 19class Call { 20public Object []arg_values ; 21public Object ret ; 22 23public Call (Object []arg_values ) {this .arg_values =arg_values ; } 24 25@ Override 26public boolean equals (Object obj ) { 27return Arrays .equals (arg_values , ((Call )obj ).arg_values ); 28 } 29} 30 31public class Memoize extends ListenerAdapter { 32Map <String ,List <Call >>memory =new HashMap (); 33 34@ Override 35public void methodEntered (VM vm ,ThreadInfo currentThread , 36MethodInfo enteredMethod ) { 37// System.out.println(enteredMethod.getName()); 38if (enteredMethod .getName ().equals ("foo" )) { 39System .out .println ("we in there" ); 40 } 41 } 42 43@ Override 44public void methodExited (VM vm ,ThreadInfo currentThread , 45MethodInfo enteredMethod ) { 46// System.out.println(enteredMethod.getName()); 47if (enteredMethod .getName ().equals ("foo" )) { 48System .out .println ("we outta there" ); 49 } 50 } 51 52@ Override 53public void executeInstruction (VM vm ,ThreadInfo currentThread , 54Instruction instructionToExecute ) { 55MethodInfo mi =currentThread .getTopFrameMethodInfo (); 56if (instructionToExecute instanceof INVOKESTATIC ) { 57INVOKESTATIC inst = (INVOKESTATIC )instructionToExecute ; 58System .out .println ("calling static: " +inst .getInvokedMethodName ()); 59Call c =new Call () 60map .put (); 61if (!calls .containsKey ()) 62for (Object o :inst .getArgumentValues (currentThread )) { 63System .out .println (o ); 64 } 65 } 66else if (instructionToExecute instanceof RETURNINT ) { 67instructionToExecute .getRetVal 68 } 69 70// MethodInfo mi = currentThread.getTopFrameMethodInfo(); 71// if (mi != null && mi.getClassName().equals("Demo")) { 72// // if (instructionToExecute instanceof IADD) { 73// // ISUB sub = new ISUB(); 74// // sub.init(mi, instructionToExecute.getInstructionIndex(), 75// instructionToExecute.getPosition()); 76// // currentThread.setNextPC(sub); 77// // } 78// if (instructionToExecute instanceof GETFIELD) { 79// GETFIELD inst = (GETFIELD)instructionToExecute; 80// ElementInfo ei = inst.peekElementInfo(currentThread); 81// ei.setIntField("fff", ei.getIntField("fff") + 1); 82// } 83// } 84}