Mercurial > hg > octave-nkf
annotate libinterp/parse-tree/pt-cell.cc @ 20638:7ac907da9fba
Use error() rather than ::error() unless explicitly required.
* resource-manager.cc (instance_ok), shortcut-manager.cc (instance_ok),
daspk.cc (DASPK_ABORT, DASPK_ABORT2), dasrt.cc (DASRT_ABORT, DASRT_ABORT2),
dassl.cc (DASSL_ABORT, DASSL_ABORT2), debug.cc (instance_ok),
display.cc (instance_ok), dynamic-ld.cc (octave_shlib_list::instance_ok,
octave_dynamic_loader::instance_ok, do_load_oct, do_load_mex), file-io.cc
(fopen_mode_to_ios_mode, do_stream_open, Ffprintf, Fsprintf, Fscanf, Ffscanf,
get_sscanf_data, Fsscanf, do_fread, do_fwrite, Fpopen, Ftempname, convert,
Fumask), graphics.in.h (graphics_toolkit::instance_ok,
gh_manager::instance_ok), load-path.cc (instance_ok),
ls-oct-ascii.cc (save_three_d), lsode.cc (LSODE_ABORT, LSODE_ABORT2),
oct-errno.in.cc (instance_ok), octave-link.cc (connect_link),
pager.cc (octave_pager_stream::instance_ok, octave_diary_stream::instance_ok),
quad.cc (QUAD_ABORT, QUAD_ABORT2),
sighandlers.cc (w32_interrupt_manager::instance_ok,
octave_child_list::instance_ok), symtab.cc (do_update_nest),
symtab.h (instance_ok), syscalls.cc (convert), toplev.h (instance_ok),
txt-eng-ft.cc (instance_ok, set_mode), urlwrite.cc (instance_ok),
__init_fltk__.cc (instance_ok), ov-builtin.cc (do_multi_index_op),
ov-classdef.cc (class_fevalStatic, make_class, octave_classdef::subsasgn,
do_multi_index_op, cdef_object_array::subsref, cdef_object_array::subsasgn,
install_meth, meta_subsref, run_constructor, make_meta_class, get_value,
set_value, check_method), ov-classdef.h (meta_subsref, instance_ok),
ov-fcn-handle.cc (octave_fcn_handle), ov-mex-fcn.cc (do_multi_index_op),
ov-range.h (octave_range), ov-typeinfo.cc (instance_ok),
ov-usr-fcn.cc (subsref, do_multi_index_op), pt-arg-list.cc (Fend,
convert_to_const_vector), pt-cell.cc (rvalue1), pt-colon.cc (append, rvalue1),
pt-eval.cc (visit_simple_for_command, visit_switch_command),
pt-exp.cc (is_logically_true, rvalue), pt-id.cc (eval_undefined_error),
pt-id.h (workspace_error), pt-mat.cc (get_concat_class):
Use error() rather than ::error().
author | Rik <rik@octave.org> |
---|---|
date | Thu, 06 Aug 2015 08:09:01 -0700 |
parents | 4197fc428c7d |
children |
rev | line source |
---|---|
3353 | 1 /* |
2 | |
19898
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19648
diff
changeset
|
3 Copyright (C) 1999-2015 John W. Eaton |
3353 | 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. | |
3353 | 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/>. | |
3353 | 20 |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 #include <config.h> | |
25 #endif | |
26 | |
3503 | 27 #include <iostream> |
3353 | 28 |
29 #include "Cell.h" | |
30 #include "oct-obj.h" | |
31 #include "pt-arg-list.h" | |
32 #include "pt-exp.h" | |
33 #include "pt-cell.h" | |
34 #include "pt-walk.h" | |
35 #include "ov.h" | |
36 | |
37 octave_value | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8588
diff
changeset
|
38 tree_cell::rvalue1 (int) |
3353 | 39 { |
40 octave_value retval; | |
41 | |
5275 | 42 octave_idx_type nr = length (); |
43 octave_idx_type nc = -1; | |
3353 | 44 |
4501 | 45 Cell val; |
3353 | 46 |
19648
e5a78897be9e
Allow empty comma-separated lists in cell { } constructor (bug #43113).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
47 octave_idx_type i = 0; |
3353 | 48 |
4219 | 49 for (iterator p = begin (); p != end (); p++) |
3353 | 50 { |
4219 | 51 tree_argument_list *elt = *p; |
3353 | 52 |
53 octave_value_list row = elt->convert_to_const_vector (); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
54 |
8588
79845b1793cf
optimize cell construction from a cs-list
Jaroslav Hajek <highegg@gmail.com>
parents:
7767
diff
changeset
|
55 if (nr == 1) |
79845b1793cf
optimize cell construction from a cs-list
Jaroslav Hajek <highegg@gmail.com>
parents:
7767
diff
changeset
|
56 // Optimize the single row case. |
79845b1793cf
optimize cell construction from a cs-list
Jaroslav Hajek <highegg@gmail.com>
parents:
7767
diff
changeset
|
57 val = row.cell_value (); |
79845b1793cf
optimize cell construction from a cs-list
Jaroslav Hajek <highegg@gmail.com>
parents:
7767
diff
changeset
|
58 else if (nc < 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
59 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
60 nc = row.length (); |
4501 | 61 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
62 val = Cell (nr, nc); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
63 } |
4501 | 64 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
65 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
66 octave_idx_type this_nc = row.length (); |
4501 | 67 |
19648
e5a78897be9e
Allow empty comma-separated lists in cell { } constructor (bug #43113).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
68 if (this_nc != nc) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
69 { |
19648
e5a78897be9e
Allow empty comma-separated lists in cell { } constructor (bug #43113).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
70 if (this_nc == 0) |
e5a78897be9e
Allow empty comma-separated lists in cell { } constructor (bug #43113).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
71 continue; // blank line |
e5a78897be9e
Allow empty comma-separated lists in cell { } constructor (bug #43113).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
72 else |
e5a78897be9e
Allow empty comma-separated lists in cell { } constructor (bug #43113).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
73 { |
20638
7ac907da9fba
Use error() rather than ::error() unless explicitly required.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
74 error ("number of columns must match"); |
19648
e5a78897be9e
Allow empty comma-separated lists in cell { } constructor (bug #43113).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
75 return retval; |
e5a78897be9e
Allow empty comma-separated lists in cell { } constructor (bug #43113).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
76 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
77 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
78 } |
4501 | 79 |
5275 | 80 for (octave_idx_type j = 0; j < nc; j++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
81 val(i,j) = row(j); |
3353 | 82 |
83 i++; | |
84 } | |
85 | |
19648
e5a78897be9e
Allow empty comma-separated lists in cell { } constructor (bug #43113).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
86 if (i < nr) |
e5a78897be9e
Allow empty comma-separated lists in cell { } constructor (bug #43113).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
87 val.resize (dim_vector (i, nc)); // there were blank rows |
3353 | 88 retval = val; |
89 | |
90 return retval; | |
91 } | |
92 | |
3556 | 93 octave_value_list |
94 tree_cell::rvalue (int nargout) | |
95 { | |
96 octave_value_list retval; | |
97 | |
98 if (nargout > 1) | |
99 error ("invalid number of output arguments for cell array"); | |
100 else | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8588
diff
changeset
|
101 retval = rvalue1 (nargout); |
3556 | 102 |
103 return retval; | |
104 } | |
105 | |
5861 | 106 tree_expression * |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
107 tree_cell::dup (symbol_table::scope_id scope, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
108 symbol_table::context_id context) const |
5861 | 109 { |
110 tree_cell *new_cell = new tree_cell (0, line (), column ()); | |
111 | |
16237
70f465930546
rearrange class heirarchy for tree_cell and tree_matrix
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
112 new_cell->copy_base (*this, scope, context); |
5861 | 113 |
114 return new_cell; | |
115 } | |
116 | |
3353 | 117 void |
118 tree_cell::accept (tree_walker& tw) | |
119 { | |
120 tw.visit_cell (*this); | |
121 } |