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
authorDoni Pracner <quinnuendo@gmail.com>
Tue, 10 Dec 2013 22:03:33 +0000 (23:03 +0100)
committerDoni Pracner <quinnuendo@gmail.com>
Tue, 10 Dec 2013 22:26:26 +0000 (23:26 +0100)
src/mjc2wsl.java

index b7c572b609049776dfe8e73865b24ce3723d24a1..f84fc3a29ae758a6575b950d061f6ed936d42487 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("\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"));
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner