Imported Debian patch 0.13.1-3
[pkg-lisaac.git] / src / profil_slot.li
blob0e6534c276f7cf7072334a8505f2f1b6929f1948
1 ///////////////////////////////////////////////////////////////////////////////
2 //                             Lisaac Compiler                               //
3 //                                                                           //
4 //                   LSIIT - ULP - CNRS - INRIA - FRANCE                     //
5 //                                                                           //
6 //   This program is free software: you can redistribute it and/or modify    //
7 //   it under the terms of the GNU General Public License as published by    //
8 //   the Free Software Foundation, either version 3 of the License, or       //
9 //   (at your option) any later version.                                     //
10 //                                                                           //
11 //   This program is distributed in the hope that it will be useful,         //
12 //   but WITHOUT ANY WARRANTY; without even the implied warranty of          //
13 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           //
14 //   GNU General Public License for more details.                            //
15 //                                                                           //
16 //   You should have received a copy of the GNU General Public License       //
17 //   along with this program.  If not, see <http://www.gnu.org/licenses/>.   //
18 //                                                                           //
19 //                     http://isaacproject.u-strasbg.fr/                     //
20 ///////////////////////////////////////////////////////////////////////////////
21 Section Header
22   
23   + name    := PROFIL_SLOT;
25   - copyright   := "2003-2007 Benoit Sonntag";
27   
28   - author  := "Sonntag Benoit (bsonntag@loria.fr)";
29   - comment := "Method with costumization";
30   
31 Section Inherit
32   
33   + parent_profil:Expanded PROFIL; 
34   
35 Section Public
36     
37   - slot:SLOT <- slot_code;
38   
39   - is_interrupt:BOOLEAN <- slot_code.id_section.is_interrupt;  
40   - is_external:BOOLEAN  <- slot_code.id_section.is_external;  
42   + slot_code:SLOT_CODE;
43     
44   + is_context_sensitive:BOOLEAN; 
45   // BSBS: Le bloc passé en argument peux ne pas etre context sensitive
46   // Et puis, cet stat peu changer dans le temps...
47     
48   - set_context_sensitive <-
49   (
50     is_context_sensitive := TRUE;
51   );
53   //
54   // Creation.
55   //
56   
57   - make s:SLOT_CODE with call_lst:FAST_ARRAY[EXPR] verify is_first:BOOLEAN :FAST_ARRAY[WRITE] <-
58   ( + loc:LOCAL;
59     + typ:TYPE_FULL;    
60     + item_lst:FAST_ARRAY[ITM_ARGUMENT];       
61     + idx_result:INTEGER;
62     + type_multiple:ITM_TYPE_MULTI;
63     + type_mono:ITM_TYPE_MONO;
64     + result:FAST_ARRAY[WRITE];
65     
66     PROFIL_LIST.add Self;
67     
68     (s.id_section.is_external).if {
69       name := s.name;
70     } else {
71       name := ALIAS_STR.get_intern (s.name);    
72     };
73     slot_code   := s;
74     type_self   := ITM_TYPE_SELF.to_run;
75             
76     // Arguments.    
77     item_lst := s.base_slot.argument_list;    
78     argument_list := FAST_ARRAY[LOCAL].create_with_capacity (s.base_slot.argument_count); 
79     (item_lst.lower).to (item_lst.upper) do { j:INTEGER;
80       item_lst.item j.to_run argument_list;
81     };
82     ((s.id_section.is_external) && {argument_list.count > 1}).if {
83       (argument_list.lower+1).to (argument_list.upper) do { j:INTEGER;      
84         loc := argument_list.item j;
85         loc.set_ensure_count 1;
86         loc.write (loc.position) value (
87           EXTERNAL_C.create (loc.position) text "/* External slot */"
88           access NULL persistant FALSE type (loc.type)
89         );
90       };
91     };    
92     
93     // Results
94     (s.base_slot.type != ITM_TYPE_MONO.type_void).if {
95       type_multiple ?= s.base_slot.type;
96       (type_multiple != NULL).if {  
97         result_list := FAST_ARRAY[LOCAL].create_with_capacity (type_multiple.count - 1);        
98         idx_result := 1;
99         0.to (type_multiple.upper - 1) do { k:INTEGER;    
100           typ := type_multiple.item k.to_run;   
101           loc := typ.get (s.position) result idx_result;
102           result_list.add_last loc;
103           idx_result := idx_result + 1;
104         };
105         typ := type_multiple.last.to_run;       
106       } else {
107         type_mono ?= s.base_slot.type;
108         typ := type_mono.to_run;
109       };
110       result_last := typ.get (s.position) result idx_result;
111     };
112     //
113     result := write_argument call_lst;
114     //    
115     context := CONTEXT.push_extern (slot_code.position) profil Self;
116     code := list_current;
117     slot_code.create_code is_first;    
118     CONTEXT.pop_extern;    
119     //
120     result
121   );
122       
123   //
124   // Execute.
125   //
126   
127   - remove_inline <-
128   (
129     parent_profil.remove_inline;
130     slot_code.remove_profil Self;    
131   );
132   
133   - remove <-
134   ( 
135     parent_profil.remove;
136     slot_code.remove_profil Self;            
137   );
138   
139   //
140   // Genere.
141   //
142   
143   - is_static:BOOLEAN <- (! slot.id_section.is_interrupt) && {! slot.id_section.is_external};