GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
pt-loop.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2017 John W. Eaton
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
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
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
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if ! defined (octave_pt_loop_h)
24 #define octave_pt_loop_h 1
25 
26 #include "octave-config.h"
27 
28 class octave_value;
29 class octave_lvalue;
30 
31 class tree_argument_list;
32 class tree_expression;
34 
35 class tree_walker;
36 
37 #include "comment-list.h"
38 #include "pt-cmd.h"
39 #include "symtab.h"
40 
41 class jit_info;
42 
43 // While.
44 
45 class
47 {
48 public:
49 
50  tree_while_command (int l = -1, int c = -1)
51  : tree_command (l, c), expr (0), list (0), lead_comm (0),
52  trail_comm (0)
53 #if defined (HAVE_LLVM)
54  , compiled (0)
55 #endif
56  { }
57 
59  octave_comment_list *lc = 0,
60  octave_comment_list *tc = 0,
61  int l = -1, int c = -1)
62  : tree_command (l, c), expr (e), list (0), lead_comm (lc),
63  trail_comm (tc)
64 #if defined (HAVE_LLVM)
65  , compiled (0)
66 #endif
67  { }
68 
70  octave_comment_list *lc = 0,
71  octave_comment_list *tc = 0,
72  int l = -1, int c = -1)
73  : tree_command (l, c), expr (e), list (lst), lead_comm (lc),
74  trail_comm (tc)
75 #if defined (HAVE_LLVM)
76  , compiled (0)
77 #endif
78  { }
79 
80  ~tree_while_command (void);
81 
82  tree_expression *condition (void) { return expr; }
83 
84  tree_statement_list *body (void) { return list; }
85 
86  octave_comment_list *leading_comment (void) { return lead_comm; }
87 
88  octave_comment_list *trailing_comment (void) { return trail_comm; }
89 
92 
93  void accept (tree_walker& tw);
94 
95 #if defined (HAVE_LLVM)
96  // some functions use by tree_jit
97  jit_info *get_info (void) const
98  {
99  return compiled;
100  }
101 
102  void stash_info (jit_info *jinfo)
103  {
104  compiled = jinfo;
105  }
106 #endif
107 
108 protected:
109 
110  // Expression to test.
112 
113  // List of commands to execute.
115 
116  // Comment preceding WHILE token.
118 
119  // Comment preceding ENDWHILE token.
121 
122 private:
123 
124 #if defined (HAVE_LLVM)
125  // compiled version of the loop
127 #endif
128 
129  // No copying!
130 
132 
133  tree_while_command& operator = (const tree_while_command&);
134 };
135 
136 // Do-Until.
137 
138 class
140 {
141 public:
142 
143  tree_do_until_command (int l = -1, int c = -1)
144  : tree_while_command (l, c) { }
145 
147  octave_comment_list *lc = 0,
148  octave_comment_list *tc = 0,
149  int l = -1, int c = -1)
150  : tree_while_command (e, lc, tc, l, c) { }
151 
153  octave_comment_list *lc = 0,
154  octave_comment_list *tc = 0,
155  int l = -1, int c = -1)
156  : tree_while_command (e, lst, lc, tc, l, c) { }
157 
159 
162 
163  void accept (tree_walker& tw);
164 
165 private:
166 
167  // No copying!
168 
170 
171  tree_do_until_command& operator = (const tree_do_until_command&);
172 };
173 
174 // For.
175 
176 class
178 {
179 public:
180 
181  tree_simple_for_command (int l = -1, int c = -1)
182  : tree_command (l, c), parallel (false), lhs (0), expr (0),
183  maxproc (0), list (0), lead_comm (0), trail_comm (0)
184 #if defined (HAVE_LLVM)
185  , compiled (0)
186 #endif
187  { }
188 
189  tree_simple_for_command (bool parallel_arg, tree_expression *le,
190  tree_expression *re,
191  tree_expression *maxproc_arg,
192  tree_statement_list *lst,
193  octave_comment_list *lc = 0,
194  octave_comment_list *tc = 0,
195  int l = -1, int c = -1)
196  : tree_command (l, c), parallel (parallel_arg), lhs (le),
197  expr (re), maxproc (maxproc_arg), list (lst),
198  lead_comm (lc), trail_comm (tc)
199 #if defined (HAVE_LLVM)
200  , compiled (0)
201 #endif
202  { }
203 
204  ~tree_simple_for_command (void);
205 
206  bool in_parallel (void) { return parallel; }
207 
208  tree_expression *left_hand_side (void) { return lhs; }
209 
210  tree_expression *control_expr (void) { return expr; }
211 
212  tree_expression *maxproc_expr (void) { return maxproc; }
213 
214  tree_statement_list *body (void) { return list; }
215 
216  octave_comment_list *leading_comment (void) { return lead_comm; }
217 
218  octave_comment_list *trailing_comment (void) { return trail_comm; }
219 
222 
223  void accept (tree_walker& tw);
224 
225 #if defined (HAVE_LLVM)
226  // some functions use by tree_jit
227  jit_info *get_info (void) const
228  {
229  return compiled;
230  }
231 
232  void stash_info (jit_info *jinfo)
233  {
234  compiled = jinfo;
235  }
236 #endif
237 
238 private:
239  // TRUE means operate in parallel (subject to the value of the
240  // maxproc expression).
241  bool parallel;
242 
243  // Expression to modify.
245 
246  // Expression to evaluate.
248 
249  // Expression to tell how many processors should be used (only valid
250  // if parallel is TRUE).
252 
253  // List of commands to execute.
255 
256  // Comment preceding FOR token.
258 
259  // Comment preceding ENDFOR token.
261 
262  // compiled version of the loop
264 
265  // No copying!
266 
268 
270 };
271 
272 class
274 {
275 public:
276 
277  tree_complex_for_command (int l = -1, int c = -1)
278  : tree_command (l, c), lhs (0), expr (0), list (0), lead_comm (0),
279  trail_comm (0) { }
280 
282  tree_statement_list *lst,
283  octave_comment_list *lc = 0,
284  octave_comment_list *tc = 0,
285  int l = -1, int c = -1)
286  : tree_command (l, c), lhs (le), expr (re), list (lst),
287  lead_comm (lc), trail_comm (tc) { }
288 
289  ~tree_complex_for_command (void);
290 
291  tree_argument_list *left_hand_side (void) { return lhs; }
292 
293  tree_expression *control_expr (void) { return expr; }
294 
295  tree_statement_list *body (void) { return list; }
296 
297  octave_comment_list *leading_comment (void) { return lead_comm; }
298 
299  octave_comment_list *trailing_comment (void) { return trail_comm; }
300 
303 
304  void accept (tree_walker& tw);
305 
306 private:
307 
308  // Expression to modify.
310 
311  // Expression to evaluate.
313 
314  // List of commands to execute.
316 
317  // Comment preceding FOR token.
319 
320  // Comment preceding ENDFOR token.
322 
323  // No copying!
324 
326 
328 };
329 
330 #endif
octave_comment_list * trailing_comment(void)
Definition: pt-loop.h:299
octave_comment_list * lead_comm
Definition: pt-loop.h:257
tree_while_command(tree_expression *e, tree_statement_list *lst, octave_comment_list *lc=0, octave_comment_list *tc=0, int l=-1, int c=-1)
Definition: pt-loop.h:69
tree_do_until_command(int l=-1, int c=-1)
Definition: pt-loop.h:143
void stash_info(jit_info *jinfo)
Definition: pt-loop.h:102
The value of lines which begin with a space character are not saved in the history list A value of all commands are saved on the history list
Definition: oct-hist.cc:728
tree_complex_for_command(int l=-1, int c=-1)
Definition: pt-loop.h:277
tree_expression * expr
Definition: pt-loop.h:247
tree_expression * control_expr(void)
Definition: pt-loop.h:293
octave_comment_list * lead_comm
Definition: pt-loop.h:318
tree_while_command(tree_expression *e, octave_comment_list *lc=0, octave_comment_list *tc=0, int l=-1, int c=-1)
Definition: pt-loop.h:58
octave_comment_list * trailing_comment(void)
Definition: pt-loop.h:218
octave_comment_list * leading_comment(void)
Definition: pt-loop.h:216
void stash_info(jit_info *jinfo)
Definition: pt-loop.h:232
tree_do_until_command(tree_expression *e, octave_comment_list *lc=0, octave_comment_list *tc=0, int l=-1, int c=-1)
Definition: pt-loop.h:146
i e
Definition: data.cc:2724
tree_argument_list * left_hand_side(void)
Definition: pt-loop.h:291
tree_statement_list * list
Definition: pt-loop.h:114
jit_info * get_info(void) const
Definition: pt-loop.h:97
octave_comment_list * leading_comment(void)
Definition: pt-loop.h:297
tree_simple_for_command(bool parallel_arg, tree_expression *le, tree_expression *re, tree_expression *maxproc_arg, tree_statement_list *lst, octave_comment_list *lc=0, octave_comment_list *tc=0, int l=-1, int c=-1)
Definition: pt-loop.h:189
tree_statement_list * body(void)
Definition: pt-loop.h:295
tree_statement_list * body(void)
Definition: pt-loop.h:214
octave_comment_list * leading_comment(void)
Definition: pt-loop.h:86
tree_expression * maxproc_expr(void)
Definition: pt-loop.h:212
tree_expression * control_expr(void)
Definition: pt-loop.h:210
static llvm::LLVMContext & context
Definition: jit-typeinfo.cc:76
if(nargin< 2) print_usage()
Definition: cellfun.cc:405
is false
Definition: cellfun.cc:398
tree_simple_for_command(int l=-1, int c=-1)
Definition: pt-loop.h:181
tree_expression * left_hand_side(void)
Definition: pt-loop.h:208
tree_do_until_command(tree_expression *e, tree_statement_list *lst, octave_comment_list *lc=0, octave_comment_list *tc=0, int l=-1, int c=-1)
Definition: pt-loop.h:152
the sparsity preserving column transformation such that that defines the pivoting threshold can be given in which case it defines the c
Definition: lu.cc:138
octave_comment_list * lead_comm
Definition: pt-loop.h:117
tree_expression * maxproc
Definition: pt-loop.h:251
if they have changed since they were last compiled
Definition: symtab.cc:1707
defaults to zero A value of zero computes the digamma a value the trigamma and so on The digamma function is defined
Definition: psi.cc:68
jit_info * get_info(void) const
Definition: pt-loop.h:227
tree_expression * expr
Definition: pt-loop.h:111
octave_comment_list * trailing_comment(void)
Definition: pt-loop.h:88
~tree_do_until_command(void)
Definition: pt-loop.h:158
tree_complex_for_command(tree_argument_list *le, tree_expression *re, tree_statement_list *lst, octave_comment_list *lc=0, octave_comment_list *tc=0, int l=-1, int c=-1)
Definition: pt-loop.h:281
octave_comment_list * trail_comm
Definition: pt-loop.h:260
octave_comment_list * trail_comm
Definition: pt-loop.h:120
tree_argument_list * lhs
Definition: pt-loop.h:309
tree_statement_list * body(void)
Definition: pt-loop.h:84
tree_statement_list * list
Definition: pt-loop.h:254
tree_while_command(int l=-1, int c=-1)
Definition: pt-loop.h:50
tree_expression * expr
Definition: pt-loop.h:312
bool in_parallel(void)
Definition: pt-loop.h:206
jit_info * compiled
Definition: pt-loop.h:263
tree_expression * lhs
Definition: pt-loop.h:244
jit_info * compiled
Definition: pt-loop.h:126
tree_expression * condition(void)
Definition: pt-loop.h:82
octave_comment_list * trail_comm
Definition: pt-loop.h:321
tree_statement_list * list
Definition: pt-loop.h:315