annotate libinterp/parse-tree/pt-idx.cc @ 19731:4197fc428c7d

maint: Update copyright notices for 2015.
author John W. Eaton <jwe@octave.org>
date Wed, 11 Feb 2015 14:19:08 -0500
parents 03067dab10ca
children dd6345fd8a97
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
1 /*
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
2
19731
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19437
diff changeset
3 Copyright (C) 1996-2015 John W. Eaton
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
4
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
6
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6833
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6833
diff changeset
10 option) any later version.
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
11
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
15 for more details.
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
16
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6833
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6833
diff changeset
19 <http://www.gnu.org/licenses/>.
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
20
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
21 */
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
22
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
23 #ifdef HAVE_CONFIG_H
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
24 #include <config.h>
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
25 #endif
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
26
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
27 #include "Cell.h"
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
28 #include "error.h"
3930
61d4427c016e [project @ 2002-05-07 00:47:31 by jwe]
jwe
parents: 3929
diff changeset
29 #include "oct-map.h"
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
30 #include "oct-obj.h"
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
31 #include "oct-lvalue.h"
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
32 #include "ov.h"
3930
61d4427c016e [project @ 2002-05-07 00:47:31 by jwe]
jwe
parents: 3929
diff changeset
33 #include "pager.h"
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents: 2980
diff changeset
34 #include "pt-arg-list.h"
3930
61d4427c016e [project @ 2002-05-07 00:47:31 by jwe]
jwe
parents: 3929
diff changeset
35 #include "pt-bp.h"
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7200
diff changeset
36 #include "pt-id.h"
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
37 #include "pt-idx.h"
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
38 #include "pt-walk.h"
3930
61d4427c016e [project @ 2002-05-07 00:47:31 by jwe]
jwe
parents: 3929
diff changeset
39 #include "utils.h"
61d4427c016e [project @ 2002-05-07 00:47:31 by jwe]
jwe
parents: 3929
diff changeset
40 #include "variables.h"
8579
7e0f36dfefbe implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents: 8564
diff changeset
41 #include "gripes.h"
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
42
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
43 // Index expressions.
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
44
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
45 tree_index_expression::tree_index_expression (int l, int c)
7791
975e9540be2c pt-idx.cc: initialize fields in constructors
John W. Eaton <jwe@octave.org>
parents: 7790
diff changeset
46 : tree_expression (l, c), expr (0), args (0), type (),
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
47 arg_nm (), dyn_field () { }
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
48
3546
6dfdded73a7e [project @ 2000-02-02 22:45:39 by jwe]
jwe
parents: 3544
diff changeset
49 tree_index_expression::tree_index_expression (tree_expression *e,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
50 tree_argument_list *lst,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
51 int l, int c, char t)
7791
975e9540be2c pt-idx.cc: initialize fields in constructors
John W. Eaton <jwe@octave.org>
parents: 7790
diff changeset
52 : tree_expression (l, c), expr (e), args (0), type (),
4131
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4066
diff changeset
53 arg_nm (), dyn_field ()
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
54 {
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
55 append (lst, t);
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
56 }
3215
bc3fdfe311a3 [project @ 1998-11-10 14:06:21 by jwe]
jwe
parents: 2991
diff changeset
57
3930
61d4427c016e [project @ 2002-05-07 00:47:31 by jwe]
jwe
parents: 3929
diff changeset
58 tree_index_expression::tree_index_expression (tree_expression *e,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
59 const std::string& n,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
60 int l, int c)
7791
975e9540be2c pt-idx.cc: initialize fields in constructors
John W. Eaton <jwe@octave.org>
parents: 7790
diff changeset
61 : tree_expression (l, c), expr (e), args (0), type (),
4131
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4066
diff changeset
62 arg_nm (), dyn_field ()
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
63 {
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
64 append (n);
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
65 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
66
4131
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4066
diff changeset
67 tree_index_expression::tree_index_expression (tree_expression *e,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
68 tree_expression *df,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
69 int l, int c)
7791
975e9540be2c pt-idx.cc: initialize fields in constructors
John W. Eaton <jwe@octave.org>
parents: 7790
diff changeset
70 : tree_expression (l, c), expr (e), args (0), type (),
4131
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4066
diff changeset
71 arg_nm (), dyn_field ()
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4066
diff changeset
72 {
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4066
diff changeset
73 append (df);
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4066
diff changeset
74 }
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4066
diff changeset
75
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
76 void
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
77 tree_index_expression::append (tree_argument_list *lst, char t)
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
78 {
4219
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4192
diff changeset
79 args.push_back (lst);
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
80 type.append (1, t);
4219
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4192
diff changeset
81 arg_nm.push_back (lst ? lst->get_arg_names () : string_vector ());
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4192
diff changeset
82 dyn_field.push_back (static_cast<tree_expression *> (0));
10206
37a08e0ce2dc support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents: 10160
diff changeset
83
37a08e0ce2dc support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents: 10160
diff changeset
84 if (lst && lst->has_magic_tilde ())
37a08e0ce2dc support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents: 10160
diff changeset
85 error ("invalid use of empty argument (~) in index expression");
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
86 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
87
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
88 void
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
89 tree_index_expression::append (const std::string& n)
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
90 {
4219
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4192
diff changeset
91 args.push_back (static_cast<tree_argument_list *> (0));
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
92 type.append (".");
4219
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4192
diff changeset
93 arg_nm.push_back (n);
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4192
diff changeset
94 dyn_field.push_back (static_cast<tree_expression *> (0));
4131
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4066
diff changeset
95 }
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4066
diff changeset
96
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4066
diff changeset
97 void
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4066
diff changeset
98 tree_index_expression::append (tree_expression *df)
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4066
diff changeset
99 {
4219
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4192
diff changeset
100 args.push_back (static_cast<tree_argument_list *> (0));
4131
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4066
diff changeset
101 type.append (".");
4219
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4192
diff changeset
102 arg_nm.push_back ("");
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4192
diff changeset
103 dyn_field.push_back (df);
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
104 }
3930
61d4427c016e [project @ 2002-05-07 00:47:31 by jwe]
jwe
parents: 3929
diff changeset
105
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
106 tree_index_expression::~tree_index_expression (void)
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
107 {
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
108 delete expr;
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
109
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
110 while (! args.empty ())
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
111 {
4219
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4192
diff changeset
112 std::list<tree_argument_list *>::iterator p = args.begin ();
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4192
diff changeset
113 delete *p;
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4192
diff changeset
114 args.erase (p);
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
115 }
13970
c93b953f7d54 plug some memory leaks
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
116
c93b953f7d54 plug some memory leaks
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
117 while (! dyn_field.empty ())
c93b953f7d54 plug some memory leaks
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
118 {
c93b953f7d54 plug some memory leaks
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
119 std::list<tree_expression *>::iterator p = dyn_field.begin ();
c93b953f7d54 plug some memory leaks
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
120 delete *p;
c93b953f7d54 plug some memory leaks
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
121 dyn_field.erase (p);
c93b953f7d54 plug some memory leaks
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
122 }
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
123 }
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
124
5099
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 4675
diff changeset
125 bool
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 4675
diff changeset
126 tree_index_expression::has_magic_end (void) const
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 4675
diff changeset
127 {
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 4675
diff changeset
128 for (std::list<tree_argument_list *>::const_iterator p = args.begin ();
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 4675
diff changeset
129 p != args.end ();
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 4675
diff changeset
130 p++)
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 4675
diff changeset
131 {
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 4675
diff changeset
132 tree_argument_list *elt = *p;
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 4675
diff changeset
133
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 4675
diff changeset
134 if (elt && elt->has_magic_end ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
135 return true;
5099
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 4675
diff changeset
136 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
137
5099
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 4675
diff changeset
138 return false;
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 4675
diff changeset
139 }
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 4675
diff changeset
140
2991
fc751d2a99fd [project @ 1997-05-16 21:00:48 by jwe]
jwe
parents: 2984
diff changeset
141 // This is useful for printing the name of the variable in an indexed
fc751d2a99fd [project @ 1997-05-16 21:00:48 by jwe]
jwe
parents: 2984
diff changeset
142 // assignment.
fc751d2a99fd [project @ 1997-05-16 21:00:48 by jwe]
jwe
parents: 2984
diff changeset
143
3536
e8fbc8c3d6d9 [project @ 2000-02-02 12:01:00 by jwe]
jwe
parents: 3534
diff changeset
144 std::string
2991
fc751d2a99fd [project @ 1997-05-16 21:00:48 by jwe]
jwe
parents: 2984
diff changeset
145 tree_index_expression::name (void) const
fc751d2a99fd [project @ 1997-05-16 21:00:48 by jwe]
jwe
parents: 2984
diff changeset
146 {
4131
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4066
diff changeset
147 return expr->name ();
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
148 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
149
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
150 static Cell
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
151 make_subs_cell (tree_argument_list *args, const string_vector& arg_nm)
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
152 {
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
153 Cell retval;
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
154
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
155 octave_value_list arg_values;
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
156
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
157 if (args)
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
158 arg_values = args->convert_to_const_vector ();
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
159
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
160 if (! error_state)
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
161 {
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
162 int n = arg_values.length ();
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
163
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
164 if (n > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
165 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
166 arg_values.stash_name_tags (arg_nm);
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
167
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
168 retval.resize (dim_vector (1, n));
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
169
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
170 for (int i = 0; i < n; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
171 retval(0,i) = arg_values(i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
172 }
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
173 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
174
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
175 return retval;
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
176 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
177
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
178 static inline octave_value_list
4234
90e44267e8cf [project @ 2002-12-21 17:15:25 by jwe]
jwe
parents: 4233
diff changeset
179 make_value_list (tree_argument_list *args, const string_vector& arg_nm,
14343
acc26b860afa fix indexed assignment bug (bug #35482)
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
180 const octave_value *object, bool rvalue = true)
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
181 {
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
182 octave_value_list retval;
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
183
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
184 if (args)
9125
8ab1e6f63cdc gripe on magic end query for undefined variable
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
185 {
14343
acc26b860afa fix indexed assignment bug (bug #35482)
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
186 if (rvalue && object && args->has_magic_end () && object->is_undefined ())
9125
8ab1e6f63cdc gripe on magic end query for undefined variable
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
187 gripe_invalid_inquiry_subscript ();
8ab1e6f63cdc gripe on magic end query for undefined variable
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
188 else
8ab1e6f63cdc gripe on magic end query for undefined variable
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
189 retval = args->convert_to_const_vector (object);
8ab1e6f63cdc gripe on magic end query for undefined variable
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
190 }
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
191
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
192 if (! error_state)
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
193 {
10659
8baff2aceabc fix slicing value lists with name tags (bug #29960)
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
194 octave_idx_type n = retval.length ();
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
195
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
196 if (n > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
197 retval.stash_name_tags (arg_nm);
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
198 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
199
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
200 return retval;
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
201 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
202
4131
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4066
diff changeset
203 std::string
4219
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4192
diff changeset
204 tree_index_expression::get_struct_index
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4192
diff changeset
205 (std::list<string_vector>::const_iterator p_arg_nm,
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4192
diff changeset
206 std::list<tree_expression *>::const_iterator p_dyn_field) const
4131
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4066
diff changeset
207 {
4219
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4192
diff changeset
208 std::string fn = (*p_arg_nm)(0);
4131
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4066
diff changeset
209
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4066
diff changeset
210 if (fn.empty ())
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4066
diff changeset
211 {
4219
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4192
diff changeset
212 tree_expression *df = *p_dyn_field;
4131
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4066
diff changeset
213
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4066
diff changeset
214 if (df)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
215 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
216 octave_value t = df->rvalue1 ();
4131
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4066
diff changeset
217
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
218 if (! error_state)
16656
cf84ea2ba2d3 require dynamic field names to be character strings
John W. Eaton <jwe@octave.org>
parents: 16442
diff changeset
219 {
16661
8291109ac3fd require that dynamic field names have only one row
John W. Eaton <jwe@octave.org>
parents: 16656
diff changeset
220 if (t.is_string () && t.rows () == 1)
16656
cf84ea2ba2d3 require dynamic field names to be character strings
John W. Eaton <jwe@octave.org>
parents: 16442
diff changeset
221 fn = t.string_value ();
cf84ea2ba2d3 require dynamic field names to be character strings
John W. Eaton <jwe@octave.org>
parents: 16442
diff changeset
222 else
19437
03067dab10ca Use stricter input validation when looking for a string as input (bug #42651).
Rik <rik@octave.org>
parents: 18439
diff changeset
223 error ("dynamic structure field names must be strings");
16656
cf84ea2ba2d3 require dynamic field names to be character strings
John W. Eaton <jwe@octave.org>
parents: 16442
diff changeset
224 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
225 }
4131
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4066
diff changeset
226 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
227 panic_impossible ();
4131
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4066
diff changeset
228 }
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4066
diff changeset
229
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4066
diff changeset
230 return fn;
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4066
diff changeset
231 }
597fbc55ea40 [project @ 2002-10-29 17:12:53 by jwe]
jwe
parents: 4066
diff changeset
232
11056
4bec51eb58e2 replace Octave_map->octave_map in pt-idx.h
Jaroslav Hajek <highegg@gmail.com>
parents: 10832
diff changeset
233 octave_map
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
234 tree_index_expression::make_arg_struct (void) const
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
235 {
4219
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4192
diff changeset
236 int n = args.size ();
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
237
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7200
diff changeset
238 Cell type_field (n, 1);
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7200
diff changeset
239 Cell subs_field (n, 1);
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
240
4219
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4192
diff changeset
241 std::list<tree_argument_list *>::const_iterator p_args = args.begin ();
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4192
diff changeset
242 std::list<string_vector>::const_iterator p_arg_nm = arg_nm.begin ();
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4192
diff changeset
243 std::list<tree_expression *>::const_iterator p_dyn_field = dyn_field.begin ();
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
244
11056
4bec51eb58e2 replace Octave_map->octave_map in pt-idx.h
Jaroslav Hajek <highegg@gmail.com>
parents: 10832
diff changeset
245 octave_map m;
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
246
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
247 for (int i = 0; i < n; i++)
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
248 {
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
249 switch (type[i])
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
250 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
251 case '(':
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
252 subs_field(i) = make_subs_cell (*p_args, *p_arg_nm);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
253 break;
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
254
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
255 case '{':
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
256 subs_field(i) = make_subs_cell (*p_args, *p_arg_nm);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
257 break;
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
258
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
259 case '.':
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
260 subs_field(i) = get_struct_index (p_arg_nm, p_dyn_field);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
261 break;
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
262
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
263 default:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
264 panic_impossible ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
265 }
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
266
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
267 if (error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
268 return m;
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
269
4219
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4192
diff changeset
270 p_args++;
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4192
diff changeset
271 p_arg_nm++;
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4192
diff changeset
272 p_dyn_field++;
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
273 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
274
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7200
diff changeset
275 m.assign ("type", type_field);
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7200
diff changeset
276 m.assign ("subs", subs_field);
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
277
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
278 return m;
2991
fc751d2a99fd [project @ 1997-05-16 21:00:48 by jwe]
jwe
parents: 2984
diff changeset
279 }
fc751d2a99fd [project @ 1997-05-16 21:00:48 by jwe]
jwe
parents: 2984
diff changeset
280
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
281 octave_value_list
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
282 tree_index_expression::rvalue (int nargout)
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
283 {
10832
1b2fcd122c6a allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents: 10659
diff changeset
284 return tree_index_expression::rvalue (nargout, 0);
1b2fcd122c6a allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents: 10659
diff changeset
285 }
1b2fcd122c6a allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents: 10659
diff changeset
286
1b2fcd122c6a allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents: 10659
diff changeset
287 octave_value_list
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
288 tree_index_expression::rvalue (int nargout,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
289 const std::list<octave_lvalue> *lvalue_list)
10832
1b2fcd122c6a allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents: 10659
diff changeset
290 {
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
291 octave_value_list retval;
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
292
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
293 if (error_state)
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
294 return retval;
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
295
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7200
diff changeset
296 octave_value first_expr_val;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7200
diff changeset
297
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7200
diff changeset
298 octave_value_list first_args;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7200
diff changeset
299
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7200
diff changeset
300 bool have_args = false;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7200
diff changeset
301
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7200
diff changeset
302 if (expr->is_identifier () && type[0] == '(')
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7200
diff changeset
303 {
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7200
diff changeset
304 tree_identifier *id = dynamic_cast<tree_identifier *> (expr);
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7200
diff changeset
305
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7200
diff changeset
306 if (! (id->is_variable () || args.empty ()))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
307 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
308 tree_argument_list *al = *(args.begin ());
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7200
diff changeset
309
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
310 size_t n = al ? al->length () : 0;
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7200
diff changeset
311
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
312 if (n > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
313 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
314 string_vector anm = *(arg_nm.begin ());
9445
c5f03874ea2a simplify symbol_table::find and associated functions
Jaroslav Hajek <highegg@gmail.com>
parents: 9329
diff changeset
315 have_args = true;
c5f03874ea2a simplify symbol_table::find and associated functions
Jaroslav Hajek <highegg@gmail.com>
parents: 9329
diff changeset
316 first_args = al -> convert_to_const_vector ();
c5f03874ea2a simplify symbol_table::find and associated functions
Jaroslav Hajek <highegg@gmail.com>
parents: 9329
diff changeset
317 first_args.stash_name_tags (anm);
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7200
diff changeset
318
9445
c5f03874ea2a simplify symbol_table::find and associated functions
Jaroslav Hajek <highegg@gmail.com>
parents: 9329
diff changeset
319 if (! error_state)
c5f03874ea2a simplify symbol_table::find and associated functions
Jaroslav Hajek <highegg@gmail.com>
parents: 9329
diff changeset
320 first_expr_val = id->do_lookup (first_args);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
321 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
322 }
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7200
diff changeset
323 }
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
324
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
325 if (! error_state)
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
326 {
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7200
diff changeset
327 if (first_expr_val.is_undefined ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
328 first_expr_val = expr->rvalue1 ();
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7200
diff changeset
329
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7200
diff changeset
330 octave_value tmp = first_expr_val;
8551
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
331 octave_idx_type tmpi = 0;
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7200
diff changeset
332
4219
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4192
diff changeset
333 std::list<octave_value_list> idx;
3930
61d4427c016e [project @ 2002-05-07 00:47:31 by jwe]
jwe
parents: 3929
diff changeset
334
4219
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4192
diff changeset
335 int n = args.size ();
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
336
4219
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4192
diff changeset
337 std::list<tree_argument_list *>::iterator p_args = args.begin ();
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4192
diff changeset
338 std::list<string_vector>::iterator p_arg_nm = arg_nm.begin ();
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4192
diff changeset
339 std::list<tree_expression *>::iterator p_dyn_field = dyn_field.begin ();
3930
61d4427c016e [project @ 2002-05-07 00:47:31 by jwe]
jwe
parents: 3929
diff changeset
340
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
341 for (int i = 0; i < n; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
342 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
343 if (i > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
344 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
345 tree_argument_list *al = *p_args;
4432
ff7187bd3075 [project @ 2003-06-19 16:40:53 by jwe]
jwe
parents: 4234
diff changeset
346
9692
126b49caba0d smart splitting of index chains
Jaroslav Hajek <highegg@gmail.com>
parents: 9445
diff changeset
347 // In Matlab, () can only be followed by . In Octave, we do not
126b49caba0d smart splitting of index chains
Jaroslav Hajek <highegg@gmail.com>
parents: 9445
diff changeset
348 // enforce this for rvalue expressions, but we'll split the
126b49caba0d smart splitting of index chains
Jaroslav Hajek <highegg@gmail.com>
parents: 9445
diff changeset
349 // evaluation at this point. This will, hopefully, allow Octave's
126b49caba0d smart splitting of index chains
Jaroslav Hajek <highegg@gmail.com>
parents: 9445
diff changeset
350 // looser rules apply smoothly for Matlab overloaded subsref
126b49caba0d smart splitting of index chains
Jaroslav Hajek <highegg@gmail.com>
parents: 9445
diff changeset
351 // codes.
126b49caba0d smart splitting of index chains
Jaroslav Hajek <highegg@gmail.com>
parents: 9445
diff changeset
352 bool force_split = type[i-1] == '(' && type[i] != '.';
126b49caba0d smart splitting of index chains
Jaroslav Hajek <highegg@gmail.com>
parents: 9445
diff changeset
353
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
354 if (force_split || (al && al->has_magic_end ()))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
355 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
356 // We have an expression like
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
357 //
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
358 // x{end}.a(end)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
359 //
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
360 // and we are looking at the argument list that
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
361 // contains the second (or third, etc.) "end" token,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
362 // so we must evaluate everything up to the point of
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
363 // that argument list so we can pass the appropriate
17355
f0edd6c752e9 don't convert "end" token to "__end__" for indexing
John W. Eaton <jwe@octave.org>
parents: 16661
diff changeset
364 // value to the built-in end function.
4432
ff7187bd3075 [project @ 2003-06-19 16:40:53 by jwe]
jwe
parents: 4234
diff changeset
365
18439
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
366 octave_value_list tmp_list
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
367 = tmp.subsref (type.substr (tmpi, i - tmpi), idx, nargout);
4432
ff7187bd3075 [project @ 2003-06-19 16:40:53 by jwe]
jwe
parents: 4234
diff changeset
368
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
369 tmp = tmp_list.length () ? tmp_list(0) : octave_value ();
8551
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
370 tmpi = i;
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
371 idx.clear ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
372
8551
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
373 if (tmp.is_cs_list ())
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
374 gripe_indexed_cs_list ();
4432
ff7187bd3075 [project @ 2003-06-19 16:40:53 by jwe]
jwe
parents: 4234
diff changeset
375
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
376 if (error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
377 break;
18439
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
378
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
379 if (tmp.is_function ())
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
380 {
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
381 octave_function *fcn = tmp.function_value (true);
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
382
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
383 if (fcn && ! fcn->is_postfix_index_handled (type[i]))
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
384 {
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
385 octave_value_list empty_args;
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
386
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
387 tmp_list = tmp.do_multi_index_op (1, empty_args);
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
388 tmp = (tmp_list.length ()
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
389 ? tmp_list(0) : octave_value ());
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
390
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
391 if (tmp.is_cs_list ())
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
392 gripe_indexed_cs_list ();
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
393
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
394 if (error_state)
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
395 break;
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
396 }
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
397 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
398 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
399 }
4432
ff7187bd3075 [project @ 2003-06-19 16:40:53 by jwe]
jwe
parents: 4234
diff changeset
400
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
401 switch (type[i])
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
402 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
403 case '(':
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
404 if (have_args)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
405 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
406 idx.push_back (first_args);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
407 have_args = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
408 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
409 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
410 idx.push_back (make_value_list (*p_args, *p_arg_nm, &tmp));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
411 break;
3930
61d4427c016e [project @ 2002-05-07 00:47:31 by jwe]
jwe
parents: 3929
diff changeset
412
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
413 case '{':
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
414 idx.push_back (make_value_list (*p_args, *p_arg_nm, &tmp));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
415 break;
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
416
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
417 case '.':
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
418 idx.push_back (octave_value (get_struct_index (p_arg_nm,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
419 p_dyn_field)));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
420 break;
3930
61d4427c016e [project @ 2002-05-07 00:47:31 by jwe]
jwe
parents: 3929
diff changeset
421
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
422 default:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
423 panic_impossible ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
424 }
3930
61d4427c016e [project @ 2002-05-07 00:47:31 by jwe]
jwe
parents: 3929
diff changeset
425
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
426 if (error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
427 break;
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
428
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
429 p_args++;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
430 p_arg_nm++;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
431 p_dyn_field++;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
432 }
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
433
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
434 if (! error_state)
18439
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
435 {
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
436 retval = tmp.subsref (type.substr (tmpi, n - tmpi), idx, nargout,
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
437 lvalue_list);
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
438
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
439 octave_value val = retval.length () ? retval(0) : octave_value ();
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
440
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
441 if (! error_state && val.is_function ())
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
442 {
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
443 octave_function *fcn = val.function_value (true);
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
444
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
445 if (fcn)
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
446 {
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
447 octave_value_list empty_args;
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
448
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
449 retval = (lvalue_list
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
450 ? val.do_multi_index_op (nargout, empty_args,
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
451 lvalue_list)
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
452 : val.do_multi_index_op (nargout, empty_args));
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
453 }
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
454 }
d5aa615dcf4c Fix package function call with magic "end" in arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17787
diff changeset
455 }
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
456 }
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
457
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
458 return retval;
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
459 }
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
460
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
461 octave_value
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8580
diff changeset
462 tree_index_expression::rvalue1 (int nargout)
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
463 {
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
464 octave_value retval;
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
465
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8580
diff changeset
466 const octave_value_list tmp = rvalue (nargout);
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
467
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
468 if (! tmp.empty ())
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
469 retval = tmp(0);
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
470
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
471 return retval;
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
472 }
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
473
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
474 octave_lvalue
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
475 tree_index_expression::lvalue (void)
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
476 {
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
477 octave_lvalue retval;
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
478
4219
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4192
diff changeset
479 std::list<octave_value_list> idx;
9329
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
480 std::string tmp_type;
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
481
4219
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4192
diff changeset
482 int n = args.size ();
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
483
4219
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4192
diff changeset
484 std::list<tree_argument_list *>::iterator p_args = args.begin ();
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4192
diff changeset
485 std::list<string_vector>::iterator p_arg_nm = arg_nm.begin ();
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4192
diff changeset
486 std::list<tree_expression *>::iterator p_dyn_field = dyn_field.begin ();
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
487
4234
90e44267e8cf [project @ 2002-12-21 17:15:25 by jwe]
jwe
parents: 4233
diff changeset
488 retval = expr->lvalue ();
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
489
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
490 if (! error_state)
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
491 {
16442
302157614308 deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents: 15614
diff changeset
492 octave_value tmp = retval.value ();
4432
ff7187bd3075 [project @ 2003-06-19 16:40:53 by jwe]
jwe
parents: 4234
diff changeset
493
8551
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
494 octave_idx_type tmpi = 0;
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
495 std::list<octave_value_list> tmpidx;
4234
90e44267e8cf [project @ 2002-12-21 17:15:25 by jwe]
jwe
parents: 4233
diff changeset
496
90e44267e8cf [project @ 2002-12-21 17:15:25 by jwe]
jwe
parents: 4233
diff changeset
497 for (int i = 0; i < n; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
498 {
8551
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
499 if (retval.numel () != 1)
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
500 gripe_indexed_cs_list ();
9329
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
501 else if (tmpi < i)
8551
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
502 {
9329
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
503 tmp = tmp.subsref (type.substr (tmpi, i - tmpi), tmpidx, true);
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
504 tmpidx.clear ();
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
505 }
4432
ff7187bd3075 [project @ 2003-06-19 16:40:53 by jwe]
jwe
parents: 4234
diff changeset
506
9329
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
507 if (error_state)
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
508 break;
4432
ff7187bd3075 [project @ 2003-06-19 16:40:53 by jwe]
jwe
parents: 4234
diff changeset
509
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
510 switch (type[i])
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
511 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
512 case '(':
8551
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
513 {
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
514 octave_value_list tidx
14343
acc26b860afa fix indexed assignment bug (bug #35482)
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
515 = make_value_list (*p_args, *p_arg_nm, &tmp, false);
9329
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
516
8551
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
517 idx.push_back (tidx);
9329
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
518
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
519 if (i < n - 1)
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
520 {
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
521 if (type[i+1] == '.')
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
522 {
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
523 tmpidx.push_back (tidx);
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
524 tmpi = i+1;
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
525 }
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
526 else
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
527 error ("() must be followed by . or close the index chain");
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
528 }
8551
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
529 }
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
530 break;
4234
90e44267e8cf [project @ 2002-12-21 17:15:25 by jwe]
jwe
parents: 4233
diff changeset
531
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
532 case '{':
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
533 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
534 octave_value_list tidx
14343
acc26b860afa fix indexed assignment bug (bug #35482)
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
535 = make_value_list (*p_args, *p_arg_nm, &tmp, false);
5846
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5775
diff changeset
536
9329
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
537 if (tmp.is_undefined ())
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
538 {
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
539 if (tidx.has_magic_colon ())
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
540 gripe_invalid_inquiry_subscript ();
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
541 else
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
542 tmp = Cell ();
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
543 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
544 else if (tmp.is_zero_by_zero ()
9329
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
545 && (tmp.is_matrix_type () || tmp.is_string ()))
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
546 {
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
547 tmp = Cell ();
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
548 }
5846
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5775
diff changeset
549
9329
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
550 retval.numel (tmp.numel (tidx));
5846
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5775
diff changeset
551
8551
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
552 if (error_state)
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
553 break;
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
554
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
555 idx.push_back (tidx);
8551
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
556 tmpidx.push_back (tidx);
9329
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
557 tmpi = i;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
558 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
559 break;
4234
90e44267e8cf [project @ 2002-12-21 17:15:25 by jwe]
jwe
parents: 4233
diff changeset
560
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
561 case '.':
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
562 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
563 octave_value tidx = get_struct_index (p_arg_nm, p_dyn_field);
8546
3d8a914c580e improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents: 8011
diff changeset
564 if (error_state)
3d8a914c580e improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents: 8011
diff changeset
565 break;
6833
e8a18d380097 [project @ 2007-08-27 17:22:50 by jwe]
jwe
parents: 6811
diff changeset
566
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
567 bool autoconv = (tmp.is_zero_by_zero ()
9329
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
568 && (tmp.is_matrix_type () || tmp.is_string ()
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
569 || tmp.is_cell ()));
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
570
15020
560317fd5977 maint: Cuddle open bracket used for indexing C++ arrays in source code.
Rik <rik@octave.org>
parents: 14429
diff changeset
571 if (i > 0 && type[i-1] == '(')
8546
3d8a914c580e improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents: 8011
diff changeset
572 {
9329
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
573 octave_value_list pidx = idx.back ();
8551
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
574
11067
d7f0d115c10c pt-idx.cc (tree_expression::lvalue): use octave_map here, not octave_scalar_map
John W. Eaton <jwe@octave.org>
parents: 11066
diff changeset
575 // Use octave_map, not octave_scalar_map so that the
d7f0d115c10c pt-idx.cc (tree_expression::lvalue): use octave_map here, not octave_scalar_map
John W. Eaton <jwe@octave.org>
parents: 11066
diff changeset
576 // dimensions are 0x0, not 1x1.
9329
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
577 if (tmp.is_undefined ())
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
578 {
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
579 if (pidx.has_magic_colon ())
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
580 gripe_invalid_inquiry_subscript ();
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
581 else
11067
d7f0d115c10c pt-idx.cc (tree_expression::lvalue): use octave_map here, not octave_scalar_map
John W. Eaton <jwe@octave.org>
parents: 11066
diff changeset
582 tmp = octave_map ();
9329
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
583 }
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
584 else if (autoconv)
11067
d7f0d115c10c pt-idx.cc (tree_expression::lvalue): use octave_map here, not octave_scalar_map
John W. Eaton <jwe@octave.org>
parents: 11066
diff changeset
585 tmp = octave_map ();
8551
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
586
9329
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
587 retval.numel (tmp.numel (pidx));
8551
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
588
9329
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
589 tmpi = i-1;
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
590 tmpidx.push_back (tidx);
8546
3d8a914c580e improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents: 8011
diff changeset
591 }
8551
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
592 else
8546
3d8a914c580e improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents: 8011
diff changeset
593 {
9329
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
594 if (tmp.is_undefined () || autoconv)
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
595 {
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
596 tmpi = i+1;
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
597 tmp = octave_value ();
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
598 }
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
599 else
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
600 {
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
601 retval.numel (tmp.numel (octave_value_list ()));
7099
70f30a92b725 [project @ 2007-11-05 21:51:24 by jwe]
jwe
parents: 7057
diff changeset
602
9329
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
603 tmpi = i;
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
604 tmpidx.push_back (tidx);
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
605 }
8546
3d8a914c580e improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents: 8011
diff changeset
606 }
7057
c344920f9e9d [project @ 2007-10-24 04:39:57 by jwe]
jwe
parents: 7043
diff changeset
607
8551
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
608 if (error_state)
8546
3d8a914c580e improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents: 8011
diff changeset
609 break;
3d8a914c580e improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents: 8011
diff changeset
610
8551
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
611 idx.push_back (tidx);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
612 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
613 break;
4234
90e44267e8cf [project @ 2002-12-21 17:15:25 by jwe]
jwe
parents: 4233
diff changeset
614
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
615 default:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
616 panic_impossible ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
617 }
4234
90e44267e8cf [project @ 2002-12-21 17:15:25 by jwe]
jwe
parents: 4233
diff changeset
618
9329
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
619 if (idx.back ().empty ())
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
620 error ("invalid empty index list");
67fc970dad7d improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents: 9125
diff changeset
621
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
622 if (error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
623 break;
4234
90e44267e8cf [project @ 2002-12-21 17:15:25 by jwe]
jwe
parents: 4233
diff changeset
624
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
625 p_args++;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
626 p_arg_nm++;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
627 p_dyn_field++;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
628 }
3930
61d4427c016e [project @ 2002-05-07 00:47:31 by jwe]
jwe
parents: 3929
diff changeset
629
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3930
diff changeset
630 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
631 retval.set_index (type, idx);
8546
3d8a914c580e improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents: 8011
diff changeset
632
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
633 }
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
634
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
635 return retval;
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
636 }
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
637
7099
70f30a92b725 [project @ 2007-11-05 21:51:24 by jwe]
jwe
parents: 7057
diff changeset
638 /*
70f30a92b725 [project @ 2007-11-05 21:51:24 by jwe]
jwe
parents: 7057
diff changeset
639 %!test
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14343
diff changeset
640 %! clear x;
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14343
diff changeset
641 %! clear y;
14343
acc26b860afa fix indexed assignment bug (bug #35482)
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
642 %! y = 3;
acc26b860afa fix indexed assignment bug (bug #35482)
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
643 %! x(y(end)) = 1;
acc26b860afa fix indexed assignment bug (bug #35482)
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
644 %! assert (x, [0, 0, 1]);
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14343
diff changeset
645 %! clear x;
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14343
diff changeset
646 %! clear y;
14343
acc26b860afa fix indexed assignment bug (bug #35482)
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
647 %! y = {3};
acc26b860afa fix indexed assignment bug (bug #35482)
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
648 %! x(y{end}) = 1;
acc26b860afa fix indexed assignment bug (bug #35482)
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
649 %! assert (x, [0, 0, 1]);
acc26b860afa fix indexed assignment bug (bug #35482)
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
650
acc26b860afa fix indexed assignment bug (bug #35482)
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
651 %!test
7099
70f30a92b725 [project @ 2007-11-05 21:51:24 by jwe]
jwe
parents: 7057
diff changeset
652 %! x = {1, 2, 3};
70f30a92b725 [project @ 2007-11-05 21:51:24 by jwe]
jwe
parents: 7057
diff changeset
653 %! [x{:}] = deal (4, 5, 6);
70f30a92b725 [project @ 2007-11-05 21:51:24 by jwe]
jwe
parents: 7057
diff changeset
654 %! assert (x, {4, 5, 6});
70f30a92b725 [project @ 2007-11-05 21:51:24 by jwe]
jwe
parents: 7057
diff changeset
655
70f30a92b725 [project @ 2007-11-05 21:51:24 by jwe]
jwe
parents: 7057
diff changeset
656 %!test
70f30a92b725 [project @ 2007-11-05 21:51:24 by jwe]
jwe
parents: 7057
diff changeset
657 %! [x.a, x.b.c] = deal (1, 2);
70f30a92b725 [project @ 2007-11-05 21:51:24 by jwe]
jwe
parents: 7057
diff changeset
658 %! assert (x.a == 1 && x.b.c == 2);
70f30a92b725 [project @ 2007-11-05 21:51:24 by jwe]
jwe
parents: 7057
diff changeset
659
70f30a92b725 [project @ 2007-11-05 21:51:24 by jwe]
jwe
parents: 7057
diff changeset
660 %!test
70f30a92b725 [project @ 2007-11-05 21:51:24 by jwe]
jwe
parents: 7057
diff changeset
661 %! [x.a, x(2).b] = deal (1, 2);
70f30a92b725 [project @ 2007-11-05 21:51:24 by jwe]
jwe
parents: 7057
diff changeset
662 %! assert (x(1).a == 1 && isempty (x(2).a) && isempty (x(1).b) && x(2).b == 2);
70f30a92b725 [project @ 2007-11-05 21:51:24 by jwe]
jwe
parents: 7057
diff changeset
663
70f30a92b725 [project @ 2007-11-05 21:51:24 by jwe]
jwe
parents: 7057
diff changeset
664 %!test
70f30a92b725 [project @ 2007-11-05 21:51:24 by jwe]
jwe
parents: 7057
diff changeset
665 %! x = struct (zeros (0, 1), {"a", "b"});
70f30a92b725 [project @ 2007-11-05 21:51:24 by jwe]
jwe
parents: 7057
diff changeset
666 %! x(2).b = 1;
70f30a92b725 [project @ 2007-11-05 21:51:24 by jwe]
jwe
parents: 7057
diff changeset
667 %! assert (x(2).b == 1);
70f30a92b725 [project @ 2007-11-05 21:51:24 by jwe]
jwe
parents: 7057
diff changeset
668
70f30a92b725 [project @ 2007-11-05 21:51:24 by jwe]
jwe
parents: 7057
diff changeset
669 %!test
70f30a92b725 [project @ 2007-11-05 21:51:24 by jwe]
jwe
parents: 7057
diff changeset
670 %! x = struct (zeros (0, 1), {"a", "b"});
70f30a92b725 [project @ 2007-11-05 21:51:24 by jwe]
jwe
parents: 7057
diff changeset
671 %! x(2).b = 1;
70f30a92b725 [project @ 2007-11-05 21:51:24 by jwe]
jwe
parents: 7057
diff changeset
672 %! assert (x(2).b == 1);
70f30a92b725 [project @ 2007-11-05 21:51:24 by jwe]
jwe
parents: 7057
diff changeset
673 */
70f30a92b725 [project @ 2007-11-05 21:51:24 by jwe]
jwe
parents: 7057
diff changeset
674
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
675 tree_index_expression *
7767
71f068b22fcc scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
676 tree_index_expression::dup (symbol_table::scope_id scope,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10206
diff changeset
677 symbol_table::context_id context) const
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
678 {
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
679 tree_index_expression *new_idx_expr
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
680 = new tree_index_expression (line (), column ());
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
681
7767
71f068b22fcc scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
682 new_idx_expr->expr = expr ? expr->dup (scope, context) : 0;
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
683
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
684 std::list<tree_argument_list *> new_args;
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
685
8913
35cd375d4bb3 make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents: 8658
diff changeset
686 for (std::list<tree_argument_list *>::const_iterator p = args.begin ();
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
687 p != args.end ();
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
688 p++)
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
689 {
8913
35cd375d4bb3 make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents: 8658
diff changeset
690 const tree_argument_list *elt = *p;
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
691
7767
71f068b22fcc scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
692 new_args.push_back (elt ? elt->dup (scope, context) : 0);
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
693 }
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
694
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
695 new_idx_expr->args = new_args;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
696
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
697 new_idx_expr->type = type;
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
698
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
699 new_idx_expr->arg_nm = arg_nm;
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
700
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
701 std::list<tree_expression *> new_dyn_field;
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
702
8913
35cd375d4bb3 make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents: 8658
diff changeset
703 for (std::list<tree_expression *>::const_iterator p = dyn_field.begin ();
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
704 p != dyn_field.end ();
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
705 p++)
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
706 {
8913
35cd375d4bb3 make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents: 8658
diff changeset
707 const tree_expression *elt = *p;
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
708
7767
71f068b22fcc scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
709 new_dyn_field.push_back (elt ? elt->dup (scope, context) : 0);
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
710 }
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
711
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
712 new_idx_expr->dyn_field = new_dyn_field;
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
713
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
714 new_idx_expr->copy_base (*this);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
715
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
716 return new_idx_expr;
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
717 }
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5846
diff changeset
718
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
719 void
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
720 tree_index_expression::accept (tree_walker& tw)
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
721 {
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
722 tw.visit_index_expression (*this);
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
723 }