gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
Merge branch 'master' into work
[mjc2wsl.git] / src / mjc2wsl.java
index 11462f4..f754e4e 100644 (file)
@@ -192,9 +192,7 @@ public class mjc2wsl{
        public String createStandardStart(int numWords){
                StringBuilder ret = new StringBuilder(
                        "C:\" This file automatically converted from microjava bytecode\";\n"
-                       +"C:\" with mjc2wsl v "+versionN+"\";\n\n");
-
-               ret.append(createAsciiString());
+                       +"C:\" with mjc2wsl v "+versionN+"\";\n");
 
                ret.append("\nBEGIN");
                ret.append("\nVAR <\n\t");
@@ -221,7 +219,7 @@ public class mjc2wsl{
                ret.append("\nWHERE\n");
                
                ret.append("\nFUNCT CHR(num) ==:\n");
-               ret.append("\tSUBSTR(ascii,num,1)\n");
+               ret.append("\t@List_To_String(< num >)\n");
                ret.append("END\n");
 
                ret.append("\nPROC Print_MJ(val, format VAR)==\n");
@@ -232,13 +230,9 @@ public class mjc2wsl{
 
                ret.append("\nPROC Print_MJ_CHAR(val, format VAR)==\n");
                ret.append(createComment("print spacing", C_SPEC));
-               ret.append("\n\tIF val=10 OR val=13 THEN\n");
-               ret.append("\t\tPRINT(\"\");\n");
-               ret.append("\tELSE\n");
-               ret.append("\t\tIF format>1 THEN\n\t\t\tFOR i:=2 TO ");
+               ret.append("\n\tIF format>1 THEN\n\t\tFOR i:=2 TO ");
                ret.append("format STEP 1 DO PRINFLUSH(\" \") OD\n");
-               ret.append("\t\tFI;\n\t\tPRINFLUSH(CHR(val))\n");
-               ret.append("\tFI\n");
+               ret.append("\tFI;\n\tPRINFLUSH(CHR(val))\n");
                ret.append("END\n");
 
                ret.append("\nEND");
@@ -442,17 +436,18 @@ public class mjc2wsl{
 
                        case getfield: {
                                int f = get2();
+                               prl(createStartVar("tempa"));
                                prl(createTopEStack());
                                prl(createToEStack(createObject("tempa") + "[" + (f + 1) + "]"));
+                               prl(createEndVar());
                                break;
                        }
                        case putfield: {
                                int f = get2();
-                               // we need to use a temparray as a pointer, WSL
-                               // otherwise tries to access it as a list of lists and fails
-                               prl(createTopTwoEStack());
-                               prl("VAR < tempArray := " + createObject("tempb") + " > :");
-                               prl("tempArray[" + (f + 1) + "]:=tempa ENDVAR;");
+                               prl(createStartVar("tempa", "tempb"));
+                               prl(createTopTwoEStack());                              
+                               prl(createObject("tempb") + "[" + (f + 1) + "]:=tempa;");
+                               prl(createEndVar());
                                break;
                        }
 
@@ -461,6 +456,11 @@ public class mjc2wsl{
                                break;
                        }
 
+                       case const_m1: {
+                               prl(createToEStack(-1));
+                               break;
+                       }
+
                        case const_0:
                        case const_1:
                        case const_2:
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner