OSDN Git Service

save
[jcfa/jcfa.git] / jcfa / src / jp / igapyon / jcfa / JcfaParser.java
index a5c1e19..ad4cd73 100644 (file)
@@ -8,6 +8,7 @@ import jp.igapyon.jcfa.util.JcfaUtil;
 import jp.igapyon.jcfa.vo.JcfaClass;
 import jp.igapyon.jcfa.vo.JcfaCode;
 import jp.igapyon.jcfa.vo.JcfaField;
+import jp.igapyon.jcfa.vo.JcfaLocalVariable;
 import jp.igapyon.jcfa.vo.JcfaMethod;
 import jp.igapyon.jcfa.vo.JcfaUnit;
 
@@ -128,9 +129,17 @@ public class JcfaParser {
 
                jcfaMethod.setName(method.getName());
                jcfaMethod.getComment().setJavaDoc(true);
+
+               {
+                       // push this to local variable.
+                       final JcfaLocalVariable jcfaLocalVariable = new JcfaLocalVariable();
+                       jcfaMethod.getFrame().getLocalVariableList().add(jcfaLocalVariable);
+                       jcfaLocalVariable.setName("this");
+                       jcfaLocalVariable.setType(jcfaClass.getName());
+               }
+
                if (jcfaMethod.getName().equals("<init>")) {
-                       jcfaMethod.getComment().getCommentList()
-                                       .add("Default constructor.");
+                       jcfaMethod.getComment().getCommentList().add("Constructor.");
                } else {
                        jcfaMethod.getComment().getCommentList().add("Method.");
                }
@@ -175,15 +184,62 @@ public class JcfaParser {
                if (operands == Constants.UNPREDICTABLE) {
                        switch (jcfaCode.getOpcode()) {
                        case Constants.TABLESWITCH: {
+                               // pad
+                               // pad
+                               // pad
+                               // pad
+                               // defaultbyte1
+                               // defaultbyte2
+                               // defaultbyte3
+                               // defaultbyte4
+                               // lowbyte1
+                               // lowbyte2
+                               // lowbyte3
+                               // lowbyte4
+                               // highbyte1
+                               // highbyte2
+                               // highbyte3
+                               // highbyte4
+                               // jump offsets here...
+
                                jcfaCode.getComment().getCommentList()
                                                .add("  TODO no support opecode and operands");
+                               int result = JcfaUtil.byte2Int(codes[pc + 1], codes[pc + 2],
+                                               codes[pc + 3], codes[pc + 4]);
+                               jcfaCode.getComment().getCommentList()
+                                               .add("  MEMO skipping operands: " + result);
+                               System.out.println("skipBytes: " + result);
+                               int lookupOp = pc + 5;
+                               short diff = JcfaUtil.byte2UnsignedByte(codes[lookupOp++]);
+                               System.out.println("diff: " + diff);
+
+                               int loopCount = JcfaUtil
+                                               .byte2Int(codes[lookupOp++], codes[lookupOp++],
+                                                               codes[lookupOp++], codes[lookupOp++]);
+                               System.out.println("count: " + loopCount);
+
                                return Constants.UNPREDICTABLE;
                        }
                        case Constants.LOOKUPSWITCH: {
+                               // pad
+                               // pad
+                               // pad
+                               // pad
+                               // defaultbyte1
+                               // defaultbyte2
+                               // defaultbyte3
+                               // defaultbyte4
+                               // npairs1
+                               // npairs2
+                               // npairs3
+                               // npairs4
+                               // match-offset pairs here...
+
                                int result = JcfaUtil.byte2Int(codes[pc + 1], codes[pc + 2],
                                                codes[pc + 3], codes[pc + 4]);
                                jcfaCode.getComment().getCommentList()
                                                .add("  TODO skipping operands: why?: " + result);
+                               System.out.println("skipBytes: " + result);
 
                                int lookupOp = pc + 5;
 
@@ -192,6 +248,8 @@ public class JcfaParser {
                                int loopCount = JcfaUtil
                                                .byte2Int(codes[lookupOp++], codes[lookupOp++],
                                                                codes[lookupOp++], codes[lookupOp++]);
+                               System.out.println("count: " + loopCount);
+
                                // switch table on loopCount.
 
                                short diff2 = JcfaUtil.byte2UnsignedByte(codes[lookupOp++]);
@@ -199,7 +257,8 @@ public class JcfaParser {
                                                .add("  TODO skipping bytes: " + (diff2));
 
                                operands += (lookupOp - pc);
-                               break;
+                               return Constants.UNPREDICTABLE;
+                               // break;
                        }
                        case Constants.WIDE: {
                                jcfaCode.getComment().getCommentList()