Mercurial > hg > octave-jordi
annotate libinterp/parse-tree/pt-select.cc @ 21016:93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
* Backend.cc, comment-list.h, debug.cc, defaults.in.h, dynamic-ld.h, error.cc,
graphics.cc, graphics.in.h, help.cc, hook-fcn.h, load-path.cc, load-path.h,
ls-ascii-helper.cc, ls-mat-ascii.cc, ls-mat5.cc, ls-mat5.h, ls-oct-text.cc,
oct-iostrm.h, oct-lvalue.h, oct-stream.cc, oct-stream.h, oct-strstrm.h,
regexp.cc, schur.cc, sqrtm.cc, strfns.cc, symtab.cc, symtab.h, sysdep.cc,
toplev.cc, urlwrite.cc, variables.cc, variables.h, ov-builtin.h, ov-cell.cc,
ov-class.cc, ov-classdef.cc, ov-classdef.h, ov-dld-fcn.h, ov-fcn-handle.cc,
ov-fcn-inline.cc, ov-fcn-inline.h, ov-fcn.h, ov-lazy-idx.cc, ov-mex-fcn.h,
ov-struct.cc, ov-typeinfo.cc, ov-typeinfo.h, ov-usr-fcn.cc, ov-usr-fcn.h, ov.h,
ovl.h, octave.cc, lex.h, parse.h, pt-classdef.h, pt-exp.cc, pt-pr-code.h,
token.h, version.cc, version.in.h, oct-rand.h, dir-ops.h, file-ops.cc,
file-ops.h, file-stat.h, oct-env.cc, oct-group.cc, oct-passwd.cc,
oct-syscalls.cc, cmd-edit.cc, cmd-edit.h, cmd-hist.cc, cmd-hist.h, kpse.cc,
lo-array-gripes.h, pathsearch.cc, pathsearch.h, str-vec.h, url-transfer.h:
Replace emtpy 'std::string ()' calls with "".
author | Rik <rik@octave.org> |
---|---|
date | Wed, 30 Dec 2015 12:33:33 -0800 |
parents | 48b2ad5ee801 |
children |
rev | line source |
---|---|
2982 | 1 /* |
2 | |
19696
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
18677
diff
changeset
|
3 Copyright (C) 1996-2015 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 #ifdef HAVE_CONFIG_H | |
24 #include <config.h> | |
25 #endif | |
26 | |
27 #include "error.h" | |
20939
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
20554
diff
changeset
|
28 #include "ovl.h" |
2982 | 29 #include "ov.h" |
30 #include "pt-cmd.h" | |
31 #include "pt-exp.h" | |
32 #include "pt-select.h" | |
33 #include "pt-stmt.h" | |
34 #include "pt-walk.h" | |
3724 | 35 #include "Cell.h" |
36 #include "ov-typeinfo.h" | |
2982 | 37 |
38 // If clauses. | |
39 | |
40 tree_if_clause::~tree_if_clause (void) | |
41 { | |
42 delete expr; | |
43 delete list; | |
3665 | 44 delete lead_comm; |
2982 | 45 } |
46 | |
5861 | 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 | 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 | 54 } |
55 | |
2982 | 56 void |
57 tree_if_clause::accept (tree_walker& tw) | |
58 { | |
59 tw.visit_if_clause (*this); | |
60 } | |
61 | |
62 // List of if commands. | |
63 | |
5861 | 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 | 67 { |
68 tree_if_command_list *new_icl = new tree_if_command_list (); | |
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 | 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 | 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 | 75 } |
76 | |
77 return new_icl; | |
78 } | |
79 | |
2982 | 80 void |
81 tree_if_command_list::accept (tree_walker& tw) | |
82 { | |
83 tw.visit_if_command_list (*this); | |
84 } | |
85 | |
86 // If. | |
87 | |
88 tree_if_command::~tree_if_command (void) | |
89 { | |
90 delete list; | |
3665 | 91 delete lead_comm; |
92 delete trail_comm; | |
2982 | 93 } |
94 | |
5861 | 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 | 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 | 103 } |
104 | |
2982 | 105 void |
106 tree_if_command::accept (tree_walker& tw) | |
107 { | |
108 tw.visit_if_command (*this); | |
109 } | |
110 | |
111 // Switch cases. | |
112 | |
113 tree_switch_case::~tree_switch_case (void) | |
114 { | |
115 delete label; | |
116 delete list; | |
3665 | 117 delete lead_comm; |
2982 | 118 } |
119 | |
3724 | 120 |
121 bool | |
122 tree_switch_case::label_matches (const octave_value& val) | |
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 | 125 |
20554
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
19696
diff
changeset
|
126 if (label_value.is_defined ()) |
2982 | 127 { |
3724 | 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 | 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 | 137 |
20554
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
19696
diff
changeset
|
138 if (match) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
139 return true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
140 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
141 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
142 } |
3724 | 143 else |
20554
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
19696
diff
changeset
|
144 return val.is_equal (label_value); |
2982 | 145 } |
146 | |
3724 | 147 return false; |
2982 | 148 } |
149 | |
5861 | 150 tree_switch_case * |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
151 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
|
152 symbol_table::context_id context) const |
5861 | 153 { |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
154 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
|
155 list ? list->dup (scope, context) : 0, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
156 lead_comm ? lead_comm->dup () : 0); |
5861 | 157 } |
158 | |
2982 | 159 void |
160 tree_switch_case::accept (tree_walker& tw) | |
161 { | |
162 tw.visit_switch_case (*this); | |
163 } | |
164 | |
165 // List of switch cases. | |
166 | |
5861 | 167 tree_switch_case_list * |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
168 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
|
169 symbol_table::context_id context) const |
5861 | 170 { |
171 tree_switch_case_list *new_scl = new tree_switch_case_list (); | |
172 | |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8843
diff
changeset
|
173 for (const_iterator p = begin (); p != end (); p++) |
5861 | 174 { |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8843
diff
changeset
|
175 const tree_switch_case *elt = *p; |
5861 | 176 |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
177 new_scl->append (elt ? elt->dup (scope, context) : 0); |
5861 | 178 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
179 |
5861 | 180 return new_scl; |
181 } | |
182 | |
2982 | 183 void |
184 tree_switch_case_list::accept (tree_walker& tw) | |
185 { | |
186 tw.visit_switch_case_list (*this); | |
187 } | |
188 | |
189 // Switch. | |
190 | |
191 tree_switch_command::~tree_switch_command (void) | |
192 { | |
193 delete expr; | |
194 delete list; | |
3665 | 195 delete lead_comm; |
196 delete trail_comm; | |
2982 | 197 } |
198 | |
5861 | 199 tree_command * |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
200 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
|
201 symbol_table::context_id context) const |
5861 | 202 { |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
203 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
|
204 list ? list->dup (scope, context) : 0, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
205 lead_comm ? lead_comm->dup () : 0, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
206 trail_comm ? trail_comm->dup () : 0, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
207 line (), column ()); |
5861 | 208 } |
209 | |
2982 | 210 void |
211 tree_switch_command::accept (tree_walker& tw) | |
212 { | |
213 tw.visit_switch_command (*this); | |
214 } |