Imported Debian patch 0.13.1-3
[pkg-lisaac.git] / src / external / arithmetic / expr_unary.li
blobf89d273ffbd5a4cf1ff5b405b5b362e695a3a7bf
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        := EXPR_UNARY;
25   - copyright   := "2003-2007 Benoit Sonntag";
27   
28   - author      := "Sonntag Benoit (bsonntag@loria.fr)";
29   - comment     := "Unary Expression.";
30   
31 Section Inherit
32   
33   + parent_expr:Expanded EXPR;
34   
35 Section Public  
36   
37   - is_invariant:BOOLEAN <- right.is_invariant;
38   
39   + right:EXPR;
40   
41   - symbol:CHARACTER <- 
42   (
43     deferred;
44     ' '
45   );
46   
47   - static_type:TYPE_FULL <- right.static_type;
48   
49   - get_type t:TYPES_TMP <-
50   (        
51     t.add (static_type.raw);
52   );
53   
54   //
55   // Creation.
56   //
57   
58   - create p:POSITION with r:EXPR :SELF <-
59   ( + result:SELF;
60     
61     result := clone;
62     result.make p with r;
63     result
64   );
65   
66   - make p:POSITION with r:EXPR <-
67   (
68     position := p;
69     right := r;
70   );
71   
72   - my_copy:SELF <- SELF.create position with (right.my_copy);
73   
74   //
75   // Comparaison.
76   //
77     
78   - '==' Right 60 other:EXPR :BOOLEAN <-
79   ( + same:SELF;
80     
81     same ?= other;
82     (same != NULL) && {right == same.right}
83   );
84   
85   - remove <-
86   (    
87     right.remove;
88   );
89   
90   //
91   // Execute.
92   //
93   
94   - execute_unlink:INSTR <-
95   (
96     right.execute_unlink
97   );
98   
99   - execute_link:EXPR <-
100   ( + result:EXPR;
101     + old_seq:UINTEGER_32;
102     + right_cst:INTEGER_CST;
103     
104     old_seq := seq_call_and_loop;    
105     right := right.execute_link;     
106     //    
107     right_cst ?= right;
108     // Conservator transformation.
109     result := exec_conservator;
110     ((result = NULL) && {right_cst != NULL}).if {      
111       result := exec_right right_cst;
112     };
113     ((result = NULL) && {old_seq = seq_call_and_loop}).if {    
114       // No conservator transformation.      
115       result := exec;      
116     };
117     (result = NULL).if {
118       result := Self;
119     } else {
120       result.set_position position;
121       new_execute_pass;
122     };
123         
124     result
125   );
126   
127   - exec_conservator:EXPR <- NULL;  
128   
129   - exec_right right_cst:INTEGER_CST :EXPR <- NULL;
130     
131   - exec:EXPR <- NULL;
132     
133   //
134   // Genere.
135   //
136   
137   - genere buffer:STRING <-
138   (
139     buffer.add_last '(';
140     static_type.genere_declaration buffer;
141     buffer.add_last ')';
142     //
143     buffer.add_last '(';
144     buffer.add_last symbol;
145     buffer.add_last ' ';
146     right.genere buffer;
147     buffer.add_last ')';
148   );  
149   
150   //
151   // Display.
152   //
153   
154   - display buffer:STRING <-
155   (
156     buffer.add_last '(';
157     buffer.add_last symbol;
158     buffer.add_last ' ';
159     right.display buffer;
160     buffer.add_last ')';
161   );