gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
mjc2wsl; remove a flag variable when making global vars
authorDoni Pracner <quinnuendo@gmail.com>
Mon, 28 Jul 2014 13:11:06 +0000 (15:11 +0200)
committerDoni Pracner <quinnuendo@gmail.com>
Mon, 28 Jul 2014 13:11:06 +0000 (15:11 +0200)
src/com/quemaster/transformations/mjc2wsl/mjc2wsl.java

index 9a61bbf827dba89de8d19a6c2c8766625a39df01..f5bb3ea96b6e8aecd5f8cbb132f0876a193cdc8b 100644 (file)
@@ -182,11 +182,11 @@ public class mjc2wsl{
                ret.append("\nVAR <\n\t");
                if (!genLocalVars){ 
                        ret.append("\n\ttempa := 0, tempb :=0, tempres := 0,");
-               }
+               } else
+                       ret.append("\n\tmjvm_flag_jump := 0,");
                ret.append("mjvm_locals := ARRAY(1,0),");
                ret.append("\n\tmjvm_statics := ARRAY("+numWords+",0),");
                ret.append("\n\tmjvm_arrays := < >,");
-               ret.append("\n\tmjvm_flag_jump := 0,");
                ret.append("\n\tmjvm_objects := < >,");
                ret.append("\n\tmjvm_estack := < >, mjvm_mstack := < > > :");
 
@@ -602,18 +602,26 @@ public class mjc2wsl{
                        case jle:
                        case jgt:
                        case jge: {
-                               prl(createStartVar("tempa", "tempb"));
-                               prl(createTopTwoEStack());
-                               prl("IF tempb " + mjInput.getRelationFor(op) 
-                                               + " tempa THEN mjvm_flag_jump := 1"
-                                               + " ELSE mjvm_flag_jump := 0" 
-                                               + " FI;");
-                               prl(createEndVar());
-                               prl("IF mjvm_flag_jump = 1 THEN CALL a"
-                                               + (mjInput.getCounter() + mjInput.get2()) 
-                                               + " ELSE CALL a" + (mjInput.getCounter() + 1)
-                                               + " FI;");
-                               
+                               if (genLocalVars) {
+                                               prl(createStartVar("tempa", "tempb"));
+                                               prl(createTopTwoEStack());
+                                               prl("IF tempb " + mjInput.getRelationFor(op)
+                                                               + " tempa THEN mjvm_flag_jump := 1"
+                                                               + " ELSE mjvm_flag_jump := 0"
+                                                               + " FI;");
+                                               prl(createEndVar());
+                                               prl("IF mjvm_flag_jump = 1 THEN CALL a"
+                                                               + (mjInput.getCounter() + mjInput.get2())
+                                                               + " ELSE CALL a" + (mjInput.getCounter() + 1)
+                                                               + " FI;");
+                               } else {
+                                               prl(createTopTwoEStack());
+                                               prl("IF tempb " + mjInput.getRelationFor(op)
+                                                               + " tempa THEN CALL a"
+                                                               + (mjInput.getCounter() + mjInput.get2())
+                                                               + " ELSE CALL a" + (mjInput.getCounter() + 1)
+                                                               + " FI;");
+                               }
                                break;
                        }
 
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner