X-Git-Url: http://svarog.pmf.uns.ac.rs/gitweb/?p=mjc2wsl.git;a=blobdiff_plain;f=src%2Fmjc2wsl.java;h=ee36c5188cf5d9f791352cd67249c4083c0dc43b;hp=86743cf4ce550065181487564ebba4ce00415dec;hb=80adcf724041ab52a9dcea93f395440332901634;hpb=faf53682246bcababbdd97eadd2da1db5ee2e49a diff --git a/src/mjc2wsl.java b/src/mjc2wsl.java index 86743cf..ee36c51 100644 --- a/src/mjc2wsl.java +++ b/src/mjc2wsl.java @@ -10,7 +10,7 @@ import java.util.*; * @author Doni Pracner, http://perun.dmi.rs/pracner http://quemaster.com */ public class mjc2wsl{ - public static String versionN = "0.1.3"; + public static String versionN = "0.1.4"; public static final int M_ERR = 2, M_WAR = 1, M_DEB = 0; @@ -125,6 +125,38 @@ public class mjc2wsl{ private boolean originalInComments = false; + private HashMap opMap = null; + + private String opCodeFile = "mj-bytecodes.properties"; + + private HashMap getOpMap() { + if (opMap==null) { + opMap = new HashMap (60, 0.98f); + try{ + BufferedReader in = new BufferedReader( + new InputStreamReader(getClass().getResourceAsStream(opCodeFile))); + String str = in.readLine(); + while (str != null) { + String[] ss = str.split("="); + opMap.put(Integer.parseInt(ss[0]),ss[1]); + str = in.readLine(); + } + in.close(); + }catch (Exception ex) { + ex.printStackTrace(); + } + } + return opMap; + } + + public String getOpString(int op) { + return getOpMap().get(op); + } + + public String describeOpCode(int op) { + return op + " (" + getOpString(op) + ")"; + } + private InputStream mainIn; private PrintWriter out = null; private int counter = -1; @@ -247,7 +279,7 @@ public class mjc2wsl{ int op = get(); while (op >= 0) { if (originalInComments) - prl(createComment("" + op, C_OC)); + prl(createComment(describeOpCode(op), C_OC)); prl("a" + counter + " == "); switch (op) { case load: { @@ -355,8 +387,11 @@ public class mjc2wsl{ } case return_: { - prl(createComment("return not fully procesed yet")); - message("return not fully procesed yet", M_WAR); + prl("IF EMPTY?(mjvm_mstack) THEN CALL Z ELSE"); + //else we let things return + prl(cmdFromMStack("tempa")); + prl("SKIP FI"); + prl("END b"+counter+" =="); break; } case enter: {