gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
mjc2wsl - CALL op added, Mstack operations added
[mjc2wsl.git] / src / mjc2wsl.java
index b7c572b..f84fc3a 100644 (file)
@@ -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("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();
        }
 
                return ret.toString();
        }
@@ -186,6 +186,8 @@ public class mjc2wsl{
                return "C:\"" + type + str.replace("\"", "''") + "\";";
        }
 
                return "C:\"" + type + str.replace("\"", "''") + "\";";
        }
 
+       //Expression stack
+       
        private String cmdToEStack(int i) {
                return "estack := <" + i + " > ++ estack;";
        }
        private String cmdToEStack(int i) {
                return "estack := <" + i + " > ++ estack;";
        }
@@ -206,6 +208,20 @@ public class mjc2wsl{
                return cmdFromEStack("tempa");
        }
        
                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 "=";
        private String getRelationFor(int opcode) throws Exception {
                        switch (opcode) {
                                        case jeq: return "=";
@@ -330,7 +346,11 @@ public class mjc2wsl{
                                break;
                        }
 
                                break;
                        }
 
-                       //TODO call
+                       case call: {
+                               prl(cmdToMStack(counter+2));
+                               prl("CALL a" + (counter + get2()) + ";");
+                               break;
+                       }
 
                        case return_: {
                                prl(createComment("return not fully procesed yet"));
 
                        case return_: {
                                prl(createComment("return not fully procesed yet"));
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner