Mercurial > octave
annotate libinterp/parse-tree/pt-assign.cc @ 24270:bc3819b7cca1
don't use symbol_table:: nesting for symbol_record, symbol_scope, or fcn_info
Change all uses of symbol_table::symbol_record to symbol_record.
Change all uses of symbol_table::scope to symbol_scope.
Change all uses of symbol_table::fcn_info to fcn_info.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 16 Nov 2017 21:43:47 -0500 |
parents | 980f39c3ab90 |
children | 194eb4bd202b |
rev | line source |
---|---|
2980 | 1 /* |
2 | |
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
3 Copyright (C) 1996-2017 John W. Eaton |
2980 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
9 the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
10 (at your option) any later version. |
2980 | 11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
15 GNU General Public License for more details. |
2980 | 16 |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
2980 | 20 |
21 */ | |
22 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21568
diff
changeset
|
23 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
24 # include "config.h" |
2980 | 25 #endif |
26 | |
3503 | 27 #include <iostream> |
23656
609658f98feb
remove some unnecessary include statements from parse tree source
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
28 #include <string> |
2980 | 29 |
30 #include "error.h" | |
22898
9baa19102908
refactor display and disp functions (bug #49794)
John W. Eaton <jwe@octave.org>
parents:
22872
diff
changeset
|
31 #include "ov.h" |
2982 | 32 #include "pt-arg-list.h" |
2980 | 33 #include "pt-assign.h" |
34 | |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
35 namespace octave |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
36 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
37 // Simple assignment expressions. |
2980 | 38 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
39 tree_simple_assignment::tree_simple_assignment |
6253 | 40 (tree_expression *le, tree_expression *re, |
41 bool plhs, int l, int c, octave_value::assign_op t) | |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
42 : tree_expression (l, c), lhs (le), rhs (re), preserve (plhs), etype (t) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
43 { } |
6253 | 44 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
45 tree_simple_assignment::~tree_simple_assignment (void) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
46 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
47 if (! preserve) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
48 delete lhs; |
2980 | 49 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
50 delete rhs; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
51 } |
2980 | 52 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
53 std::string |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
54 tree_simple_assignment::oper (void) const |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
55 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
56 return octave_value::assign_op_as_string (etype); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
57 } |
5861 | 58 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
59 tree_expression * |
24270
bc3819b7cca1
don't use symbol_table:: nesting for symbol_record, symbol_scope, or fcn_info
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
60 tree_simple_assignment::dup (symbol_scope& scope) const |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
61 { |
23788
c94e9509461b
restore parse tree dup function delete in changeset 214cb58ccc1c
John W. Eaton <jwe@octave.org>
parents:
23656
diff
changeset
|
62 tree_simple_assignment *new_sa |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23788
diff
changeset
|
63 = new tree_simple_assignment (lhs ? lhs->dup (scope) : nullptr, |
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23788
diff
changeset
|
64 rhs ? rhs->dup (scope) : nullptr, |
23788
c94e9509461b
restore parse tree dup function delete in changeset 214cb58ccc1c
John W. Eaton <jwe@octave.org>
parents:
23656
diff
changeset
|
65 preserve, etype); |
c94e9509461b
restore parse tree dup function delete in changeset 214cb58ccc1c
John W. Eaton <jwe@octave.org>
parents:
23656
diff
changeset
|
66 |
c94e9509461b
restore parse tree dup function delete in changeset 214cb58ccc1c
John W. Eaton <jwe@octave.org>
parents:
23656
diff
changeset
|
67 new_sa->copy_base (*this); |
c94e9509461b
restore parse tree dup function delete in changeset 214cb58ccc1c
John W. Eaton <jwe@octave.org>
parents:
23656
diff
changeset
|
68 |
c94e9509461b
restore parse tree dup function delete in changeset 214cb58ccc1c
John W. Eaton <jwe@octave.org>
parents:
23656
diff
changeset
|
69 return new_sa; |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
70 } |
2980 | 71 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
72 // Multi-valued assignment expressions. |
2980 | 73 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
74 tree_multi_assignment::tree_multi_assignment |
6253 | 75 (tree_argument_list *lst, tree_expression *r, |
10230
0a5a769b8fc0
disallow computed multiple assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
10227
diff
changeset
|
76 bool plhs, int l, int c) |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
77 : tree_expression (l, c), lhs (lst), rhs (r), preserve (plhs) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
78 { } |
6253 | 79 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
80 tree_multi_assignment::~tree_multi_assignment (void) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
81 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
82 if (! preserve) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
83 delete lhs; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
84 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
85 delete rhs; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
86 } |
2980 | 87 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
88 std::string |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
89 tree_multi_assignment::oper (void) const |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
90 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
91 return octave_value::assign_op_as_string (op_type ()); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
92 } |
3977 | 93 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
94 tree_expression * |
24270
bc3819b7cca1
don't use symbol_table:: nesting for symbol_record, symbol_scope, or fcn_info
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
95 tree_multi_assignment::dup (symbol_scope&) const |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
96 { |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23435
diff
changeset
|
97 panic_impossible (); |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23788
diff
changeset
|
98 return nullptr; |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
99 } |
2980 | 100 } |
101 | |
14572
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
102 /* |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
103 %!function varargout = f () |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
104 %! varargout{1} = nargout; |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
105 %!endfunction |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
106 %! |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
107 %!test |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
108 %! [a, ~] = f (); |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
109 %! assert (a, 2); |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
110 %!test |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
111 %! [a, ~, ~, ~, ~] = f (); |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
112 %! assert (a, 5); |
000cd393f3c1
avoid error for calls to functions returning varargout that ignore final outputs (bug #36221)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
113 */ |