[SCM] Lisaac compiler branch, mildred-projects, updated. lisaac-0.12-422-g0699906

Mildred Ki'Lya silkensedai at online.fr
Wed Aug 5 21:23:18 UTC 2009


The following commit has been merged in the mildred-projects branch:
commit 0699906c445c13e74a7a5588b64bc590da8235f4
Author: Mildred Ki'Lya <silkensedai at online.fr>
Date:   Wed Aug 5 23:22:57 2009 +0200

    Share prototypes with the same filepath

diff --git a/make.lip b/make.lip
index 75d7145..366dd59 100644
--- a/make.lip
+++ b/make.lip
@@ -58,17 +58,39 @@ Section Private
   + target:STRING := "unix";
   
   + lib_std :PROJECT;
+  + parent_project :PROJECT;
 
   //
   // Code
   //
 
-  - init prj:PROJECT <-
+  - default_init prj:PROJECT <-
   // Initialize the library
   (
     "Initialize project ".print; Self.print;
     prj.if { " from ".print; prj.print; };
     "\n".print;
+
+    parent_project := prj;
+    parent_project.if {
+      lisaac          := parent_project.lisaac;
+      target          := parent_project.target;
+      debug_level     := parent_project.debug_level;
+      debug_with_code := parent_project.debug_with_code;
+      is_all_warning  := parent_project.is_all_warning;
+      is_optimization := parent_project.is_optimization;
+      inline_level    := parent_project.inline_level;
+      is_java         := parent_project.is_java;
+      is_cop          := parent_project.is_cop;
+      is_statistic    := parent_project.is_statistic;
+      is_quiet        := parent_project.is_quiet;
+    };
+  );
+
+  - init prj:PROJECT <-
+  // Initialize the library
+  (
+    default_init prj;
   );
   
   //
diff --git a/src/item/itm_slot.li b/src/item/itm_slot.li
index e0edd4f..97d42d6 100644
--- a/src/item/itm_slot.li
+++ b/src/item/itm_slot.li
@@ -380,7 +380,9 @@ Section Private
     s.set_result_type result_type;
     t.slot_list.fast_put s to (s.name);      
     (t.generic_count = 0).if {
-      a := ITM_PROTOTYPE.create (v.position) type (ITM_TYPE_SIMPLE.get (t.name) from (t.itm_source));
+      // TODO: Mildred: Check we really want the first PRJ_ITEM from the
+      // prototype
+      a := ITM_PROTOTYPE.create (v.position) type (ITM_TYPE_SIMPLE.get (t.name) from (t.itm_source.first));
     };
     ITM_READ_ARG1.create (v.position) name n arg a
   );
diff --git a/src/item/itm_type_simple.li b/src/item/itm_type_simple.li
index 3f5d1fc..0fd9003 100644
--- a/src/item/itm_type_simple.li
+++ b/src/item/itm_type_simple.li
@@ -133,30 +133,6 @@ Section Public
     result
   );
 
-/*Section SELF
-
-  - get_source n:STRING_CONSTANT from proto:PROTOTYPE or prj:LIP_PROJECT :PRJ_ITEM <-
-  [
-    -? { (proto != NULL) | (prj != NULL) };
-  ]
-  ( + res :PRJ_ITEM;
-
-    (proto = NULL).if {
-      res := proto.itm_source.find_item_prototype n;
-    } else {
-      res := prj.find_item n;
-    };
-    
-    (res = NULL).if {
-      string_tmp.copy n;
-      string_tmp.append " is not found.";
-      semantic_error (current_position, string_tmp);
-      POSITION.send_error;
-    };
-
-    res
-  );*/
-
 Section Public
   
   + to_run_for p:PARAMETER_TO_TYPE :TYPE_FULL <-
diff --git a/src/lip/prj_item.li b/src/lip/prj_item.li
index 85f93af..f3b5220 100644
--- a/src/lip/prj_item.li
+++ b/src/lip/prj_item.li
@@ -38,6 +38,11 @@ Section PRJ_ITEM
 
   - set_prototype p:PROTOTYPE <- deferred [ +? { prototype = p }; ];
 
+  - dico_proto :HASHED_DICTIONARY[PROTOTYPE,STRING_CONSTANT] :=
+    HASHED_DICTIONARY[PROTOTYPE,STRING_CONSTANT].create;
+
+  - self_item_prototype :PRJ_ITM_PROTOTYPE <- (deferred; NULL);
+
 Section Public
 
   + project  :LIP_PROJECT;
@@ -87,6 +92,13 @@ Section Public
 
     (prototype = NULL).if {
       path := filepath;
+      set_prototype (dico_proto.fast_reference_at path);
+      (prototype != NULL).if {
+        prototype.itm_source.add_last self_item_prototype;
+      };
+    };
+
+    (prototype = NULL).if {
       entry := FS_MIN.open_read path;
       ((entry != NULL) /*&& {entry.is_file}*/).if {
 	// Load prototype.
@@ -96,6 +108,7 @@ Section Public
                        source  Self
                        generic_count gen_count;
         set_prototype p;
+        dico_proto.fast_put p to path;
         PARSER.go_on p;
       } else {
 	string_tmp.copy "Cannot open `";
@@ -104,6 +117,7 @@ Section Public
 	semantic_error (last_position, string_tmp);
       };
     };
+
     prototype
   );
 
diff --git a/src/lip/prj_itm_alias.li b/src/lip/prj_itm_alias.li
index 2b8a848..78184a4 100644
--- a/src/lip/prj_itm_alias.li
+++ b/src/lip/prj_itm_alias.li
@@ -38,6 +38,8 @@ Section PRJ_ITEM
 
   - set_prototype p:PROTOTYPE <- source_item.set_prototype p;
 
+  - self_item_prototype :PRJ_ITM_PROTOTYPE <- source_item.self_item_prototype;
+
 Section Public
 
   + source_item :PRJ_ITEM;
diff --git a/src/lip/prj_itm_prototype.li b/src/lip/prj_itm_prototype.li
index 5d181d2..d9fb663 100644
--- a/src/lip/prj_itm_prototype.li
+++ b/src/lip/prj_itm_prototype.li
@@ -41,6 +41,8 @@ Section PRJ_ITEM
     prototype := p;
   );
 
+  - self_item_prototype :PRJ_ITM_PROTOTYPE <- Self;
+
 Section Public
 
   + filename :STRING_CONSTANT;
diff --git a/src/parser.li b/src/parser.li
index 652e749..625c362 100644
--- a/src/parser.li
+++ b/src/parser.li
@@ -187,7 +187,7 @@ Section Private
 
   // This is here because it might require current_position to raise an error
   - find_prototype n:STRING_CONSTANT :PRJ_ITEM <-
-    object.itm_source.project.find_item n from (object.itm_source) or_fail current_position;
+    object.itm_source.first.project.find_item n from (object.itm_source.first) or_fail current_position;
 
   //
   // Syntax parser.
diff --git a/src/type/prototype.li b/src/type/prototype.li
index 9a1da4c..ce81f32 100644
--- a/src/type/prototype.li
+++ b/src/type/prototype.li
@@ -45,7 +45,8 @@ Section Public
   
   + index:INTEGER; // in `prototype_list', for POSITION.
 
-  + itm_source :PRJ_ITEM;
+  + itm_source :FAST_ARRAY[PRJ_ITEM] :=
+    FAST_ARRAY[PRJ_ITEM].create_with_capacity 1;
   
   + shortname:STRING_CONSTANT;
   
@@ -188,7 +189,8 @@ Section Public
     
     filename   := f;
     name       := n;
-    itm_source := s;
+    itm_source := FAST_ARRAY[PRJ_ITEM].create_with_capacity 1;
+    itm_source.add_last s;
     idx := n.fast_last_index_of '.';
     (idx != 0).if {
       string_tmp.copy n;
diff --git a/src/type/type.li b/src/type/type.li
index 2fc4234..eb12366 100644
--- a/src/type/type.li
+++ b/src/type/type.li
@@ -813,10 +813,16 @@ Section Public
     + idx:INTEGER;
     + type_parent:TYPE;
     + ts:ITM_TYPE_SIMPLE;
-            
-    (prototype.itm_source.match n).if {
-      result := TRUE;
-    } else {
+
+    idx := prototype.itm_source.lower;
+    {(idx <= prototype.itm_source.upper) && {!result}}.while_do {
+      (prototype.itm_source.item idx.match n).if {
+        result := TRUE;
+      };
+      idx := idx + 1;
+    };
+
+    result.if_false {
       idx := slot_run.lower;
       {
 	(idx <= slot_run.upper) && 
@@ -831,6 +837,7 @@ Section Public
 	idx := idx + 1;
       };
     };
+
     result
   );
   
@@ -841,111 +848,6 @@ Section TYPE
 
     result := itm_typ.source.load_prototype_generic_count gen_count;
 
-/*
-    + j,idx_path,idx_name,idx_name_old,idx_path_old:INTEGER;
-    + entry:POINTER; 
-    + path,found,n:STRING_CONSTANT;
-    + cn,cp:CHARACTER;
-    + read_char:BLOCK;
-
-    n := itm_typ.name;
-    result := dico_name_to_prototype.fast_reference_at n;        
-    (result = NULL).if {
-      read_char := {
-        cn := n.item idx_name;
-        (cn = '.').if {
-          (
-            (idx_name > n.lower+1) && 
-            {n.item (idx_name-1) = '.'} && 
-            {n.item (idx_name-2) = '.'}
-          ).if {
-            idx_name := idx_name - 2;
-            cn := '*';
-          } else {
-            cn := '/';
-          };
-        } else {
-          cn := cn.to_lower;
-        };
-      };
-      j := path_file.lower;      
-      {(j > path_file.upper) || {result != NULL}}.until_do {      
-        path := path_file.item j;            
-        idx_name := n.upper;
-        idx_path := path.upper-3; // ".li"
-        {
-          read_char.value;
-          cp := path.item idx_path;
-          idx_name := idx_name - 1;
-          idx_path := idx_path - 1;
-        }.do_while {
-          (idx_name >= n.lower) && 
-          {idx_path >= path.lower} && 
-          {cn = cp}
-        };
-        ((idx_name < n.lower) && {cn = cp}).if {
-          ((idx_path < path.lower) || {path.item idx_path = '/'}).if {
-            found := path;            
-          };
-        }.elseif {(cn = '*') && {cp = '/'}} then {        
-          idx_name_old := idx_name+1;
-          idx_path_old := idx_path+1;
-          {(idx_name >= n.lower) && {idx_path >= path.lower}}.while_do {          
-            read_char.value; 
-            cp := path.item idx_path;          
-            (cn = cp).if {            
-              // Nothing.            
-            }.elseif {(cn = '*') && {cp = '/'}} then {                        
-              idx_name_old := idx_name;
-              idx_path_old := idx_path;
-            } else {            
-              idx_name := idx_name_old;
-              idx_path := idx_path_old;
-              {
-                idx_path := idx_path - 1;
-              }.do_while {(idx_path >= path.lower) && {path.item idx_path != '/'}};            
-              idx_path_old := idx_path;
-            };
-            idx_name := idx_name - 1;
-            idx_path := idx_path - 1;                
-          };
-          (idx_name < n.lower).if {
-            found := path;
-          };
-        };        
-        (found != NULL).if {          
-          result := PROTOTYPE.prototype_dico.fast_reference_at found;
-          (result = NULL).if {
-            entry := FS_MIN.open_read found;
-//             ((entry != NULL) && {entry.is_file}).if {
-            (entry != NULL).if {
-              // Load prototype.
-              FS_MIN.close entry;
-              result := PROTOTYPE.create found name n generic_count gen_count;
-              PARSER.go_on result;              
-            } else {
-              string_tmp.copy "Cannot open `";
-              string_tmp.append found;
-              string_tmp.append "'.";
-              semantic_error (last_position,string_tmp);
-            };
-          };
-          dico_name_to_prototype.add result to n;      
-        };
-        j := j + 1;
-      };
-      (result = NULL).if {
-        string_tmp.copy n;
-        string_tmp.append " is not found.";
-        POSITION.put_error semantic text string_tmp;
-        (list_current != NULL).if {
-          list_current.position.put_position;
-        };
-        POSITION.send_error;
-      };	
-    };
-    */
-
     (result.generic_count != gen_count).if {        
       //crash;      
       POSITION.put_error semantic text "Incorrect genericity definition.";
@@ -957,6 +859,7 @@ Section TYPE
       };
       POSITION.send_error;
     };
+
     result
   );
   

-- 
Lisaac compiler



More information about the Lisaac-commits mailing list