X-Git-Url: http://svarog.pmf.uns.ac.rs/gitweb/?p=mjc2wsl.git;a=blobdiff_plain;f=src%2Fmjc2wsl.java;h=18551d13e89223770ff6ec177ef117d30645b74f;hp=dde880ee299a30f46f72d80ff559af68b94629c0;hb=9ad77207956d30c4ad2e3020d389989777e5b7b4;hpb=102044c2e6ad75c7ccd28cc9a11082b819534a7a diff --git a/src/mjc2wsl.java b/src/mjc2wsl.java index dde880e..18551d1 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 := < > > :"); @@ -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; }