Mercurial > hg > octave-nkf
annotate src/pt-cell.cc @ 10828:322f43e0e170
Grammarcheck .txi documentation files.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Wed, 28 Jul 2010 12:45:04 -0700 |
parents | 57a59eae83cc |
children | fd0a3ac60b0e |
rev | line source |
---|---|
3353 | 1 /* |
2 | |
8920 | 3 Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, |
4 2008, 2009 John W. Eaton | |
3353 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
3353 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
3353 | 21 |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 #include <config.h> | |
26 #endif | |
27 | |
3503 | 28 #include <iostream> |
3353 | 29 |
30 #include "Cell.h" | |
31 #include "defun.h" | |
32 #include "error.h" | |
33 #include "oct-obj.h" | |
34 #include "pt-arg-list.h" | |
3770 | 35 #include "pt-bp.h" |
3353 | 36 #include "pt-exp.h" |
37 #include "pt-cell.h" | |
38 #include "pt-walk.h" | |
39 #include "utils.h" | |
40 #include "ov.h" | |
41 #include "variables.h" | |
42 | |
43 octave_value | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8588
diff
changeset
|
44 tree_cell::rvalue1 (int) |
3353 | 45 { |
46 octave_value retval; | |
47 | |
5275 | 48 octave_idx_type nr = length (); |
49 octave_idx_type nc = -1; | |
3353 | 50 |
4501 | 51 Cell val; |
3353 | 52 |
53 int i = 0; | |
54 | |
4219 | 55 for (iterator p = begin (); p != end (); p++) |
3353 | 56 { |
4219 | 57 tree_argument_list *elt = *p; |
3353 | 58 |
59 octave_value_list row = elt->convert_to_const_vector (); | |
60 | |
8588
79845b1793cf
optimize cell construction from a cs-list
Jaroslav Hajek <highegg@gmail.com>
parents:
7767
diff
changeset
|
61 if (nr == 1) |
79845b1793cf
optimize cell construction from a cs-list
Jaroslav Hajek <highegg@gmail.com>
parents:
7767
diff
changeset
|
62 // Optimize the single row case. |
79845b1793cf
optimize cell construction from a cs-list
Jaroslav Hajek <highegg@gmail.com>
parents:
7767
diff
changeset
|
63 val = row.cell_value (); |
79845b1793cf
optimize cell construction from a cs-list
Jaroslav Hajek <highegg@gmail.com>
parents:
7767
diff
changeset
|
64 else if (nc < 0) |
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 nc = row.length (); |
4501 | 67 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
68 val = Cell (nr, nc); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
69 } |
4501 | 70 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
71 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
72 octave_idx_type this_nc = row.length (); |
4501 | 73 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
74 if (nc != this_nc) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
75 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
76 ::error ("number of columns must match"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
77 return retval; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
78 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
79 } |
4501 | 80 |
5275 | 81 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
|
82 val(i,j) = row(j); |
3353 | 83 |
84 i++; | |
85 } | |
86 | |
87 retval = val; | |
88 | |
89 return retval; | |
90 } | |
91 | |
3556 | 92 octave_value_list |
93 tree_cell::rvalue (int nargout) | |
94 { | |
95 octave_value_list retval; | |
96 | |
97 if (nargout > 1) | |
98 error ("invalid number of output arguments for cell array"); | |
99 else | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8588
diff
changeset
|
100 retval = rvalue1 (nargout); |
3556 | 101 |
102 return retval; | |
103 } | |
104 | |
5861 | 105 tree_expression * |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
106 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
|
107 symbol_table::context_id context) const |
5861 | 108 { |
109 tree_cell *new_cell = new tree_cell (0, line (), column ()); | |
110 | |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
111 for (const_iterator p = begin (); p != end (); p++) |
5861 | 112 { |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
113 const tree_argument_list *elt = *p; |
5861 | 114 |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
115 new_cell->append (elt ? elt->dup (scope, context) : 0); |
5861 | 116 } |
117 | |
118 new_cell->copy_base (*this); | |
119 | |
120 return new_cell; | |
121 } | |
122 | |
3353 | 123 void |
124 tree_cell::accept (tree_walker& tw) | |
125 { | |
126 tw.visit_cell (*this); | |
127 } |