Mercurial > hg > octave-lyh
annotate src/pt-select.h @ 10833:e5c752231985
delete set/delete breakpoint functions from tree_if_command and tree_switch_command classes
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 29 Jul 2010 17:49:50 -0400 |
parents | f3b65e1ae355 |
children | fd0a3ac60b0e |
rev | line source |
---|---|
2982 | 1 /* |
2 | |
8920 | 3 Copyright (C) 1996, 1997, 2000, 2002, 2004, 2005, 2006, 2007, 2008, 2009 |
7017 | 4 John W. Eaton |
2982 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
2982 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
2982 | 21 |
22 */ | |
23 | |
24 #if !defined (octave_tree_select_h) | |
25 #define octave_tree_select_h 1 | |
26 | |
27 class expression; | |
28 class tree_statement_list; | |
29 | |
30 class tree_walker; | |
31 | |
4219 | 32 #include "base-list.h" |
3665 | 33 #include "comment-list.h" |
2982 | 34 #include "pt-cmd.h" |
7336 | 35 #include "symtab.h" |
2982 | 36 |
37 // If. | |
38 | |
39 class | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
40 tree_if_clause : public tree |
2982 | 41 { |
42 public: | |
43 | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
44 tree_if_clause (int l = -1, int c = -1) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
45 : tree (l, c), expr (0), list (0), lead_comm (0) { } |
2982 | 46 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
47 tree_if_clause (tree_statement_list *sl, octave_comment_list *lc = 0, |
10313 | 48 int l = -1, int c = -1) |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
49 : tree (l, c), expr (0), list (sl), lead_comm (lc) { } |
2982 | 50 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
51 tree_if_clause (tree_expression *e, tree_statement_list *sl, |
10313 | 52 octave_comment_list *lc = 0, |
53 int l = -1, int c = -1) | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
54 : tree (l, c), expr (e), list (sl), lead_comm (lc) { } |
2982 | 55 |
56 ~tree_if_clause (void); | |
57 | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
58 bool is_else_clause (void) { return ! expr; } |
2982 | 59 |
60 tree_expression *condition (void) { return expr; } | |
61 | |
62 tree_statement_list *commands (void) { return list; } | |
63 | |
3665 | 64 octave_comment_list *leading_comment (void) { return lead_comm; } |
65 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
66 tree_if_clause *dup (symbol_table::scope_id scope, |
10313 | 67 symbol_table::context_id context) const; |
5861 | 68 |
2982 | 69 void accept (tree_walker& tw); |
70 | |
71 private: | |
72 | |
73 // The condition to test. | |
74 tree_expression *expr; | |
75 | |
76 // The list of statements to evaluate if expr is true. | |
77 tree_statement_list *list; | |
2988 | 78 |
3665 | 79 // Comment preceding ELSE or ELSEIF token. |
80 octave_comment_list *lead_comm; | |
81 | |
2988 | 82 // No copying! |
83 | |
84 tree_if_clause (const tree_if_clause&); | |
85 | |
86 tree_if_clause& operator = (const tree_if_clause&); | |
2982 | 87 }; |
88 | |
89 class | |
4219 | 90 tree_if_command_list : public octave_base_list<tree_if_clause *> |
2982 | 91 { |
92 public: | |
93 | |
4219 | 94 tree_if_command_list (void) { } |
2982 | 95 |
4219 | 96 tree_if_command_list (tree_if_clause *t) { append (t); } |
2982 | 97 |
98 ~tree_if_command_list (void) | |
99 { | |
4219 | 100 while (! empty ()) |
10313 | 101 { |
102 iterator p = begin (); | |
103 delete *p; | |
104 erase (p); | |
105 } | |
2982 | 106 } |
107 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
108 tree_if_command_list *dup (symbol_table::scope_id scope, |
10313 | 109 symbol_table::context_id context) const; |
5861 | 110 |
2982 | 111 void accept (tree_walker& tw); |
2988 | 112 |
113 private: | |
114 | |
115 // No copying! | |
116 | |
117 tree_if_command_list (const tree_if_command_list&); | |
118 | |
119 tree_if_command_list& operator = (const tree_if_command_list&); | |
2982 | 120 }; |
121 | |
122 class | |
123 tree_if_command : public tree_command | |
124 { | |
125 public: | |
126 | |
127 tree_if_command (int l = -1, int c = -1) | |
3665 | 128 : tree_command (l, c), list (0), lead_comm (0), trail_comm (0) { } |
2982 | 129 |
3665 | 130 tree_if_command (tree_if_command_list *lst, octave_comment_list *lc, |
10313 | 131 octave_comment_list *tc, int l = -1, int c = -1) |
3665 | 132 : tree_command (l, c), list (lst), lead_comm (lc), trail_comm (tc) { } |
2982 | 133 |
134 ~tree_if_command (void); | |
135 | |
136 tree_if_command_list *cmd_list (void) { return list; } | |
137 | |
3665 | 138 octave_comment_list *leading_comment (void) { return lead_comm; } |
139 | |
140 octave_comment_list *trailing_comment (void) { return trail_comm; } | |
141 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
142 tree_command *dup (symbol_table::scope_id scope, |
10313 | 143 symbol_table::context_id context) const; |
5861 | 144 |
2982 | 145 void accept (tree_walker& tw); |
146 | |
147 private: | |
148 | |
149 // List of if commands (if, elseif, elseif, ... else, endif) | |
150 tree_if_command_list *list; | |
2988 | 151 |
3665 | 152 // Comment preceding IF token. |
153 octave_comment_list *lead_comm; | |
154 | |
155 // Comment preceding ENDIF token. | |
156 octave_comment_list *trail_comm; | |
157 | |
2988 | 158 // No copying! |
159 | |
160 tree_if_command (const tree_if_command&); | |
161 | |
162 tree_if_command& operator = (const tree_if_command&); | |
2982 | 163 }; |
164 | |
165 // Switch. | |
166 | |
167 class | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
168 tree_switch_case : public tree |
2982 | 169 { |
170 public: | |
171 | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
172 tree_switch_case (int l = -1, int c = -1) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
173 : tree (l, c), label (0), list (0), lead_comm (0) { } |
2982 | 174 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
175 tree_switch_case (tree_statement_list *sl, octave_comment_list *lc = 0, |
10313 | 176 int l = -1, int c = -1) |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
177 : tree (l, c), label (0), list (sl), lead_comm (lc) { } |
2982 | 178 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
179 tree_switch_case (tree_expression *e, tree_statement_list *sl, |
10313 | 180 octave_comment_list *lc = 0, |
181 int l = -1, int c = -1) | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
182 : tree (l, c), label (e), list (sl), lead_comm (lc) { } |
2982 | 183 |
184 ~tree_switch_case (void); | |
185 | |
3933 | 186 bool is_default_case (void) { return ! label; } |
2982 | 187 |
188 bool label_matches (const octave_value& val); | |
189 | |
190 tree_expression *case_label (void) { return label; } | |
191 | |
192 tree_statement_list *commands (void) { return list; } | |
193 | |
3665 | 194 octave_comment_list *leading_comment (void) { return lead_comm; } |
195 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
196 tree_switch_case *dup (symbol_table::scope_id scope, |
10313 | 197 symbol_table::context_id context) const; |
5861 | 198 |
2982 | 199 void accept (tree_walker& tw); |
200 | |
201 private: | |
202 | |
203 // The case label. | |
204 tree_expression *label; | |
205 | |
206 // The list of statements to evaluate if the label matches. | |
207 tree_statement_list *list; | |
2988 | 208 |
3665 | 209 // Comment preceding CASE or OTHERWISE token. |
210 octave_comment_list *lead_comm; | |
211 | |
2988 | 212 // No copying! |
213 | |
214 tree_switch_case (const tree_switch_case&); | |
215 | |
216 tree_switch_case& operator = (const tree_switch_case&); | |
2982 | 217 }; |
218 | |
219 class | |
4219 | 220 tree_switch_case_list : public octave_base_list<tree_switch_case *> |
2982 | 221 { |
222 public: | |
223 | |
4219 | 224 tree_switch_case_list (void) { } |
2982 | 225 |
4219 | 226 tree_switch_case_list (tree_switch_case *t) { append (t); } |
2982 | 227 |
228 ~tree_switch_case_list (void) | |
229 { | |
4219 | 230 while (! empty ()) |
10313 | 231 { |
232 iterator p = begin (); | |
233 delete *p; | |
234 erase (p); | |
235 } | |
2982 | 236 } |
237 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
238 tree_switch_case_list *dup (symbol_table::scope_id scope, |
10313 | 239 symbol_table::context_id context) const; |
5861 | 240 |
2982 | 241 void accept (tree_walker& tw); |
2988 | 242 |
243 private: | |
244 | |
245 // No copying! | |
246 | |
247 tree_switch_case_list (const tree_switch_case_list&); | |
248 | |
249 tree_switch_case_list& operator = (const tree_switch_case_list&); | |
2982 | 250 }; |
251 | |
252 class | |
253 tree_switch_command : public tree_command | |
254 { | |
255 public: | |
256 | |
257 tree_switch_command (int l = -1, int c = -1) | |
3665 | 258 : tree_command (l, c), expr (0), list (0), lead_comm (0), |
259 trail_comm (0) { } | |
2982 | 260 |
261 tree_switch_command (tree_expression *e, tree_switch_case_list *lst, | |
10313 | 262 octave_comment_list *lc, octave_comment_list *tc, |
263 int l = -1, int c = -1) | |
3665 | 264 : tree_command (l, c), expr (e), list (lst), lead_comm (lc), |
265 trail_comm (tc) { } | |
2982 | 266 |
267 ~tree_switch_command (void); | |
268 | |
269 tree_expression *switch_value (void) { return expr; } | |
270 | |
271 tree_switch_case_list *case_list (void) { return list; } | |
272 | |
3665 | 273 octave_comment_list *leading_comment (void) { return lead_comm; } |
274 | |
275 octave_comment_list *trailing_comment (void) { return trail_comm; } | |
276 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
277 tree_command *dup (symbol_table::scope_id scope, |
10313 | 278 symbol_table::context_id context) const; |
5861 | 279 |
2982 | 280 void accept (tree_walker& tw); |
281 | |
282 private: | |
283 | |
284 // Value on which to switch. | |
285 tree_expression *expr; | |
286 | |
287 // List of cases (case 1, case 2, ..., default) | |
288 tree_switch_case_list *list; | |
2988 | 289 |
3665 | 290 // Comment preceding SWITCH token. |
291 octave_comment_list *lead_comm; | |
292 | |
293 // Comment preceding ENDSWITCH token. | |
294 octave_comment_list *trail_comm; | |
295 | |
2988 | 296 // No copying! |
297 | |
298 tree_switch_command (const tree_switch_command&); | |
299 | |
300 tree_switch_command& operator = (const tree_switch_command&); | |
2982 | 301 }; |
302 | |
303 #endif |