annotate src/pt-select.cc @ 11586:12df7854fa7c

strip trailing whitespace from source files
author John W. Eaton <jwe@octave.org>
date Thu, 20 Jan 2011 17:24:59 -0500
parents fd0a3ac60b0e
children 72c96de7a403
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
1 /*
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
2
11523
fd0a3ac60b0e update copyright notices
John W. Eaton <jwe@octave.org>
parents: 10833
diff changeset
3 Copyright (C) 1996-2011 John W. Eaton
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
4
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
6
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5861
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5861
diff changeset
10 option) any later version.
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
11
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
15 for more details.
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
16
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5861
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5861
diff changeset
19 <http://www.gnu.org/licenses/>.
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
20
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
21 */
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
22
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
23 #ifdef HAVE_CONFIG_H
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
24 #include <config.h>
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
25 #endif
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
26
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
27 #include "error.h"
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
28 #include "oct-obj.h"
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
29 #include "ov.h"
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
30 #include "pt-cmd.h"
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
31 #include "pt-exp.h"
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
32 #include "pt-select.h"
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
33 #include "pt-stmt.h"
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
34 #include "pt-walk.h"
3724
3dfae66ad67c [project @ 2000-10-12 05:45:11 by jwe]
jwe
parents: 3665
diff changeset
35 #include "Cell.h"
3dfae66ad67c [project @ 2000-10-12 05:45:11 by jwe]
jwe
parents: 3665
diff changeset
36 #include "ov-typeinfo.h"
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
37
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
38 // If clauses.
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
39
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
40 tree_if_clause::~tree_if_clause (void)
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
41 {
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
42 delete expr;
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
43 delete list;
3665
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3525
diff changeset
44 delete lead_comm;
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
45 }
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
46
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
47 tree_if_clause *
7767
71f068b22fcc scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
48 tree_if_clause::dup (symbol_table::scope_id scope,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
49 symbol_table::context_id context) const
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
50 {
7767
71f068b22fcc scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
51 return new tree_if_clause (expr ? expr->dup (scope, context) : 0,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
52 list ? list->dup (scope, context) : 0,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
53 lead_comm ? lead_comm->dup () : 0);
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
54 }
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
55
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
56 void
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
57 tree_if_clause::accept (tree_walker& tw)
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
58 {
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
59 tw.visit_if_clause (*this);
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
60 }
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
61
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
62 // List of if commands.
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
63
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
64 tree_if_command_list *
7767
71f068b22fcc scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
65 tree_if_command_list::dup (symbol_table::scope_id scope,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
66 symbol_table::context_id context) const
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
67 {
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
68 tree_if_command_list *new_icl = new tree_if_command_list ();
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
69
8913
35cd375d4bb3 make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents: 8843
diff changeset
70 for (const_iterator p = begin (); p != end (); p++)
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
71 {
8913
35cd375d4bb3 make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents: 8843
diff changeset
72 const tree_if_clause *elt = *p;
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
73
7767
71f068b22fcc scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
74 new_icl->append (elt ? elt->dup (scope, context) : 0);
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
75 }
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
76
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
77 return new_icl;
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
78 }
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
79
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
80 void
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
81 tree_if_command_list::accept (tree_walker& tw)
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
82 {
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
83 tw.visit_if_command_list (*this);
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
84 }
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
85
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
86 // If.
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
87
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
88 tree_if_command::~tree_if_command (void)
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
89 {
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
90 delete list;
3665
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3525
diff changeset
91 delete lead_comm;
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3525
diff changeset
92 delete trail_comm;
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
93 }
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
94
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
95 tree_command *
7767
71f068b22fcc scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
96 tree_if_command::dup (symbol_table::scope_id scope,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
97 symbol_table::context_id context) const
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
98 {
7767
71f068b22fcc scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
99 return new tree_if_command (list ? list->dup (scope, context) : 0,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
100 lead_comm ? lead_comm->dup () : 0,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
101 trail_comm ? trail_comm->dup () : 0,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
102 line (), column ());
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
103 }
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
104
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
105 void
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
106 tree_if_command::accept (tree_walker& tw)
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
107 {
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
108 tw.visit_if_command (*this);
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
109 }
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
110
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
111 // Switch cases.
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
112
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
113 tree_switch_case::~tree_switch_case (void)
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
114 {
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
115 delete label;
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
116 delete list;
3665
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3525
diff changeset
117 delete lead_comm;
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
118 }
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
119
3724
3dfae66ad67c [project @ 2000-10-12 05:45:11 by jwe]
jwe
parents: 3665
diff changeset
120
3dfae66ad67c [project @ 2000-10-12 05:45:11 by jwe]
jwe
parents: 3665
diff changeset
121 bool
3dfae66ad67c [project @ 2000-10-12 05:45:11 by jwe]
jwe
parents: 3665
diff changeset
122 tree_switch_case::label_matches (const octave_value& val)
3dfae66ad67c [project @ 2000-10-12 05:45:11 by jwe]
jwe
parents: 3665
diff changeset
123 {
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8346
diff changeset
124 octave_value label_value = label->rvalue1 ();
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
125
3724
3dfae66ad67c [project @ 2000-10-12 05:45:11 by jwe]
jwe
parents: 3665
diff changeset
126 if (! error_state && label_value.is_defined() )
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
127 {
3724
3dfae66ad67c [project @ 2000-10-12 05:45:11 by jwe]
jwe
parents: 3665
diff changeset
128 if (label_value.is_cell ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
129 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
130 Cell cell (label_value.cell_value ());
3724
3dfae66ad67c [project @ 2000-10-12 05:45:11 by jwe]
jwe
parents: 3665
diff changeset
131
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
132 for (octave_idx_type i = 0; i < cell.rows (); i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
133 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
134 for (octave_idx_type j = 0; j < cell.columns (); j++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
135 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
136 bool match = val.is_equal (cell(i,j));
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
137
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
138 if (error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
139 return false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
140 else if (match)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
141 return true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
142 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
143 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
144 }
3724
3dfae66ad67c [project @ 2000-10-12 05:45:11 by jwe]
jwe
parents: 3665
diff changeset
145 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
146 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
147 bool match = val.is_equal (label_value);
3724
3dfae66ad67c [project @ 2000-10-12 05:45:11 by jwe]
jwe
parents: 3665
diff changeset
148
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
149 if (error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
150 return false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
151 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
152 return match;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
153 }
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
154 }
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
155
3724
3dfae66ad67c [project @ 2000-10-12 05:45:11 by jwe]
jwe
parents: 3665
diff changeset
156 return false;
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
157 }
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
158
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
159 tree_switch_case *
7767
71f068b22fcc scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
160 tree_switch_case::dup (symbol_table::scope_id scope,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
161 symbol_table::context_id context) const
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
162 {
7767
71f068b22fcc scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
163 return new tree_switch_case (label ? label->dup (scope, context) : 0,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
164 list ? list->dup (scope, context) : 0,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
165 lead_comm ? lead_comm->dup () : 0);
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
166 }
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
167
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
168 void
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
169 tree_switch_case::accept (tree_walker& tw)
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
170 {
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
171 tw.visit_switch_case (*this);
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
172 }
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
173
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
174 // List of switch cases.
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
175
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
176 tree_switch_case_list *
7767
71f068b22fcc scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
177 tree_switch_case_list::dup (symbol_table::scope_id scope,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
178 symbol_table::context_id context) const
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
179 {
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
180 tree_switch_case_list *new_scl = new tree_switch_case_list ();
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
181
8913
35cd375d4bb3 make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents: 8843
diff changeset
182 for (const_iterator p = begin (); p != end (); p++)
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
183 {
8913
35cd375d4bb3 make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents: 8843
diff changeset
184 const tree_switch_case *elt = *p;
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
185
7767
71f068b22fcc scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
186 new_scl->append (elt ? elt->dup (scope, context) : 0);
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
187 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
188
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
189 return new_scl;
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
190 }
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
191
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
192 void
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
193 tree_switch_case_list::accept (tree_walker& tw)
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
194 {
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
195 tw.visit_switch_case_list (*this);
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
196 }
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
197
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
198 // Switch.
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
199
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
200 tree_switch_command::~tree_switch_command (void)
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
201 {
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
202 delete expr;
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
203 delete list;
3665
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3525
diff changeset
204 delete lead_comm;
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3525
diff changeset
205 delete trail_comm;
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
206 }
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
207
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
208 tree_command *
7767
71f068b22fcc scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
209 tree_switch_command::dup (symbol_table::scope_id scope,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
210 symbol_table::context_id context) const
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
211 {
7767
71f068b22fcc scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
212 return new tree_switch_command (expr ? expr->dup (scope, context) : 0,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
213 list ? list->dup (scope, context) : 0,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
214 lead_comm ? lead_comm->dup () : 0,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
215 trail_comm ? trail_comm->dup () : 0,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
216 line (), column ());
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
217 }
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5775
diff changeset
218
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
219 void
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
220 tree_switch_command::accept (tree_walker& tw)
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
221 {
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
222 tw.visit_switch_command (*this);
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
223 }