Mercurial > hg > octave-nkf
annotate src/pt-loop.h @ 14626:f947d2922feb stable rc-3-6-2-0
3.6.2-rc0 release candidate
* configure.ac (AC_INIT): Version is now 3.6.2-rc0.
(OCTAVE_RELEASE_DATE): Now 2012-05-11.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 11 May 2012 13:46:18 -0400 |
parents | 72c96de7a403 |
children | 3f81e8b42955 |
rev | line source |
---|---|
2982 | 1 /* |
2 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
13245
diff
changeset
|
3 Copyright (C) 1996-2012 John W. Eaton |
2982 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
2982 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
2982 | 20 |
21 */ | |
22 | |
23 #if !defined (octave_tree_loop_h) | |
24 #define octave_tree_loop_h 1 | |
25 | |
26 class octave_value; | |
27 class octave_lvalue; | |
28 | |
29 class tree_argument_list; | |
30 class tree_expression; | |
31 class tree_statement_list; | |
32 | |
33 class tree_walker; | |
34 | |
3665 | 35 #include "comment-list.h" |
2982 | 36 #include "pt-cmd.h" |
7336 | 37 #include "symtab.h" |
2982 | 38 |
39 // While. | |
40 | |
41 class | |
42 tree_while_command : public tree_command | |
43 { | |
44 public: | |
45 | |
46 tree_while_command (int l = -1, int c = -1) | |
3665 | 47 : tree_command (l, c), expr (0), list (0), lead_comm (0), |
48 trail_comm (0) { } | |
2982 | 49 |
3665 | 50 tree_while_command (tree_expression *e, |
10313 | 51 octave_comment_list *lc = 0, |
52 octave_comment_list *tc = 0, | |
53 int l = -1, int c = -1) | |
3665 | 54 : tree_command (l, c), expr (e), list (0), lead_comm (lc), |
55 trail_comm (tc) { } | |
2982 | 56 |
57 tree_while_command (tree_expression *e, tree_statement_list *lst, | |
10313 | 58 octave_comment_list *lc = 0, |
59 octave_comment_list *tc = 0, | |
60 int l = -1, int c = -1) | |
3665 | 61 : tree_command (l, c), expr (e), list (lst), lead_comm (lc), |
62 trail_comm (tc) { } | |
2982 | 63 |
64 ~tree_while_command (void); | |
65 | |
66 tree_expression *condition (void) { return expr; } | |
67 | |
68 tree_statement_list *body (void) { return list; } | |
69 | |
3665 | 70 octave_comment_list *leading_comment (void) { return lead_comm; } |
71 | |
72 octave_comment_list *trailing_comment (void) { return trail_comm; } | |
73 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
74 tree_command *dup (symbol_table::scope_id scope, |
10313 | 75 symbol_table::context_id context) const; |
5861 | 76 |
2982 | 77 void accept (tree_walker& tw); |
78 | |
3484 | 79 protected: |
2982 | 80 |
81 // Expression to test. | |
82 tree_expression *expr; | |
83 | |
84 // List of commands to execute. | |
85 tree_statement_list *list; | |
2988 | 86 |
3665 | 87 // Comment preceding WHILE token. |
88 octave_comment_list *lead_comm; | |
89 | |
90 // Comment preceding ENDWHILE token. | |
91 octave_comment_list *trail_comm; | |
92 | |
3484 | 93 private: |
94 | |
2988 | 95 // No copying! |
96 | |
97 tree_while_command (const tree_while_command&); | |
98 | |
99 tree_while_command& operator = (const tree_while_command&); | |
2982 | 100 }; |
101 | |
3484 | 102 // Do-Until. |
103 | |
104 class | |
105 tree_do_until_command : public tree_while_command | |
106 { | |
107 public: | |
108 | |
109 tree_do_until_command (int l = -1, int c = -1) | |
110 : tree_while_command (l, c) { } | |
111 | |
3665 | 112 tree_do_until_command (tree_expression *e, |
10313 | 113 octave_comment_list *lc = 0, |
114 octave_comment_list *tc = 0, | |
115 int l = -1, int c = -1) | |
3665 | 116 : tree_while_command (e, lc, tc, l, c) { } |
3484 | 117 |
118 tree_do_until_command (tree_expression *e, tree_statement_list *lst, | |
10313 | 119 octave_comment_list *lc = 0, |
120 octave_comment_list *tc = 0, | |
121 int l = -1, int c = -1) | |
3665 | 122 : tree_while_command (e, lst, lc, tc, l, c) { } |
3484 | 123 |
124 ~tree_do_until_command (void) { } | |
125 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
126 tree_command *dup (symbol_table::scope_id scope, |
10313 | 127 symbol_table::context_id context) const; |
5861 | 128 |
3484 | 129 void accept (tree_walker& tw); |
130 | |
131 private: | |
132 | |
133 // No copying! | |
134 | |
135 tree_do_until_command (const tree_do_until_command&); | |
136 | |
137 tree_do_until_command& operator = (const tree_do_until_command&); | |
138 }; | |
139 | |
2982 | 140 // For. |
141 | |
142 class | |
143 tree_simple_for_command : public tree_command | |
144 { | |
145 public: | |
146 | |
147 tree_simple_for_command (int l = -1, int c = -1) | |
13245
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
148 : tree_command (l, c), parallel (false), lhs (0), expr (0), |
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
149 maxproc (0), list (0), lead_comm (0), trail_comm (0) { } |
2982 | 150 |
13245
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
151 tree_simple_for_command (bool parallel_arg, tree_expression *le, |
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
152 tree_expression *re, |
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
153 tree_expression *maxproc_arg, |
10313 | 154 tree_statement_list *lst, |
155 octave_comment_list *lc = 0, | |
156 octave_comment_list *tc = 0, | |
157 int l = -1, int c = -1) | |
13245
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
158 : tree_command (l, c), parallel (parallel_arg), lhs (le), |
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
159 expr (re), maxproc (maxproc_arg), list (lst), |
3665 | 160 lead_comm (lc), trail_comm (tc) { } |
2982 | 161 |
162 ~tree_simple_for_command (void); | |
163 | |
13245
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
164 bool in_parallel (void) { return parallel; } |
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
165 |
2982 | 166 tree_expression *left_hand_side (void) { return lhs; } |
167 | |
168 tree_expression *control_expr (void) { return expr; } | |
169 | |
13245
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
170 tree_expression *maxproc_expr (void) { return maxproc; } |
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
171 |
2982 | 172 tree_statement_list *body (void) { return list; } |
173 | |
3665 | 174 octave_comment_list *leading_comment (void) { return lead_comm; } |
175 | |
176 octave_comment_list *trailing_comment (void) { return trail_comm; } | |
177 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
178 tree_command *dup (symbol_table::scope_id scope, |
10313 | 179 symbol_table::context_id context) const; |
5861 | 180 |
2982 | 181 void accept (tree_walker& tw); |
182 | |
183 private: | |
184 | |
13245
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
185 // TRUE means operate in parallel (subject to the value of the |
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
186 // maxproc expression). |
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
187 bool parallel; |
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
188 |
2982 | 189 // Expression to modify. |
190 tree_expression *lhs; | |
191 | |
192 // Expression to evaluate. | |
193 tree_expression *expr; | |
194 | |
13245
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
195 // Expression to tell how many processors should be used (only valid |
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
196 // if parallel is TRUE). |
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
197 tree_expression *maxproc; |
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
198 |
2982 | 199 // List of commands to execute. |
200 tree_statement_list *list; | |
201 | |
3665 | 202 // Comment preceding FOR token. |
203 octave_comment_list *lead_comm; | |
204 | |
205 // Comment preceding ENDFOR token. | |
206 octave_comment_list *trail_comm; | |
207 | |
2988 | 208 // No copying! |
209 | |
210 tree_simple_for_command (const tree_simple_for_command&); | |
211 | |
212 tree_simple_for_command& operator = (const tree_simple_for_command&); | |
2982 | 213 }; |
214 | |
215 class | |
216 tree_complex_for_command : public tree_command | |
217 { | |
218 public: | |
219 | |
220 tree_complex_for_command (int l = -1, int c = -1) | |
3665 | 221 : tree_command (l, c), lhs (0), expr (0), list (0), lead_comm (0), |
222 trail_comm (0) { } | |
2982 | 223 |
224 tree_complex_for_command (tree_argument_list *le, tree_expression *re, | |
10313 | 225 tree_statement_list *lst, |
226 octave_comment_list *lc = 0, | |
227 octave_comment_list *tc = 0, | |
228 int l = -1, int c = -1) | |
3665 | 229 : tree_command (l, c), lhs (le), expr (re), list (lst), |
230 lead_comm (lc), trail_comm (tc) { } | |
2982 | 231 |
232 ~tree_complex_for_command (void); | |
233 | |
234 tree_argument_list *left_hand_side (void) { return lhs; } | |
235 | |
236 tree_expression *control_expr (void) { return expr; } | |
237 | |
238 tree_statement_list *body (void) { return list; } | |
239 | |
3665 | 240 octave_comment_list *leading_comment (void) { return lead_comm; } |
241 | |
242 octave_comment_list *trailing_comment (void) { return trail_comm; } | |
243 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
244 tree_command *dup (symbol_table::scope_id scope, |
10313 | 245 symbol_table::context_id context) const; |
5861 | 246 |
2982 | 247 void accept (tree_walker& tw); |
248 | |
249 private: | |
250 | |
251 // Expression to modify. | |
252 tree_argument_list *lhs; | |
253 | |
254 // Expression to evaluate. | |
255 tree_expression *expr; | |
256 | |
257 // List of commands to execute. | |
258 tree_statement_list *list; | |
259 | |
3665 | 260 // Comment preceding FOR token. |
261 octave_comment_list *lead_comm; | |
262 | |
263 // Comment preceding ENDFOR token. | |
264 octave_comment_list *trail_comm; | |
265 | |
2988 | 266 // No copying! |
267 | |
268 tree_complex_for_command (const tree_complex_for_command&); | |
269 | |
270 tree_complex_for_command& operator = (const tree_complex_for_command&); | |
2982 | 271 }; |
272 | |
273 #endif |