GNU Octave  4.0.0
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.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2015 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 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26 
27 #include "quit.h"
28 
29 #include "error.h"
30 #include "gripes.h"
31 #include "oct-map.h"
32 #include "oct-lvalue.h"
33 #include "ov.h"
34 #include "pt-arg-list.h"
35 #include "pt-bp.h"
36 #include "pt-cmd.h"
37 #include "pt-exp.h"
38 #include "pt-jit.h"
39 #include "pt-jump.h"
40 #include "pt-loop.h"
41 #include "pt-stmt.h"
42 #include "pt-walk.h"
43 #include "unwind-prot.h"
44 
45 // While.
46 
48 {
49  delete expr;
50  delete list;
51  delete lead_comm;
52  delete trail_comm;
53 #ifdef HAVE_LLVM
54  delete compiled;
55 #endif
56 }
57 
61 {
62  return new tree_while_command (expr ? expr->dup (scope, context) : 0,
63  list ? list->dup (scope, context) : 0,
64  lead_comm ? lead_comm->dup () : 0,
65  trail_comm ? trail_comm->dup (): 0,
66  line (), column ());
67 }
68 
69 void
71 {
72  tw.visit_while_command (*this);
73 }
74 
75 // Do-Until
76 
80 {
81  return new tree_do_until_command (expr ? expr->dup (scope, context) : 0,
82  list ? list->dup (scope, context) : 0,
83  lead_comm ? lead_comm->dup () : 0,
84  trail_comm ? trail_comm->dup (): 0,
85  line (), column ());
86 }
87 
88 void
90 {
91  tw.visit_do_until_command (*this);
92 }
93 
94 // For.
95 
97 {
98  delete lhs;
99  delete expr;
100  delete maxproc;
101  delete list;
102  delete lead_comm;
103  delete trail_comm;
104 #ifdef HAVE_LLVM
105  delete compiled;
106 #endif
107 }
108 
109 tree_command *
112 {
113  return new tree_simple_for_command
114  (parallel, lhs ? lhs->dup (scope, context) : 0,
115  expr ? expr->dup (scope, context) : 0,
116  maxproc ? maxproc->dup (scope, context) : 0,
117  list ? list->dup (scope, context) : 0,
118  lead_comm ? lead_comm->dup () : 0,
119  trail_comm ? trail_comm->dup () : 0, line (), column ());
120 }
121 
122 void
124 {
125  tw.visit_simple_for_command (*this);
126 }
127 
129 {
130  delete lhs;
131  delete expr;
132  delete list;
133  delete lead_comm;
134  delete trail_comm;
135 }
136 
137 tree_command *
140 {
141  return new tree_complex_for_command (lhs ? lhs->dup (scope, context) : 0,
142  expr ? expr->dup (scope, context) : 0,
143  list ? list->dup (scope, context) : 0,
144  lead_comm ? lead_comm->dup () : 0,
145  trail_comm ? trail_comm->dup () : 0,
146  line (), column ());
147 }
148 
149 void
151 {
152  tw.visit_complex_for_command (*this);
153 }
void accept(tree_walker &tw)
Definition: pt-loop.cc:70
octave_comment_list * lead_comm
Definition: pt-loop.h:255
tree_do_until_command(int l=-1, int c=-1)
Definition: pt-loop.h:141
tree_complex_for_command(int l=-1, int c=-1)
Definition: pt-loop.h:275
~tree_simple_for_command(void)
Definition: pt-loop.cc:96
tree_expression * expr
Definition: pt-loop.h:245
octave_comment_list * lead_comm
Definition: pt-loop.h:316
tree_command * dup(symbol_table::scope_id scope, symbol_table::context_id context) const
Definition: pt-loop.cc:59
virtual tree_expression * dup(symbol_table::scope_id, symbol_table::context_id context) const =0
void accept(tree_walker &tw)
Definition: pt-loop.cc:89
~tree_while_command(void)
Definition: pt-loop.cc:47
tree_command * dup(symbol_table::scope_id scope, symbol_table::context_id context) const
Definition: pt-loop.cc:78
tree_statement_list * list
Definition: pt-loop.h:112
tree_command * dup(symbol_table::scope_id scope, symbol_table::context_id context) const
Definition: pt-loop.cc:138
void accept(tree_walker &tw)
Definition: pt-loop.cc:123
virtual void visit_simple_for_command(tree_simple_for_command &)=0
static llvm::LLVMContext & context
Definition: jit-typeinfo.cc:76
tree_simple_for_command(int l=-1, int c=-1)
Definition: pt-loop.h:179
virtual void visit_while_command(tree_while_command &)=0
tree_argument_list * dup(symbol_table::scope_id scope, symbol_table::context_id context) const
Definition: pt-arg-list.cc:333
virtual int line(void) const
Definition: pt.h:45
octave_comment_list * lead_comm
Definition: pt-loop.h:115
virtual void visit_do_until_command(tree_do_until_command &)=0
tree_expression * maxproc
Definition: pt-loop.h:249
void accept(tree_walker &tw)
Definition: pt-loop.cc:150
tree_expression * expr
Definition: pt-loop.h:109
virtual void visit_complex_for_command(tree_complex_for_command &)=0
tree_command * dup(symbol_table::scope_id scope, symbol_table::context_id context) const
Definition: pt-loop.cc:110
octave_comment_list * trail_comm
Definition: pt-loop.h:258
octave_comment_list * trail_comm
Definition: pt-loop.h:118
tree_argument_list * lhs
Definition: pt-loop.h:307
tree_statement_list * list
Definition: pt-loop.h:252
tree_while_command(int l=-1, int c=-1)
Definition: pt-loop.h:48
tree_expression * expr
Definition: pt-loop.h:310
octave_comment_list * dup(void) const
Definition: comment-list.cc:33
virtual int column(void) const
Definition: pt.h:47
jit_info * compiled
Definition: pt-loop.h:261
tree_expression * lhs
Definition: pt-loop.h:242
jit_info * compiled
Definition: pt-loop.h:124
tree_statement_list * dup(symbol_table::scope_id scope, symbol_table::context_id context) const
Definition: pt-stmt.cc:271
octave_comment_list * trail_comm
Definition: pt-loop.h:319
tree_statement_list * list
Definition: pt-loop.h:313