gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
Added a flag variable for conditional jumps.
authorDoni Pracner <quinnuendo@gmail.com>
Wed, 11 Jun 2014 14:37:24 +0000 (16:37 +0200)
committerDoni Pracner <quinnuendo@gmail.com>
Wed, 11 Jun 2014 14:37:24 +0000 (16:37 +0200)
CALL commands should not be used in VAR blocks to go outside
them - so this was introduced. Alternative is to use "global" variables
for the operands.

src/mjc2wsl.java

index dde880ee299a30f46f72d80ff559af68b94629c0..5472d5564234d3b689bcc9ad26f908e0361c2ef7 100644 (file)
@@ -201,6 +201,7 @@ public class mjc2wsl{
                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 := < > > :");
 
@@ -617,10 +618,15 @@ public class mjc2wsl{
                        case jge: {
                                prl(createStartVar("tempa", "tempb"));
                                prl(createTopTwoEStack());
-                               prl("IF tempb " + getRelationFor(op) + " tempa THEN CALL a"
-                                               + (counter + get2()) + " ELSE CALL a" + (counter + 1)
+                               prl("IF tempb " + 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"
+                                               + (counter + get2()) 
+                                               + " ELSE CALL a" + (counter + 1)
+                                               + " FI;");
                                
                                break;
                        }
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner