[SCM] Lisaac compiler branch, mildred-backend, updated. lisaac-0.12-524-g7710f76

Mildred Ki'Lya silkensedai at online.fr
Tue Aug 25 21:53:55 UTC 2009


The following commit has been merged in the mildred-backend branch:
commit 2cd1463e16290852984e6cd55c9e4911c38696c9
Author: Mildred Ki'Lya <silkensedai at online.fr>
Date:   Tue Aug 25 21:44:53 2009 +0200

    Revert type.li so it kind of bootstraps

diff --git a/src/code_life/instr.li b/src/code_life/instr.li
index 197dea5..c5efc97 100644
--- a/src/code_life/instr.li
+++ b/src/code_life/instr.li
@@ -74,8 +74,6 @@ Section Public
   (
     // BUG.
     backend.generate_instruction_deferred Self in buffer;
-    //display buffer;
-    //buffer.append " /* INSTR.genere :: Not genere ! */";
     // FIN BUG.
     //deferred;
   );
diff --git a/src/type/type.li b/src/type/type.li
index 00f8efa..d6ca648 100644
--- a/src/type/type.li
+++ b/src/type/type.li
@@ -454,13 +454,10 @@ Section Public
     + tab:FAST_ARRAY(SLOT_DATA);
     + action:{SLOT_DATA; };
     + tg:TYPE_GENERIC;
-
-    ((slot_run.is_empty) || {slot_run.first != NULL}).if {
-
-      //
-      // Detect recursivity
-      //
-
+    + count_slot:SLOT_DATA;
+    + storage_slot:SLOT_DATA;
+    
+    ((slot_run.is_empty) || {slot_run.first != NULL}).if {                        
       (detect_recursivity_generation).if {
         string_tmp.copy "Compiler limit: Cyclic depending structure definition for ";
         append_name_in string_tmp;
@@ -468,144 +465,275 @@ Section Public
         semantic_error (position,string_tmp);
       };
       detect_recursivity_generation := TRUE;
-
-      //
-      // Depending (generate structs we require)
-      //
-
+            
+      // Depending.
       (slot_run.lower).to (slot_run.upper) do { j:INTEGER;
-        slot := slot_run.item j;
-        ((slot.style = '+') && {slot.lower_style = 0}).if {
+	slot := slot_run.item j;
+	((slot.style = '+') && {slot.lower_style = 0}).if {
           action := { s:SLOT_DATA;
-            (
-              (
-                (s.ensure_count > 0) ||
-                {s.id_section.is_mapping}
-              ) &&
-              {s.type.raw != Self} &&
-              {(s.type.is_expanded) || {s.type.raw.is_block}}
-            ).if {
-              s.type.raw.genere_struct;
+	    (
+	      (
+		(s.ensure_count > 0) || 
+		{s.id_section.is_mapping}
+	      ) && 
+	      {s.type.raw != Self} &&
+	      {(s.type.is_expanded) || {s.type.raw.is_block}}
+            ).if {	                    
+              s.type.raw.genere_struct;                           
             };
-          };
-          (slot.slot_data_list != NULL).if {
-            (slot.slot_data_list.lower).to (slot.slot_data_list.upper) do { k:INTEGER;
-              action.value (slot.slot_data_list.item k);
-            };
-          };
-          action.value (slot.slot_data);
-        };
+	  };
+	  (slot.slot_data_list != NULL).if {
+	    (slot.slot_data_list.lower).to (slot.slot_data_list.upper) do { k:INTEGER;
+	      action.value (slot.slot_data_list.item k);
+	    };
+	  };
+	  action.value (slot.slot_data);
+	};
       };
-
-      //
-      // Sort slot. (whatever that might mean)
-      //
-
+      // Sort slot.
       (slot_run.lower).to (slot_run.upper) do { j:INTEGER;
-        slot := slot_run.item j;
-        (slot.style = '+').if {
-          // In struct.
-          (slot.lower_style = 0).if {
-            action := { s:SLOT_DATA;
-              (
-                (s.id_section.is_mapping) ||
-                {s.ensure_count > 0}
-              ).if {
-                add_slot_struct s;
-              };
-            };
-            (slot.slot_data_list != NULL).if {
-              (slot.slot_data_list.lower).to (slot.slot_data_list.upper) do { k:INTEGER;
-                action.value (slot.slot_data_list.item k);
-              };
+	slot := slot_run.item j;		
+	(slot.style = '+').if {
+	  // In struct.
+	  (slot.lower_style = 0).if {
+	    action := { s:SLOT_DATA;
+	      (
+		(s.id_section.is_mapping) || 
+		{s.ensure_count > 0}
+	      ).if {
+		add_slot_struct s;
+	      };
+	    };
+	    (slot.slot_data_list != NULL).if {
+	      (slot.slot_data_list.lower).to (slot.slot_data_list.upper) do { k:INTEGER;
+		action.value (slot.slot_data_list.item k);
+	      };
+	    };
+	    action.value (slot.slot_data);
+	  };
+	  slot_data := slot.slot_id;
+	  ((slot_data != NULL) && {slot_data.ensure_count > 0}).if {
+	    add_slot_struct slot_data;
+	  };
+	} else {	    
+	  // In global.
+	  (slot.lower_style = 0).if {
+	    action := { s:SLOT_DATA;
+	      (s.ensure_count > 0).if {
+		s.genere output_glob;
+	      };
+	    };
+	    (slot.slot_data_list != NULL).if {
+	      (slot.slot_data_list.lower).to (slot.slot_data_list.upper) do { k:INTEGER;
+		action.value (slot.slot_data_list.item k);
+	      };
+	    };
+	    action.value (slot.slot_data);
+	  };
+	  slot_data := slot.slot_id;
+	  ((slot_data != NULL) && {slot_data.ensure_count > 0}).if {
+	    slot_data.slot_id.genere output_glob;
+	  };
+	};
+      };
+      
+      (
+	(prototype.shortname = ALIAS_STR.prototype_native_array) || 
+	{prototype.shortname = ALIAS_STR.prototype_native_array_volatile}
+      ).if {
+	tg ?= Self;
+	tg.generic_list.first.raw.genere_struct;
+      } else {              
+	(type_c != NULL).if {
+	  0.to 4 do { j:INTEGER;
+	    tab := slot_size.item j;
+	    // BSBS: A tester sont utilit� !
+	    (! tab.is_empty).if {
+	      semantic_error (tab.first.position,"Slot is not possible with a type C");
+	    };	  
+          };
+          (is_java).if_false {            
+            ((shortname = ALIAS_STR.prototype_true) || 
+            {shortname = ALIAS_STR.prototype_false}).if {
+              output_decl.append "#define ";
+              output_decl.append intern_name;
+              output_decl.append "__ ";
+              output_decl.add_last ((shortname = ALIAS_STR.prototype_true).to_character);
+              output_decl.add_last '\n';            
+            }.elseif {is_late_binding} then {	    
+              semantic_error (tab.first.position,"Late binding is not possible with a type C");
+            };            
+          };
+        } else {	  
+          output_decl.append "// ";
+          output_decl.append intern_name;
+          output_decl.add_last '\n';
+          (is_java).if {
+            output_decl.append "static private int __";
+            output_decl.append intern_name;
+            output_decl.append "__ = ";
+          } else {
+            output_decl.append "#define __";
+            output_decl.append intern_name;
+            output_decl.append "__ ";
+          };
+          string_tmp.clear;                    
+	  (is_late_binding).if {	  
+	    id_counter_with_type.append_in output_decl;	  
+            id_counter_with_type := id_counter_with_type + 1;
+            (prototype.style != '-').if {
+              string_tmp.append "  unsigned long __id;\n";
             };
-            action.value (slot.slot_data);
+	    (prototype.is_mapping).if {	    
+	      semantic_error (prototype.position,	    
+	      "Late binding is not possible with `mapping' object.");
+	    };
+	  } else {	  
+	    id_counter_without_type.append_in output_decl;	  
+	    id_counter_without_type := id_counter_without_type + 1;	  
           };
-          slot_data := slot.slot_id;
-          ((slot_data != NULL) && {slot_data.ensure_count > 0}).if {
-            add_slot_struct slot_data;
+          (is_java).if {
+            output_decl.add_last ';';
           };
-        } else {
-          // In global.
-          // Mildred: is that useful to iterate? The action seems empty
-          (slot.lower_style = 0).if {
-            action := { s:SLOT_DATA;
-              (s.ensure_count > 0).if {
+          output_decl.add_last '\n';	
+          (prototype.style = '-').if {
+            string_tmp.append "  lith_object thread;\n";
+            (param_count != 0).if {              
+              1.to param_count do { n:INTEGER;
+                string_tmp.append "  int param_";
+                (n-1).append_in string_tmp;
+                string_tmp.append ";\n";
               };
             };
-            (slot.slot_data_list != NULL).if {
-              (slot.slot_data_list.lower).to (slot.slot_data_list.upper) do { k:INTEGER;
-                action.value (slot.slot_data_list.item k);
+          };
+	  4.downto 0 do { j:INTEGER;
+	    tab := slot_size.item j;
+	    (tab.lower).to (tab.upper) do { i:INTEGER;
+	      slot_data := tab.item i;	      
+	      ((prototype.is_mapping) && {slot_data.type.is_expanded_c}).if {
+		string_tmp.append "  volatile ";
+	      } else {
+		string_tmp.append "  ";	    
+	      };
+	      slot_data.genere string_tmp;
+	    };
+	    tab.clear;
+	  };            
+	  	  
+          (Self = type_block).if {            
+	    string_tmp.append "  void *self;\n";
+	  };
+	  
+	  (string_tmp.is_empty).if {
+	    string_tmp.append "  void *Nothing;\n";
+	  };
+          
+          (is_java).if {
+            output_decl.append "static class __";
+            output_decl.append intern_name;
+            (is_late_binding).if {
+              output_decl.append " extends __OBJ";
+            };
+            output_decl.append " {\n";  
+            output_decl.append string_tmp;
+            (prototype.is_mapping).if {
+              semantic_error (position,"Mapping is not yet implemented for Java code.");
+            };
+            (Self = type_string_constant).if {
+              // STRING_CONSTANT constructor.
+              output_decl.append "\n  public __";
+              output_decl.append intern_name;
+              output_decl.add_last '(';
+              (is_late_binding).if {
+                output_decl.append "int pid,";
               };
+              storage_slot := get_local_slot (ALIAS_STR.slot_storage).slot_data_intern;
+              count_slot   := get_local_slot (ALIAS_STR.slot_count).slot_data_intern;              
+              (count_slot.ensure_count != 0).if {
+                output_decl.append "int pcount,";
+              };
+              (storage_slot.ensure_count != 0).if {
+                output_decl.append "String pstorage,";
+              };
+              output_decl.remove_last 1;
+              output_decl.append ")\n  {\n    ";              
+              (is_late_binding).if {
+                output_decl.append "__id = pid;\n";
+              };
+              (count_slot.ensure_count != 0).if {
+                output_decl.append (count_slot.intern_name);
+                output_decl.append " = pcount;\n";
+              };
+              (storage_slot.ensure_count != 0).if {
+                output_decl.append (storage_slot.intern_name);
+                output_decl.append " = pstorage.toCharArray();\n";
+              };
+              output_decl.append "  };\n";  
             };
-            action.value (slot.slot_data);
-          };
-          slot_data := slot.slot_id;
-          ((slot_data != NULL) && {slot_data.ensure_count > 0}).if {
-          };
-        };
-      };
-
-      //
-      // For NATIVE_ARRAY, only generate the generic type, don't bother
-      // to generate the struct for the NATIVE_ARRAY itself
-      //
-
-      ( // TODO: Mildred: don't use prototype name for detection
-        // Possibly, try to find a way to extend that to any prototype
-        (prototype.shortname = ALIAS_STR.prototype_native_array) ||
-        {prototype.shortname = ALIAS_STR.prototype_native_array_volatile}
-      ).if {
-        tg ?= Self;
-        tg.generic_list.first.raw.genere_struct;
-      } else {
-
-      //
-      // Detect errors
-      //
-
-        (type_c != NULL).if {
-          // Forbid data slots when C type is specified
-          0.to 4 do { j:INTEGER;
-            tab := slot_size.item j;
-            // BSBS: A tester sont utilit� !
-            (! tab.is_empty).if {
-	      string_tmp.copy "Slot is not possible with the C type `";
-              string_tmp.append type_c;
-	      string_tmp.append "' in `";
-              string_tmp.append name;
-	      string_tmp.append "'.";
-              semantic_error ((tab.first.position),string_tmp);
+            // Basic Constructor.
+            output_decl.append "\n  public __";
+            output_decl.append intern_name;
+            output_decl.add_last '(';
+            (is_late_binding).if {              
+              output_decl.append "int pid";
             };
+            output_decl.append ")\n  {\n    ";
+            (is_late_binding).if {
+              output_decl.append "__id = pid;\n";
+            } else {
+              output_decl.append "super();\n";
+            };
+            output_decl.append "  };\n};\n";  
+          }.elseif {alias_slot = NULL} then {                        
+            output_decl.append "struct ";
+            output_decl.append intern_name;
+            output_decl.append "_struct {\n";
+            output_decl.append string_tmp;
+            (prototype.is_mapping).if {
+              output_decl.append "} __attribute__ ((packed));\n";
+            } else {
+              output_decl.append "};\n";
+            };
+	  };	    
+          // Prototype declaration.
+          (is_java).if {
+            output_glob.append "private static __";
+            output_glob.append intern_name;
+            output_glob.add_last ' ';
+            output_glob.append intern_name;
+            output_glob.append "_=new __";
+            output_glob.append intern_name;
+            output_glob.add_last '(';
+            (is_late_binding).if {
+              output_glob.append "__";
+              output_glob.append intern_name;
+              output_glob.append "__";
+            };
+            output_glob.append ");\n";
+          } else {
+            output_glob.append "__";
+            output_glob.append intern_name;
+            output_glob.add_last ' ';
+            output_glob.append intern_name;
+            output_glob.add_last '_';
+            (is_late_binding).if {
+              output_glob.append "={__";
+              output_glob.append intern_name;
+              output_glob.append "__}";
+            };
+            output_glob.append ";\n"; 	            
+            output_glob.append "#define ";
+            output_glob.append intern_name;
+            output_glob.append "__ (&";
+            output_glob.append intern_name;
+            output_glob.append "_)\n\n";	  
           };
-          // Raise an error for C types that have a late binding
-          (is_late_binding &&
-           {shortname != ALIAS_STR.prototype_true} &&
-           {shortname != ALIAS_STR.prototype_false}).if
-          {
-            semantic_error (tab.first.position,
-                            "Late binding is not possible with a type C");
-          };
-        } else {
-          ((is_late_binding) && {prototype.is_mapping}).if {
-            semantic_error ((prototype.position),
-                  "Late binding is not possible with `mapping' object.");
-          };
-        };
-
-        //
-        // Generate code
-        //
-
-        backend.generate_type_struct_for  Self in output_decl;
-        backend.generate_type_globals_for Self in output_glob;
-
+	};
       };
-
-      // Flag on (don't generate twice the code)
+      
+      // Flag on:
       slot_run.force NULL to 0;
-    };
-
+    };    
   );
   
   - genere_typedef <-

-- 
Lisaac compiler



More information about the Lisaac-commits mailing list