From: Doni Pracner Date: Wed, 11 Jun 2014 14:37:24 +0000 (+0200) Subject: Added a flag variable for conditional jumps. X-Git-Tag: v0.1.7~3 X-Git-Url: https://svarog.pmf.uns.ac.rs/gitweb/?a=commitdiff_plain;h=e8be41bd1cfa257e30acb6b86b3228aecc64776d;p=mjc2wsl.git Added a flag variable for conditional jumps. 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. --- diff --git a/src/mjc2wsl.java b/src/mjc2wsl.java index dde880e..5472d55 100644 --- a/src/mjc2wsl.java +++ b/src/mjc2wsl.java @@ -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; }