From e8be41bd1cfa257e30acb6b86b3228aecc64776d Mon Sep 17 00:00:00 2001 From: Doni Pracner Date: Wed, 11 Jun 2014 16:37:24 +0200 Subject: [PATCH] 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. --- src/mjc2wsl.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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; } -- 2.25.1