gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
mjc2wsl - directives to print Estack on each change
authorDoni Pracner <quinnuendo@gmail.com>
Wed, 8 Jan 2014 16:29:51 +0000 (17:29 +0100)
committerDoni Pracner <quinnuendo@gmail.com>
Wed, 8 Jan 2014 16:29:51 +0000 (17:29 +0100)
src/mjc2wsl.java

index 65b6348cf19b08e6e239f10510daf14464b3a69a..886cd7d3ba0588bb4f413d5362e8e378c1b045e3 100644 (file)
@@ -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) {
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner