Mercurial > hg > octave-nkf
annotate src/pt-assign.h @ 7767:71f068b22fcc
scope and context fixes for function handles
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 07 May 2008 13:45:30 -0400 |
parents | 745a8299c2b5 |
children | 3100283874d7 |
rev | line source |
---|---|
2980 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1996, 1997, 1998, 2000, 2002, 2003, 2004, 2005, 2006, |
4 2007 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 | |
3503 | 27 #include <iostream> |
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) |
2980 | 50 : tree_expression (l, c), lhs (0), rhs (0), preserve (plhs), etype (t) { } |
51 | |
52 tree_simple_assignment (tree_expression *le, tree_expression *re, | |
53 bool plhs = false, int l = -1, int c = -1, | |
6253 | 54 octave_value::assign_op t = octave_value::op_asn_eq); |
2980 | 55 |
56 ~tree_simple_assignment (void); | |
57 | |
4267 | 58 bool has_magic_end (void) const { return (rhs && rhs->has_magic_end ()); } |
59 | |
3933 | 60 bool rvalue_ok (void) const { return true; } |
2980 | 61 |
62 octave_value rvalue (void); | |
63 | |
64 octave_value_list rvalue (int nargout); | |
65 | |
3933 | 66 bool is_assignment_expression (void) const { return true; } |
2980 | 67 |
68 void eval_error (void); | |
69 | |
3523 | 70 std::string oper (void) const; |
2980 | 71 |
72 tree_expression *left_hand_side (void) { return lhs; } | |
73 | |
74 tree_expression *right_hand_side (void) { return rhs; } | |
75 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
76 tree_expression *dup (symbol_table::scope_id scope, |
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
77 symbol_table::context_id context); |
5861 | 78 |
2980 | 79 void accept (tree_walker& tw); |
80 | |
7087 | 81 octave_value::assign_op op_type (void) const { return etype; } |
82 | |
2980 | 83 private: |
84 | |
85 void do_assign (octave_lvalue& ult, const octave_value_list& args, | |
86 const octave_value& rhs_val); | |
87 | |
88 void do_assign (octave_lvalue& ult, const octave_value& rhs_val); | |
89 | |
90 // The left hand side of the assignment. | |
91 tree_expression *lhs; | |
92 | |
93 // The right hand side of the assignment. | |
94 tree_expression *rhs; | |
95 | |
96 // True if we should not delete the lhs. | |
97 bool preserve; | |
98 | |
5794 | 99 // True if this is an assignment to the automatic variable ans. |
2980 | 100 bool ans_ass; |
101 | |
102 // The type of the expression. | |
103 octave_value::assign_op etype; | |
2988 | 104 |
105 // No copying! | |
106 | |
2989 | 107 tree_simple_assignment (const tree_simple_assignment&); |
2988 | 108 |
2989 | 109 tree_simple_assignment& operator = (const tree_simple_assignment&); |
2980 | 110 }; |
111 | |
112 // Multi-valued assignment expressions. | |
113 | |
114 class | |
115 tree_multi_assignment : public tree_expression | |
116 { | |
117 public: | |
118 | |
3208 | 119 tree_multi_assignment (bool plhs = false, int l = -1, int c = -1, |
3527 | 120 octave_value::assign_op t = octave_value::op_asn_eq) |
3208 | 121 : tree_expression (l, c), lhs (0), rhs (0), preserve (plhs), etype(t) { } |
2980 | 122 |
123 tree_multi_assignment (tree_argument_list *lst, tree_expression *r, | |
3208 | 124 bool plhs = false, int l = -1, int c = -1, |
6253 | 125 octave_value::assign_op t = octave_value::op_asn_eq); |
2980 | 126 |
127 ~tree_multi_assignment (void); | |
128 | |
4267 | 129 bool has_magic_end (void) const { return (rhs && rhs->has_magic_end ()); } |
130 | |
3933 | 131 bool is_assignment_expression (void) const { return true; } |
2980 | 132 |
3933 | 133 bool rvalue_ok (void) const { return true; } |
2980 | 134 |
135 octave_value rvalue (void); | |
136 | |
137 octave_value_list rvalue (int nargout); | |
138 | |
139 void eval_error (void); | |
140 | |
3523 | 141 std::string oper (void) const; |
3208 | 142 |
2980 | 143 tree_argument_list *left_hand_side (void) { return lhs; } |
144 | |
145 tree_expression *right_hand_side (void) { return rhs; } | |
146 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
147 tree_expression *dup (symbol_table::scope_id scope, |
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
148 symbol_table::context_id context); |
5861 | 149 |
2980 | 150 void accept (tree_walker& tw); |
7087 | 151 |
152 octave_value::assign_op op_type (void) const { return etype; } | |
2980 | 153 |
154 private: | |
155 | |
3208 | 156 // The left hand side of the assignment. |
2980 | 157 tree_argument_list *lhs; |
3208 | 158 |
159 // The right hand side of the assignment. | |
2980 | 160 tree_expression *rhs; |
2988 | 161 |
3208 | 162 // True if we should not delete the lhs. |
163 bool preserve; | |
164 | |
165 // The type of the expression. | |
166 octave_value::assign_op etype; | |
167 | |
2988 | 168 // No copying! |
169 | |
2989 | 170 tree_multi_assignment (const tree_multi_assignment&); |
2988 | 171 |
2989 | 172 tree_multi_assignment& operator = (const tree_multi_assignment&); |
2980 | 173 }; |
174 | |
175 #endif | |
176 | |
177 /* | |
178 ;;; Local Variables: *** | |
179 ;;; mode: C++ *** | |
180 ;;; End: *** | |
181 */ |