GNU Octave  3.8.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-2013 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 }