1414import org .objectweb .asm .tree .FieldInsnNode ;
1515import org .objectweb .asm .tree .MethodInsnNode ;
1616import org .objectweb .asm .tree .MethodNode ;
17+ import org .objectweb .asm .util .Printer ;
1718
1819import edu .columbia .cs .psl .chroniclerj .struct .AnnotatedMethod ;
1920import edu .columbia .cs .psl .chroniclerj .struct .Expression ;
@@ -84,6 +85,7 @@ public ClassNode analyzeClass(ClassReader cr) {
8485 ClassNode cn = new ClassNode ();
8586 cr .accept (cn , ClassReader .SKIP_DEBUG );
8687
88+ System .out .println ("Analyze " + cn .name );
8789 for (Object o : cn .methods ) {
8890 MethodNode thisMethodNode = (MethodNode ) o ;
8991 AnnotatedMethod thisMethod = findOrAddMethod (cn .name , thisMethodNode );
@@ -93,70 +95,71 @@ public ClassNode analyzeClass(ClassReader cr) {
9395 if ((thisMethodNode .access & ACC_NATIVE ) != 0 ) // is native
9496 NonDeterministicLoggingMethodVisitor .registerNDMethod (cn .name , thisMethodNode .name ,
9597 thisMethodNode .desc );
96-
97- ListIterator <?> i = thisMethodNode .instructions .iterator ();
98- boolean isFirstInsn = true ;
99- while (i .hasNext ()) {
100- AbstractInsnNode n = (AbstractInsnNode ) i .next ();
101- if (n .getType () == AbstractInsnNode .FIELD_INSN ) // Field
102- // Instruction
103- {
104- FieldInsnNode fn = (FieldInsnNode ) n ;
105- if (n .getOpcode () == Opcodes .PUTSTATIC ) {
106- // This instruction is changing a static field. Previous
107- // instruction is the value to set to
108- FieldExpression pi = new FieldExpression (fn .name , fn .owner , fn .desc ,
109- n .getOpcode ());
110- thisMethod .getPutFieldInsns ().add (pi );
111- thisMethod .setMutatesFieldsDirectly ();
112- } else if (n .getOpcode () == Opcodes .PUTFIELD ) {
113-
114- // This instruction is changing a field.
115- // Previous instruction will have the value that we are
116- // setting to
117- FieldExpression pi = new FieldExpression (fn .name , fn .owner , fn .desc ,
118- n .getOpcode ());
119- pi .setParent (parentInstructionOf (thisMethodNode , pi ,
120- thisMethodNode .instructions .iterator (i .previousIndex ())));
121- thisMethod .getPutFieldInsns ().add (pi );
122- thisMethod .setMutatesFieldsDirectly ();
123- }
124- } else if (n .getType () == AbstractInsnNode .METHOD_INSN ) // Method
125- // invocation
126- {
127- MethodInsnNode whatWeCall = (MethodInsnNode ) n ;
128- AnnotatedMethod otherMethod = findOrAddMethod (whatWeCall .owner ,
129- whatWeCall .name , whatWeCall .desc , 0 );
130- otherMethod .functionsThatCallMe .add (thisMethod );
131- MethodExpression otherMethodExp = new MethodExpression (otherMethod ,
132- whatWeCall .getOpcode ());
133- otherMethodExp .getParams ().addAll (
134- paramsOf (thisMethodNode , otherMethodExp ,
135- thisMethodNode .instructions .iterator (i .previousIndex ())));
136-
137- if (whatWeCall .getOpcode () != Opcodes .INVOKESTATIC )
138- otherMethodExp .setParent (parentInstructionOf (thisMethodNode ,
139- otherMethodExp ,
140- thisMethodNode .instructions .iterator (i .previousIndex ())));
141-
142- if (NonDeterministicLoggingMethodVisitor .isND (whatWeCall .owner ,
143- whatWeCall .name , whatWeCall .desc )
144- && whatWeCall .name .equals ("<init>" )
145- && whatWeCall .owner .equals (cn .superName )
146- && thisMethodNode .name .equals ("<init>" ) && isFirstInsn ) {
147- NonDeterministicLoggingMethodVisitor .registerNDMethod (cn .name ,
148- thisMethodNode .name , thisMethodNode .desc );
149- }
150-
151- thisMethod .functionsThatICall .add (otherMethodExp );
152-
153- isFirstInsn = false ;
154- } else if (n .getType () == AbstractInsnNode .INVOKE_DYNAMIC_INSN ) // Invoke
155- // dynamic
156- {
157-
158- }
159- }
98+ //
99+ // ListIterator<?> i = thisMethodNode.instructions.iterator();
100+ // boolean isFirstInsn = true;
101+ // while (i.hasNext()) {
102+ // AbstractInsnNode n = (AbstractInsnNode) i.next();
103+ // System.out.println(n + " " + Printer.OPCODES[n.getOpcode()]);
104+ // if (n.getType() == AbstractInsnNode.FIELD_INSN) // Field
105+ // // Instruction
106+ // {
107+ // FieldInsnNode fn = (FieldInsnNode) n;
108+ // if (n.getOpcode() == Opcodes.PUTSTATIC) {
109+ // // This instruction is changing a static field. Previous
110+ // // instruction is the value to set to
111+ // FieldExpression pi = new FieldExpression(fn.name, fn.owner, fn.desc,
112+ // n.getOpcode());
113+ // thisMethod.getPutFieldInsns().add(pi);
114+ // thisMethod.setMutatesFieldsDirectly();
115+ // } else if (n.getOpcode() == Opcodes.PUTFIELD) {
116+ //
117+ // // This instruction is changing a field.
118+ // // Previous instruction will have the value that we are
119+ // // setting to
120+ // FieldExpression pi = new FieldExpression(fn.name, fn.owner, fn.desc,
121+ // n.getOpcode());
122+ // pi.setParent(parentInstructionOf(thisMethodNode, pi,
123+ // thisMethodNode.instructions.iterator(i.previousIndex())));
124+ // thisMethod.getPutFieldInsns().add(pi);
125+ // thisMethod.setMutatesFieldsDirectly();
126+ // }
127+ // } else if (n.getType() == AbstractInsnNode.METHOD_INSN) // Method
128+ // // invocation
129+ // {
130+ // MethodInsnNode whatWeCall = (MethodInsnNode) n;
131+ // AnnotatedMethod otherMethod = findOrAddMethod(whatWeCall.owner,
132+ // whatWeCall.name, whatWeCall.desc, 0);
133+ // otherMethod.functionsThatCallMe.add(thisMethod);
134+ // MethodExpression otherMethodExp = new MethodExpression(otherMethod,
135+ // whatWeCall.getOpcode());
136+ // otherMethodExp.getParams().addAll(
137+ // paramsOf(thisMethodNode, otherMethodExp,
138+ // thisMethodNode.instructions.iterator(i.previousIndex())));
139+ //
140+ // if (whatWeCall.getOpcode() != Opcodes.INVOKESTATIC)
141+ // otherMethodExp.setParent(parentInstructionOf(thisMethodNode,
142+ // otherMethodExp,
143+ // thisMethodNode.instructions.iterator(i.previousIndex())));
144+ //
145+ // if (NonDeterministicLoggingMethodVisitor.isND(whatWeCall.owner,
146+ // whatWeCall.name, whatWeCall.desc)
147+ // && whatWeCall.name.equals("<init>")
148+ // && whatWeCall.owner.equals(cn.superName)
149+ // && thisMethodNode.name.equals("<init>") && isFirstInsn) {
150+ // NonDeterministicLoggingMethodVisitor.registerNDMethod(cn.name,
151+ // thisMethodNode.name, thisMethodNode.desc);
152+ // }
153+ //
154+ // thisMethod.functionsThatICall.add(otherMethodExp);
155+ //
156+ // isFirstInsn = false;
157+ // } else if (n.getType() == AbstractInsnNode.INVOKE_DYNAMIC_INSN) // Invoke
158+ // // dynamic
159+ // {
160+ //
161+ // }
162+ // }
160163 }
161164 ClassNode ret = new ClassNode ();
162165 ret .name = cn .name ;
0 commit comments