From: Doni Pracner Date: Tue, 10 Dec 2013 22:03:33 +0000 (+0100) Subject: mjc2wsl - CALL op added, Mstack operations added X-Git-Tag: v0.1.3~9 X-Git-Url: https://svarog.pmf.uns.ac.rs/gitweb/?a=commitdiff_plain;h=34fbcd7d5825cd670082f11dcec087e5121c8115;p=mjc2wsl.git mjc2wsl - CALL op added, Mstack operations added --- diff --git a/src/mjc2wsl.java b/src/mjc2wsl.java index b7c572b..f84fc3a 100644 --- a/src/mjc2wsl.java +++ b/src/mjc2wsl.java @@ -112,7 +112,7 @@ public class mjc2wsl{ ret.append("VAR < tempa := 0, tempb := 0, tempres :=0,\n"); for (int i = 0; i <= 3; i++) ret.append("loc" + i + " := 0, "); - ret.append("\n estack := < >, t_e_m_p := 0 > :"); + ret.append("\n estack := < >, mstack := < >, t_e_m_p := 0 > :"); return ret.toString(); } @@ -186,6 +186,8 @@ public class mjc2wsl{ return "C:\"" + type + str.replace("\"", "''") + "\";"; } + //Expression stack + private String cmdToEStack(int i) { return "estack := <" + i + " > ++ estack;"; } @@ -206,6 +208,20 @@ public class mjc2wsl{ return cmdFromEStack("tempa"); } + //Method stack + + private String cmdToMStack(int i) { + return "mstack := <" + i + " > ++ mstack;"; + } + + private String cmdToMStack(String i) { + return "mstack := <" + i + " > ++ mstack;"; + } + + private String cmdFromMStack(String st) { + return st + " := HEAD(mstack); mstack := TAIL(mstack);"; + } + private String getRelationFor(int opcode) throws Exception { switch (opcode) { case jeq: return "="; @@ -330,7 +346,11 @@ public class mjc2wsl{ break; } - //TODO call + case call: { + prl(cmdToMStack(counter+2)); + prl("CALL a" + (counter + get2()) + ";"); + break; + } case return_: { prl(createComment("return not fully procesed yet"));