Mercurial > hg > octave-lyh
annotate src/pt-assign.h @ 10160:cd96d29c5efa
remove Emacs local-variable settings from source files in src directory
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 20 Jan 2010 20:39:26 -0500 |
parents | d865363208d6 |
children | 0a5a769b8fc0 |
rev | line source |
---|---|
2980 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1996, 1997, 1998, 2000, 2002, 2003, 2004, 2005, 2006, |
8920 | 4 2007, 2008, 2009 John W. Eaton |
2980 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
2980 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
2980 | 21 |
22 */ | |
23 | |
24 #if !defined (octave_tree_assign_h) | |
25 #define octave_tree_assign_h 1 | |
26 | |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
27 #include <iosfwd> |
2980 | 28 #include <string> |
29 | |
30 class tree_argument_list; | |
31 class tree_walker; | |
32 | |
33 class octave_value; | |
34 class octave_value_list; | |
35 class octave_lvalue; | |
36 | |
37 #include "ov.h" | |
38 #include "pt-exp.h" | |
7336 | 39 #include "symtab.h" |
2980 | 40 |
41 // Simple assignment expressions. | |
42 | |
43 class | |
44 tree_simple_assignment : public tree_expression | |
45 { | |
46 public: | |
47 | |
48 tree_simple_assignment (bool plhs = false, int l = -1, int c = -1, | |
3527 | 49 octave_value::assign_op t = octave_value::op_asn_eq) |
8037
0be8cf23b95c
check for obsolete built-in variable assignment at first execution rather than parse time
Jaroslav Hajek <highegg@gmail.com>
parents:
8011
diff
changeset
|
50 : tree_expression (l, c), lhs (0), rhs (0), preserve (plhs), etype (t), |
0be8cf23b95c
check for obsolete built-in variable assignment at first execution rather than parse time
Jaroslav Hajek <highegg@gmail.com>
parents:
8011
diff
changeset
|
51 first_execution (true) { } |
2980 | 52 |
53 tree_simple_assignment (tree_expression *le, tree_expression *re, | |
54 bool plhs = false, int l = -1, int c = -1, | |
6253 | 55 octave_value::assign_op t = octave_value::op_asn_eq); |
2980 | 56 |
57 ~tree_simple_assignment (void); | |
58 | |
4267 | 59 bool has_magic_end (void) const { return (rhs && rhs->has_magic_end ()); } |
60 | |
3933 | 61 bool rvalue_ok (void) const { return true; } |
2980 | 62 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8037
diff
changeset
|
63 octave_value rvalue1 (int nargout = 1); |
2980 | 64 |
65 octave_value_list rvalue (int nargout); | |
66 | |
3933 | 67 bool is_assignment_expression (void) const { return true; } |
2980 | 68 |
3523 | 69 std::string oper (void) const; |
2980 | 70 |
71 tree_expression *left_hand_side (void) { return lhs; } | |
72 | |
73 tree_expression *right_hand_side (void) { return rhs; } | |
74 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
75 tree_expression *dup (symbol_table::scope_id scope, |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
76 symbol_table::context_id context) const; |
5861 | 77 |
2980 | 78 void accept (tree_walker& tw); |
79 | |
7087 | 80 octave_value::assign_op op_type (void) const { return etype; } |
81 | |
2980 | 82 private: |
83 | |
84 void do_assign (octave_lvalue& ult, const octave_value_list& args, | |
85 const octave_value& rhs_val); | |
86 | |
87 void do_assign (octave_lvalue& ult, const octave_value& rhs_val); | |
88 | |
89 // The left hand side of the assignment. | |
90 tree_expression *lhs; | |
91 | |
92 // The right hand side of the assignment. | |
93 tree_expression *rhs; | |
94 | |
95 // True if we should not delete the lhs. | |
96 bool preserve; | |
97 | |
5794 | 98 // True if this is an assignment to the automatic variable ans. |
2980 | 99 bool ans_ass; |
100 | |
101 // The type of the expression. | |
102 octave_value::assign_op etype; | |
2988 | 103 |
8037
0be8cf23b95c
check for obsolete built-in variable assignment at first execution rather than parse time
Jaroslav Hajek <highegg@gmail.com>
parents:
8011
diff
changeset
|
104 // true only on first rvalue() call. |
0be8cf23b95c
check for obsolete built-in variable assignment at first execution rather than parse time
Jaroslav Hajek <highegg@gmail.com>
parents:
8011
diff
changeset
|
105 bool first_execution; |
0be8cf23b95c
check for obsolete built-in variable assignment at first execution rather than parse time
Jaroslav Hajek <highegg@gmail.com>
parents:
8011
diff
changeset
|
106 |
2988 | 107 // No copying! |
108 | |
2989 | 109 tree_simple_assignment (const tree_simple_assignment&); |
2988 | 110 |
2989 | 111 tree_simple_assignment& operator = (const tree_simple_assignment&); |
2980 | 112 }; |
113 | |
114 // Multi-valued assignment expressions. | |
115 | |
116 class | |
117 tree_multi_assignment : public tree_expression | |
118 { | |
119 public: | |
120 | |
3208 | 121 tree_multi_assignment (bool plhs = false, int l = -1, int c = -1, |
3527 | 122 octave_value::assign_op t = octave_value::op_asn_eq) |
8037
0be8cf23b95c
check for obsolete built-in variable assignment at first execution rather than parse time
Jaroslav Hajek <highegg@gmail.com>
parents:
8011
diff
changeset
|
123 : tree_expression (l, c), lhs (0), rhs (0), preserve (plhs), etype(t), |
0be8cf23b95c
check for obsolete built-in variable assignment at first execution rather than parse time
Jaroslav Hajek <highegg@gmail.com>
parents:
8011
diff
changeset
|
124 first_execution (true) { } |
2980 | 125 |
126 tree_multi_assignment (tree_argument_list *lst, tree_expression *r, | |
3208 | 127 bool plhs = false, int l = -1, int c = -1, |
6253 | 128 octave_value::assign_op t = octave_value::op_asn_eq); |
2980 | 129 |
130 ~tree_multi_assignment (void); | |
131 | |
4267 | 132 bool has_magic_end (void) const { return (rhs && rhs->has_magic_end ()); } |
133 | |
3933 | 134 bool is_assignment_expression (void) const { return true; } |
2980 | 135 |
3933 | 136 bool rvalue_ok (void) const { return true; } |
2980 | 137 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8037
diff
changeset
|
138 octave_value rvalue1 (int nargout = 1); |
2980 | 139 |
140 octave_value_list rvalue (int nargout); | |
141 | |
3523 | 142 std::string oper (void) const; |
3208 | 143 |
2980 | 144 tree_argument_list *left_hand_side (void) { return lhs; } |
145 | |
146 tree_expression *right_hand_side (void) { return rhs; } | |
147 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
148 tree_expression *dup (symbol_table::scope_id scope, |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
149 symbol_table::context_id context) const; |
5861 | 150 |
2980 | 151 void accept (tree_walker& tw); |
7087 | 152 |
153 octave_value::assign_op op_type (void) const { return etype; } | |
2980 | 154 |
155 private: | |
156 | |
3208 | 157 // The left hand side of the assignment. |
2980 | 158 tree_argument_list *lhs; |
3208 | 159 |
160 // The right hand side of the assignment. | |
2980 | 161 tree_expression *rhs; |
2988 | 162 |
3208 | 163 // True if we should not delete the lhs. |
164 bool preserve; | |
165 | |
166 // The type of the expression. | |
167 octave_value::assign_op etype; | |
168 | |
8037
0be8cf23b95c
check for obsolete built-in variable assignment at first execution rather than parse time
Jaroslav Hajek <highegg@gmail.com>
parents:
8011
diff
changeset
|
169 // true only on first rvalue() call. |
0be8cf23b95c
check for obsolete built-in variable assignment at first execution rather than parse time
Jaroslav Hajek <highegg@gmail.com>
parents:
8011
diff
changeset
|
170 bool first_execution; |
0be8cf23b95c
check for obsolete built-in variable assignment at first execution rather than parse time
Jaroslav Hajek <highegg@gmail.com>
parents:
8011
diff
changeset
|
171 |
2988 | 172 // No copying! |
173 | |
2989 | 174 tree_multi_assignment (const tree_multi_assignment&); |
2988 | 175 |
2989 | 176 tree_multi_assignment& operator = (const tree_multi_assignment&); |
2980 | 177 }; |
178 | |
179 #endif |