gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
install doc - another specific distro that it was ran on
[mjc2wsl.git] / src-wsl / transf-exp.wsl
index 8bc0357..6e50137 100755 (executable)
@@ -20,7 +20,11 @@ License along with this program. If not, see
 
 C:"Automatic transformation tool for simplification of WSL";
 C:"code automaticaly translated from assembly using asm2wsl.";
 
 C:"Automatic transformation tool for simplification of WSL";
 C:"code automaticaly translated from assembly using asm2wsl.";
-C:"a simple version";
+C:"experimental version";
+
+C:"set the following so that Action Systems are not automaticaly treated as regular";
+Assume_A_S_Regular := 0;
+
 MW_PROC @Process_Prog() ==
        FOREACH Statement DO
                IF @Trans?(TR_Push_Pop) THEN
 MW_PROC @Process_Prog() ==
        FOREACH Statement DO
                IF @Trans?(TR_Push_Pop) THEN
@@ -31,6 +35,7 @@ MW_PROC @Process_Prog() ==
        FOREACH Statement DO
                IF @ST(@I) = T_A_S THEN 
                        C:"don't need to test for this, works for T_A_S";
        FOREACH Statement DO
                IF @ST(@I) = T_A_S THEN 
                        C:"don't need to test for this, works for T_A_S";
+                       @Trans(TR_Simplify_Action_System, "");
                        IF @Trans?(TR_Collapse_Action_System) THEN
                                @Trans(TR_Collapse_Action_System, "");
                        FI;
                        IF @Trans?(TR_Collapse_Action_System) THEN
                                @Trans(TR_Collapse_Action_System, "");
                        FI;
@@ -40,23 +45,30 @@ MW_PROC @Process_Prog() ==
                        @Delete  
                FI
        OD;
                        @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 
                        @Delete
        FI
        OD;
        C:"remove all the comments ";
        FOREACH Statement DO
        IF @ST(@I) = T_Comment THEN 
                        @Delete
        FI
        OD;
+       FOREACH Statement DO
+             IF @Trans?(TR_Simplify_Item) THEN
+               @Trans(TR_Simplify_Item,"")
+             FI
+       OD;
+
        C:"Convert DO loops into WHILE loops";
        FOREACH Statement DO
                IF @Trans?(TR_Floop_To_While) THEN
                        @Trans(TR_Floop_To_While, "");
                FI
        OD;
        C:"Convert DO loops into WHILE loops";
        FOREACH Statement DO
                IF @Trans?(TR_Floop_To_While) THEN
                        @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, "");
        C:"Go back to the start, and remove redundant";
        @GOTO(< >);
        @Trans(TR_Delete_All_Redundant, "");
@@ -79,10 +91,10 @@ IF @File_Exists?(inifilename) THEN
                        @Process_Prog();
                        Get_New_Name(VAR filename);
                        @PP_Item(@Program, 80, filename);
                        @Process_Prog();
                        Get_New_Name(VAR filename);
                        @PP_Item(@Program, 80, filename);
-                       Prog_Stat(prog);
-                       PRINT("");
-                       PRINT("After Conversion");
-                       Prog_Stat(@Program)
+                       PRINT("<Metrics>");
+                       PRINT(filename);
+                       Prog_Stat_Comp(prog, @Program);
+                       PRINT("</Metrics>")
                FI;
                filename := @Read_Line(inifile)
        OD;
                FI;
                filename := @Read_Line(inifile)
        OD;
@@ -111,6 +123,27 @@ PROC Prog_Stat(Pro VAR)==
   SKIP
 END
 
   SKIP
 END
 
+PROC Prog_Stat_Comp(Pro, After VAR)==
+  VAR < ma := 0, mb :=1 > :
+  ma := @McCabe(Pro);
+  mb := @McCabe(After);
+  PRINT ("McCabe ", ma, "  ", mb, "  ",(mb-ma));
+  ma := @Stat_Count(Pro);
+  mb := @Stat_Count(After);
+  PRINT ("Statem ", ma, "  ",mb, "  ",(mb-ma));
+  ma := @CFDF_Metric(Pro);
+  mb := @CFDF_Metric(After);
+  PRINT ("CF/DF  ", ma,"  ", mb,"  ", (mb-ma));
+  ma := @Total_Size(Pro);
+  mb := @Total_Size(After);
+  PRINT ("Size   ", ma,"  ", mb, "  ",(mb-ma));
+  ma := @Struct_Metric(Pro);
+  mb := @Struct_Metric(After);
+  PRINT ("Struct ", ma, "  ",mb, "  ",(mb-ma));
+  SKIP
+  ENDVAR
+END
+
 PROC Get_New_Name(VAR str) == 
        IF @Ends_With?(str, ".wsl") THEN
                str := SUBSTR(str, 0, SLENGTH(str)-4)
 PROC Get_New_Name(VAR str) == 
        IF @Ends_With?(str, ".wsl") THEN
                str := SUBSTR(str, 0, SLENGTH(str)-4)
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner