X-Git-Url: http://svarog.pmf.uns.ac.rs/gitweb/?p=mjc2wsl.git;a=blobdiff_plain;f=src%2Fmjc2wsl.java;h=18551d13e89223770ff6ec177ef117d30645b74f;hp=113bfef0c197ae7d515ee65c9ada0209f9d20486;hb=9ad77207956d30c4ad2e3020d389989777e5b7b4;hpb=5e03219e880a35b20ba9c2276f24c1f174264b6c diff --git a/src/mjc2wsl.java b/src/mjc2wsl.java index 113bfef..18551d1 100644 --- a/src/mjc2wsl.java +++ b/src/mjc2wsl.java @@ -28,7 +28,7 @@ import java.util.*; * @author Doni Pracner, http://perun.dmi.rs/pracner http://quemaster.com */ public class mjc2wsl{ - public static String versionN = "0.1.6"; + public static String versionN = "0.1.7"; private TransMessages messages = new TransMessages(); @@ -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 := < > > :"); @@ -569,12 +570,11 @@ public class mjc2wsl{ } case astore: case bastore: { + prl(createStartVar("tempa", "tempb", "tempres")); prl(createFromEStack("tempres")); prl(createTopTwoEStack()); - // we need to use a temparray as a pointer, WSL - // otherwise tries to access it as a list of lists and fails - prl("VAR < tempArray := " + createArray("tempb") + " > :"); - prl("tempArray[tempa+1]:=tempres ENDVAR;"); + prl("mjvm_arrays[tempb][tempa+1]:=tempres;"); + prl(createEndVar()); break; } case arraylength: { @@ -617,10 +617,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; }