Mercurial > hg > octave-lyh
comparison libinterp/parse-tree/pt-cell.cc @ 15195:2fc554ffbc28
split libinterp from src
* libinterp: New directory. Move all files from src directory here
except Makefile.am, main.cc, main-cli.cc, mkoctfile.in.cc,
mkoctfilr.in.sh, octave-config.in.cc, octave-config.in.sh.
* libinterp/Makefile.am: New file, extracted from src/Makefile.am.
* src/Makefile.am: Delete everything except targets and definitions
needed to build and link main and utility programs.
* Makefile.am (SUBDIRS): Include libinterp in the list.
* autogen.sh: Run config-module.sh in libinterp/dldfcn directory, not
src/dldfcn directory.
* configure.ac (AC_CONFIG_SRCDIR): Use libinterp/octave.cc, not
src/octave.cc.
(DL_LDFLAGS, LIBOCTINTERP): Use libinterp, not src.
(AC_CONFIG_FILES): Include libinterp/Makefile in the list.
* find-docstring-files.sh: Look in libinterp, not src.
* gui/src/Makefile.am (liboctgui_la_CPPFLAGS): Find header files in
libinterp, not src.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 18 Aug 2012 16:23:39 -0400 |
parents | src/parse-tree/pt-cell.cc@46b19589b593 |
children | 70f465930546 |
comparison
equal
deleted
inserted
replaced
15194:0f0b795044c3 | 15195:2fc554ffbc28 |
---|---|
1 /* | |
2 | |
3 Copyright (C) 1999-2012 John W. Eaton | |
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 | |
9 Free Software Foundation; either version 3 of the License, or (at your | |
10 option) any later version. | |
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 | |
18 along with Octave; see the file COPYING. If not, see | |
19 <http://www.gnu.org/licenses/>. | |
20 | |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 #include <config.h> | |
25 #endif | |
26 | |
27 #include <iostream> | |
28 | |
29 #include "Cell.h" | |
30 #include "defun.h" | |
31 #include "error.h" | |
32 #include "oct-obj.h" | |
33 #include "pt-arg-list.h" | |
34 #include "pt-bp.h" | |
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 | |
43 tree_cell::rvalue1 (int) | |
44 { | |
45 octave_value retval; | |
46 | |
47 octave_idx_type nr = length (); | |
48 octave_idx_type nc = -1; | |
49 | |
50 Cell val; | |
51 | |
52 int i = 0; | |
53 | |
54 for (iterator p = begin (); p != end (); p++) | |
55 { | |
56 tree_argument_list *elt = *p; | |
57 | |
58 octave_value_list row = elt->convert_to_const_vector (); | |
59 | |
60 if (nr == 1) | |
61 // Optimize the single row case. | |
62 val = row.cell_value (); | |
63 else if (nc < 0) | |
64 { | |
65 nc = row.length (); | |
66 | |
67 val = Cell (nr, nc); | |
68 } | |
69 else | |
70 { | |
71 octave_idx_type this_nc = row.length (); | |
72 | |
73 if (nc != this_nc) | |
74 { | |
75 ::error ("number of columns must match"); | |
76 return retval; | |
77 } | |
78 } | |
79 | |
80 for (octave_idx_type j = 0; j < nc; j++) | |
81 val(i,j) = row(j); | |
82 | |
83 i++; | |
84 } | |
85 | |
86 retval = val; | |
87 | |
88 return retval; | |
89 } | |
90 | |
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 | |
99 retval = rvalue1 (nargout); | |
100 | |
101 return retval; | |
102 } | |
103 | |
104 tree_expression * | |
105 tree_cell::dup (symbol_table::scope_id scope, | |
106 symbol_table::context_id context) const | |
107 { | |
108 tree_cell *new_cell = new tree_cell (0, line (), column ()); | |
109 | |
110 for (const_iterator p = begin (); p != end (); p++) | |
111 { | |
112 const tree_argument_list *elt = *p; | |
113 | |
114 new_cell->append (elt ? elt->dup (scope, context) : 0); | |
115 } | |
116 | |
117 new_cell->copy_base (*this); | |
118 | |
119 return new_cell; | |
120 } | |
121 | |
122 void | |
123 tree_cell::accept (tree_walker& tw) | |
124 { | |
125 tw.visit_cell (*this); | |
126 } |