From 1b7d6ae9ea605e75294f59d4fbe86968d93bacd9 Mon Sep 17 00:00:00 2001 From: Doni Pracner Date: Sun, 5 Jan 2014 21:40:19 +0100 Subject: [PATCH] mjc2wsl - jumps have ELSE branches, so that actions have normal ends for the recursive returns --- src/mjc2wsl.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/mjc2wsl.java b/src/mjc2wsl.java index f05d271..2f6aa8d 100644 --- a/src/mjc2wsl.java +++ b/src/mjc2wsl.java @@ -270,6 +270,10 @@ public class mjc2wsl{ } 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; @@ -389,6 +393,7 @@ public class mjc2wsl{ prl(getTopTwo()); prl("IF tempb "+ getRelationFor(op) +" tempa THEN CALL a" + (counter + get2()) + +" ELSE CALL a" + (counter+1) + " FI;"); break; } @@ -458,9 +463,13 @@ public class mjc2wsl{ break; } + boolean wasJump = isJumpCode(op); 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()); -- 2.25.1