From ec3c740bef0052321dad7949b470f3bdc6d6bc03 Mon Sep 17 00:00:00 2001 From: Doni Pracner Date: Wed, 8 Jan 2014 17:29:51 +0100 Subject: [PATCH] mjc2wsl - directives to print Estack on each change --- src/mjc2wsl.java | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/mjc2wsl.java b/src/mjc2wsl.java index 65b6348..886cd7d 100644 --- a/src/mjc2wsl.java +++ b/src/mjc2wsl.java @@ -33,7 +33,8 @@ public class mjc2wsl{ } private boolean addPauseAfterEachAddress=false, - addPrintForEachAddress = false; + addPrintForEachAddress = false, + genPrintEStackOnChange = false; /** Constant used for marking a regular comment from the original file */ public static final char C_REG = ' '; @@ -226,15 +227,21 @@ public class mjc2wsl{ //Expression stack private String cmdToEStack(int i) { - return "mjvm_estack := <" + i + " > ++ mjvm_estack;"; + String res = "mjvm_estack := <" + i + " > ++ mjvm_estack;"; + if (genPrintEStackOnChange) res +="PRINT(\"eStack\",mjvm_estack);"; + return res; } private String cmdToEStack(String i) { - return "mjvm_estack := <" + i + " > ++ mjvm_estack;"; + String res = "mjvm_estack := <" + i + " > ++ mjvm_estack;"; + if (genPrintEStackOnChange) res +="PRINT(\"eStack\",mjvm_estack);"; + return res; } private String cmdFromEStack(String st) { - return st + " := HEAD(mjvm_estack); mjvm_estack := TAIL(mjvm_estack);"; + String res = st + " := HEAD(mjvm_estack); mjvm_estack := TAIL(mjvm_estack);"; + if (genPrintEStackOnChange) res +="PRINT(\"eStack\",mjvm_estack);"; + return res; } private String getTopTwo(){ @@ -516,16 +523,21 @@ public class mjc2wsl{ originalInComments = args[i].charAt(4) == '+'; else originalInComments = true; - } else if (args[i].startsWith("--screen")) { + } else if (args[i].compareTo("--screen") == 0) { out = new PrintWriter(System.out); } else if (args[i].compareTo("-d") == 0) { printLevel = M_DEB;//print debug info } else if (args[i].compareTo("-v") == 0) { printLevel = M_WAR;//print warnings } else if (args[i].compareTo("-q") == 0) { - printLevel = M_ERR+1;//no printing - } - i++; + printLevel = M_ERR+1;//no printing + } else if (args[i].compareToIgnoreCase("--genEStackPrint") == 0) { + genPrintEStackOnChange = true; + } else if (args[i].compareToIgnoreCase("--genAll") == 0) { + genPrintEStackOnChange = true; + addPrintForEachAddress = true; + addPauseAfterEachAddress = true; + }i++; } if (i >= args.length) { -- 2.25.1