gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
mjc2wsl - jumps have ELSE branches, so that actions have normal ends for the recursiv...
authorDoni Pracner <quinnuendo@gmail.com>
Sun, 5 Jan 2014 20:40:19 +0000 (21:40 +0100)
committerDoni Pracner <quinnuendo@gmail.com>
Sun, 5 Jan 2014 20:40:19 +0000 (21:40 +0100)
src/mjc2wsl.java

index f05d271..2f6aa8d 100644 (file)
@@ -270,6 +270,10 @@ public class mjc2wsl{
                        }
                        throw new Exception("Wrong opcode for a relation");
        }
                        }
                        throw new Exception("Wrong opcode for a relation");
        }
+       
+       private boolean isJumpCode(int opcode) {
+                       return (opcode>=jmp) && (opcode<=jge);
+       }
 
        public void convertStream(InputStream ins) throws Exception{
                mainIn = ins;
 
        public void convertStream(InputStream ins) throws Exception{
                mainIn = ins;
@@ -389,6 +393,7 @@ public class mjc2wsl{
                                prl(getTopTwo());
                                prl("IF tempb "+ getRelationFor(op)
                                                +" tempa THEN CALL a" + (counter + get2())
                                prl(getTopTwo());
                                prl("IF tempb "+ getRelationFor(op)
                                                +" tempa THEN CALL a" + (counter + get2())
+                                               +" ELSE CALL a" + (counter+1)
                                                + " FI;");
                                break;
                        }
                                                + " FI;");
                                break;
                        }
@@ -458,9 +463,13 @@ public class mjc2wsl{
                                break;
                        }
 
                                break;
                        }
 
+                       boolean wasJump = isJumpCode(op);
                        op = get();
                        if (op >= 0)
                        op = get();
                        if (op >= 0)
-                               prl("CALL a" + counter + " END");
+                               if (wasJump)
+                                               prl("SKIP END");
+                               else
+                                               prl("CALL a" + counter + " END");
                }
                prl("CALL Z;\nSKIP END\nENDACTIONS;\n");
                prl(getStandardEnd());
                }
                prl("CALL Z;\nSKIP END\nENDACTIONS;\n");
                prl(getStandardEnd());
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner