gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
Merge branch 'master' into work
authorDoni Pracner <quinnuendo@gmail.com>
Fri, 18 Jul 2014 18:45:18 +0000 (20:45 +0200)
committerDoni Pracner <quinnuendo@gmail.com>
Fri, 18 Jul 2014 18:45:18 +0000 (20:45 +0200)
samples/fields.mj [new file with mode: 0644]
src-wsl/transf-exp.wsl
src/mjc2wsl.java

diff --git a/samples/fields.mj b/samples/fields.mj
new file mode 100644 (file)
index 0000000..f29fb26
--- /dev/null
@@ -0,0 +1,44 @@
+program F
+       class HolderClass {
+               int simple;
+               int[] arry;
+       }
+       
+       HolderClass holder;
+       
+{
+       void main()
+               int i, size;
+       {
+               holder = new HolderClass;
+               holder.simple = 5;
+               
+               print(holder.simple,10);
+               
+               print(chr(10));
+               
+               size = 5;
+               holder.arry = new int[size];
+               holder.arry[0] = size+1;
+               i = 1;
+               while (i < size){
+                       holder.arry[i] = holder.arry[i-1]-1;
+                       i++;
+               }
+               
+               i = 0;
+               while (i < size){
+                       print(holder.arry[i],3);
+                       i++;
+               }
+               print(chr(10));
+               
+               i = 0;
+               while (i < size){
+                       holder.arry[i]--;
+                       print(holder.arry[i],3);
+                       i++;
+               }
+               
+       }
+}
\ No newline at end of file
index 1bffdbd..6e50137 100755 (executable)
@@ -45,11 +45,7 @@ MW_PROC @Process_Prog() ==
                        @Delete  
                FI
        OD;
-       FOREACH Statement DO
-               IF @Trans?(TR_Flag_Removal) THEN
-                       @Trans(TR_Flag_Removal, "");
-               FI
-       OD;
+
        C:"remove all the comments ";
        FOREACH Statement DO
        IF @ST(@I) = T_Comment THEN 
@@ -68,6 +64,11 @@ MW_PROC @Process_Prog() ==
                        @Trans(TR_Floop_To_While, "");
                FI
        OD;
+       FOREACH Statement DO
+               IF @Trans?(TR_Flag_Removal) THEN
+                       @Trans(TR_Flag_Removal, "");
+               FI
+       OD;
        C:"Go back to the start, and remove redundant";
        @GOTO(< >);
        @Trans(TR_Delete_All_Redundant, "");
index 6cd59e0..f754e4e 100644 (file)
@@ -436,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;
                        }
 
@@ -455,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