From: Doni Pracner Date: Mon, 28 Jul 2014 13:11:06 +0000 (+0200) Subject: mjc2wsl; remove a flag variable when making global vars X-Git-Tag: v0.2.0~16 X-Git-Url: http://svarog.pmf.uns.ac.rs/gitweb/?p=mjc2wsl.git;a=commitdiff_plain;h=cb772f818f110f996bdd38b5da4a1c035838e7e5 mjc2wsl; remove a flag variable when making global vars --- diff --git a/src/com/quemaster/transformations/mjc2wsl/mjc2wsl.java b/src/com/quemaster/transformations/mjc2wsl/mjc2wsl.java index 9a61bbf..f5bb3ea 100644 --- a/src/com/quemaster/transformations/mjc2wsl/mjc2wsl.java +++ b/src/com/quemaster/transformations/mjc2wsl/mjc2wsl.java @@ -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; }