Mercurial > hg > octave-nkf
annotate libinterp/parse-tree/pt-colon.cc @ 19589:b39cbe9f3bb0
allow ranges to be disabled
* ov.cc, ov.h: Allow creation of range object to be disabled.
Also allow range objects to be forced, even when generally disabled.
* pt-exp.h (tree_expression::for_cmd_expr): New member variable.
(tree_expression::mark_as_for_cmd_expr,
tree_expression::is_for_cmd_expr): New functions.
* oct-parse.in.yy: Mark for command expressions.
* pt-colon.cc (tree_colon_expression::make_range): Force creation of
range if expression is a for command expression.
* basics.txi, numbers.txi: Document changes.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 08 Dec 2014 12:59:47 -0500 |
parents | 175b392e91fe |
children | 4197fc428c7d |
rev | line source |
---|---|
2980 | 1 /* |
2 | |
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
3 Copyright (C) 1996-2013 John W. Eaton |
2980 | 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. | |
2980 | 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/>. | |
2980 | 20 |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 #include <config.h> | |
25 #endif | |
26 | |
27 #include "error.h" | |
28 #include "oct-obj.h" | |
29 #include "pager.h" | |
30 #include "ov.h" | |
3770 | 31 #include "pt-bp.h" |
2980 | 32 #include "pt-colon.h" |
33 #include "pt-walk.h" | |
34 | |
35 // Colon expressions. | |
36 | |
37 tree_colon_expression * | |
38 tree_colon_expression::append (tree_expression *t) | |
39 { | |
40 tree_colon_expression *retval = 0; | |
41 | |
42 if (op_base) | |
43 { | |
44 if (op_limit) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
45 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
46 if (op_increment) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
47 ::error ("invalid colon expression"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
48 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
49 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
50 // Stupid syntax: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
51 // |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
52 // base : limit |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
53 // base : increment : limit |
2980 | 54 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
55 op_increment = op_limit; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
56 op_limit = t; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
57 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
58 } |
2980 | 59 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
60 op_limit = t; |
2980 | 61 |
62 retval = this; | |
63 } | |
64 else | |
65 ::error ("invalid colon expression"); | |
66 | |
67 return retval; | |
68 } | |
69 | |
70 octave_value_list | |
71 tree_colon_expression::rvalue (int nargout) | |
72 { | |
73 octave_value_list retval; | |
74 | |
75 if (nargout > 1) | |
76 error ("invalid number of output arguments for colon expression"); | |
77 else | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8213
diff
changeset
|
78 retval = rvalue1 (nargout); |
2980 | 79 |
80 return retval; | |
81 } | |
82 | |
83 octave_value | |
5347 | 84 tree_colon_expression::make_range (const Matrix& m_base, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
85 const Matrix& m_limit, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
86 const Matrix& m_increment, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
87 bool result_is_str, bool dq_str) const |
5347 | 88 { |
89 octave_value retval; | |
90 | |
91 bool base_empty = m_base.is_empty (); | |
92 bool limit_empty = m_limit.is_empty (); | |
93 bool increment_empty = m_increment.is_empty (); | |
94 | |
5358 | 95 if (base_empty || limit_empty || increment_empty) |
96 retval = Range (); | |
97 else | |
5347 | 98 { |
19589
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
99 Range r (m_base(0), m_limit(0), m_increment(0)); |
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
100 |
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
101 // For compatibility with Matlab, don't allow the range used in |
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
102 // a FOR loop expression to be converted to a Matrix. |
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
103 |
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
104 retval = octave_value (r, is_for_cmd_expr ()); |
5347 | 105 |
5358 | 106 if (result_is_str) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
107 retval = retval.convert_to_str (false, true, dq_str ? '"' : '\''); |
5347 | 108 } |
109 | |
110 return retval; | |
111 } | |
112 | |
113 octave_value | |
114 tree_colon_expression::make_range (const octave_value& ov_base, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
115 const octave_value& ov_limit, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
116 const octave_value& ov_increment) const |
5347 | 117 { |
118 octave_value retval; | |
119 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
120 if (ov_base.is_object () || ov_limit.is_object () || |
8213
d5e08881bba8
Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
8011
diff
changeset
|
121 ov_increment.is_object ()) |
d5e08881bba8
Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
8011
diff
changeset
|
122 { |
d5e08881bba8
Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
8011
diff
changeset
|
123 octave_value_list tmp1; |
d5e08881bba8
Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
8011
diff
changeset
|
124 tmp1(2) = ov_limit; |
d5e08881bba8
Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
8011
diff
changeset
|
125 tmp1(1) = ov_increment; |
d5e08881bba8
Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
8011
diff
changeset
|
126 tmp1(0) = ov_base; |
d5e08881bba8
Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
8011
diff
changeset
|
127 |
d5e08881bba8
Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
8011
diff
changeset
|
128 octave_value fcn = symbol_table::find_function ("colon", tmp1); |
5347 | 129 |
8213
d5e08881bba8
Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
8011
diff
changeset
|
130 if (fcn.is_defined ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
131 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
132 octave_value_list tmp2 = fcn.do_multi_index_op (1, tmp1); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
133 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
134 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
135 retval = tmp2 (0); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
136 } |
8213
d5e08881bba8
Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
8011
diff
changeset
|
137 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
138 ::error ("can not find overloaded colon function"); |
8213
d5e08881bba8
Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
8011
diff
changeset
|
139 } |
5347 | 140 else |
141 { | |
8213
d5e08881bba8
Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
8011
diff
changeset
|
142 bool result_is_str = (ov_base.is_string () && ov_limit.is_string ()); |
d5e08881bba8
Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
8011
diff
changeset
|
143 bool dq_str = (ov_base.is_dq_string () || ov_limit.is_dq_string ()); |
d5e08881bba8
Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
8011
diff
changeset
|
144 |
d5e08881bba8
Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
8011
diff
changeset
|
145 Matrix m_base = ov_base.matrix_value (true); |
5347 | 146 |
147 if (error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
148 eval_error ("invalid base value in colon expression"); |
5347 | 149 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
150 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
151 Matrix m_limit = ov_limit.matrix_value (true); |
5347 | 152 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
153 if (error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
154 eval_error ("invalid limit value in colon expression"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
155 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
156 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
157 Matrix m_increment = ov_increment.matrix_value (true); |
8213
d5e08881bba8
Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
8011
diff
changeset
|
158 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
159 if (error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
160 eval_error ("invalid increment value in colon expression"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
161 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
162 retval = make_range (m_base, m_limit, m_increment, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
163 result_is_str, dq_str); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
164 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
165 } |
5347 | 166 } |
167 | |
168 return retval; | |
169 } | |
170 | |
171 octave_value | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8213
diff
changeset
|
172 tree_colon_expression::rvalue1 (int) |
2980 | 173 { |
174 octave_value retval; | |
175 | |
176 if (error_state || ! op_base || ! op_limit) | |
177 return retval; | |
178 | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8213
diff
changeset
|
179 octave_value ov_base = op_base->rvalue1 (); |
2980 | 180 |
5347 | 181 if (error_state || ov_base.is_undefined ()) |
182 eval_error ("invalid base value in colon expression"); | |
183 else | |
2980 | 184 { |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8213
diff
changeset
|
185 octave_value ov_limit = op_limit->rvalue1 (); |
2980 | 186 |
5347 | 187 if (error_state || ov_limit.is_undefined ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
188 eval_error ("invalid limit value in colon expression"); |
8213
d5e08881bba8
Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
8011
diff
changeset
|
189 else if (ov_base.is_object () || ov_limit.is_object ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
190 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
191 octave_value_list tmp1; |
8213
d5e08881bba8
Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
8011
diff
changeset
|
192 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
193 if (op_increment) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
194 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
195 octave_value ov_increment = op_increment->rvalue1 (); |
8213
d5e08881bba8
Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
8011
diff
changeset
|
196 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
197 if (error_state || ov_increment.is_undefined ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
198 eval_error ("invalid increment value in colon expression"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
199 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
200 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
201 tmp1(2) = ov_limit; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
202 tmp1(1) = ov_increment; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
203 tmp1(0) = ov_base; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
204 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
205 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
206 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
207 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
208 tmp1(1) = ov_limit; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
209 tmp1(0) = ov_base; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
210 } |
8213
d5e08881bba8
Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
8011
diff
changeset
|
211 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
212 if (!error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
213 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
214 octave_value fcn = symbol_table::find_function ("colon", tmp1); |
8213
d5e08881bba8
Add overloading of the colon operator
David Bateman <dbateman@free.fr>
parents:
8011
diff
changeset
|
215 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
216 if (fcn.is_defined ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
217 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
218 octave_value_list tmp2 = fcn.do_multi_index_op (1, tmp1); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
219 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
220 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
221 retval = tmp2 (0); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
222 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
223 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
224 ::error ("can not find overloaded colon function"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
225 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
226 } |
5347 | 227 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
228 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
229 octave_value ov_increment = 1.0; |
2980 | 230 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
231 if (op_increment) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
232 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
233 ov_increment = op_increment->rvalue1 (); |
2980 | 234 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
235 if (error_state || ov_increment.is_undefined ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
236 eval_error ("invalid increment value in colon expression"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
237 } |
5347 | 238 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
239 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
240 retval = make_range (ov_base, ov_limit, ov_increment); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
241 } |
2980 | 242 } |
243 | |
244 return retval; | |
245 } | |
246 | |
247 void | |
5347 | 248 tree_colon_expression::eval_error (const std::string& s) const |
2980 | 249 { |
8011
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7767
diff
changeset
|
250 ::error ("%s", s.c_str ()); |
2980 | 251 } |
252 | |
5066 | 253 int |
254 tree_colon_expression::line (void) const | |
255 { | |
256 return (op_base ? op_base->line () | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
257 : (op_increment ? op_increment->line () |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
258 : (op_limit ? op_limit->line () |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
259 : -1))); |
5066 | 260 } |
261 | |
262 int | |
263 tree_colon_expression::column (void) const | |
264 { | |
265 return (op_base ? op_base->column () | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
266 : (op_increment ? op_increment->column () |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
267 : (op_limit ? op_limit->column () |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
268 : -1))); |
5066 | 269 } |
270 | |
5861 | 271 tree_expression * |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
272 tree_colon_expression::dup (symbol_table::scope_id scope, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
273 symbol_table::context_id context) const |
5861 | 274 { |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
275 tree_colon_expression *new_ce = new |
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
276 tree_colon_expression (op_base ? op_base->dup (scope, context) : 0, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
277 op_limit ? op_limit->dup (scope, context) : 0, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
278 op_increment ? op_increment->dup (scope, context) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
279 : 0, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
280 line (), column ()); |
5861 | 281 |
282 new_ce->copy_base (*new_ce); | |
283 | |
284 return new_ce; | |
285 } | |
286 | |
2980 | 287 void |
288 tree_colon_expression::accept (tree_walker& tw) | |
289 { | |
290 tw.visit_colon_expression (*this); | |
291 } |