Mercurial > hg > octave-nkf
annotate src/pt-cell.cc @ 15536:2e8eb9ac43a5 stable rc-3-6-4-0
3.6.4-rc0 release candidate
* configure.ac (AC_INIT): Version is now 3.6.2-rc0.
(OCTAVE_RELEASE_DATE): Now 2012-05-11.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 17 Oct 2012 10:05:44 -0400 |
parents | 72c96de7a403 |
children |
rev | line source |
---|---|
3353 | 1 /* |
2 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
3 Copyright (C) 1999-2012 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 "defun.h" | |
31 #include "error.h" | |
32 #include "oct-obj.h" | |
33 #include "pt-arg-list.h" | |
3770 | 34 #include "pt-bp.h" |
3353 | 35 #include "pt-exp.h" |
36 #include "pt-cell.h" | |
37 #include "pt-walk.h" | |
38 #include "utils.h" | |
39 #include "ov.h" | |
40 #include "variables.h" | |
41 | |
42 octave_value | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8588
diff
changeset
|
43 tree_cell::rvalue1 (int) |
3353 | 44 { |
45 octave_value retval; | |
46 | |
5275 | 47 octave_idx_type nr = length (); |
48 octave_idx_type nc = -1; | |
3353 | 49 |
4501 | 50 Cell val; |
3353 | 51 |
52 int i = 0; | |
53 | |
4219 | 54 for (iterator p = begin (); p != end (); p++) |
3353 | 55 { |
4219 | 56 tree_argument_list *elt = *p; |
3353 | 57 |
58 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
|
59 |
8588
79845b1793cf
optimize cell construction from a cs-list
Jaroslav Hajek <highegg@gmail.com>
parents:
7767
diff
changeset
|
60 if (nr == 1) |
79845b1793cf
optimize cell construction from a cs-list
Jaroslav Hajek <highegg@gmail.com>
parents:
7767
diff
changeset
|
61 // Optimize the single row case. |
79845b1793cf
optimize cell construction from a cs-list
Jaroslav Hajek <highegg@gmail.com>
parents:
7767
diff
changeset
|
62 val = row.cell_value (); |
79845b1793cf
optimize cell construction from a cs-list
Jaroslav Hajek <highegg@gmail.com>
parents:
7767
diff
changeset
|
63 else if (nc < 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
64 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
65 nc = row.length (); |
4501 | 66 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
67 val = Cell (nr, nc); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
68 } |
4501 | 69 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
70 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
71 octave_idx_type this_nc = row.length (); |
4501 | 72 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
73 if (nc != this_nc) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
74 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
75 ::error ("number of columns must match"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
76 return retval; |
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 | |
86 retval = val; | |
87 | |
88 return retval; | |
89 } | |
90 | |
3556 | 91 octave_value_list |
92 tree_cell::rvalue (int nargout) | |
93 { | |
94 octave_value_list retval; | |
95 | |
96 if (nargout > 1) | |
97 error ("invalid number of output arguments for cell array"); | |
98 else | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8588
diff
changeset
|
99 retval = rvalue1 (nargout); |
3556 | 100 |
101 return retval; | |
102 } | |
103 | |
5861 | 104 tree_expression * |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
105 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
|
106 symbol_table::context_id context) const |
5861 | 107 { |
108 tree_cell *new_cell = new tree_cell (0, line (), column ()); | |
109 | |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
110 for (const_iterator p = begin (); p != end (); p++) |
5861 | 111 { |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
112 const tree_argument_list *elt = *p; |
5861 | 113 |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
114 new_cell->append (elt ? elt->dup (scope, context) : 0); |
5861 | 115 } |
116 | |
117 new_cell->copy_base (*this); | |
118 | |
119 return new_cell; | |
120 } | |
121 | |
3353 | 122 void |
123 tree_cell::accept (tree_walker& tw) | |
124 { | |
125 tw.visit_cell (*this); | |
126 } |