Imported Debian patch 0.13.1-3
[pkg-lisaac.git] / src / external / item.li
blob31c60506075f1f7ba6e308de9d7204b0a6e4e9dd
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        := ITEM;
25   - copyright   := "2003-2007 Benoit Sonntag";
27   
28   - author      := "Sonntag Benoit (bsonntag@loria.fr)";
29   - comment     := "Item for NATIVE_ARRAY[type].";
30   
31 Section Inherit
32   
33   + parent_expr:Expanded EXPR;
34   
35 Section Public 
36   
37   - is_invariant:BOOLEAN <- receiver.is_invariant && {index.is_invariant};
38   
39   + receiver:EXPR;
40   
41   + index:EXPR;
42     
43   - static_type:TYPE_FULL <- 
44   ( + t:TYPE_GENERIC;
45     
46     t ?= receiver.static_type.raw;
47     t.generic_list.first    
48   );
49      
50   - get_type t:TYPES_TMP <-
51   ( + typ_gen:TYPE_GENERIC;   
52         
53     typ_gen ?= receiver.static_type.raw;
54     typ_gen.get_type t;    
55   );
56   
57   //
58   // Creation.
59   //
60   
61   - create p:POSITION base rec:EXPR index idx:EXPR :SELF <-
62   ( + result:SELF;
63     
64     result := clone;
65     result.make p base rec index idx;
66     result
67   );
68   
69   - make p:POSITION base rec:EXPR index idx:EXPR <-
70   (
71     position := p;            
72     receiver := rec;
73     index    := idx;
74   );
75   
76   - my_copy:SELF <- SELF.create position base (receiver.my_copy) index (index.my_copy);
77   
78   //
79   // Remove
80   //
81   
82   - remove <-
83   (
84     receiver.remove;
85     index.remove;
86   );
87   
88   //
89   // Execute
90   //
91   
92   - execute_unlink:INSTR <-
93   ( + instr:INSTR;    
94     instr := receiver.execute_unlink;
95     (instr != NULL).if {
96       list_current.insert_before instr;
97     };
98     index.execute_unlink    
99   );
100   
101   - execute_link:EXPR <-
102   (   
103     receiver := receiver.execute_link;
104     index    := index.execute_link;    
105     Self
106   );
107     
108   //
109   // Genere.
110   //
111   
112   - genere buffer:STRING <-
113   (
114     receiver.genere buffer;
115     buffer.add_last '[';
116     index.genere buffer;
117     buffer.add_last ']';    
118   );
119   
120   //
121   // Display.
122   //
123   
124   - display buffer:STRING <-
125   (
126     receiver.display buffer;
127     buffer.add_last '[';
128     index.display buffer;
129     buffer.add_last ']';
130   );