2980
|
1 /* |
|
2 |
|
3 Copyright (C) 1996, 1997 John W. Eaton |
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_tree_assign_h) |
|
24 #define octave_tree_assign_h 1 |
|
25 |
|
26 #if defined (__GNUG__) |
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 #include <string> |
|
31 |
|
32 class ostream; |
|
33 |
|
34 class tree_argument_list; |
|
35 class tree_walker; |
|
36 |
|
37 class octave_value; |
|
38 class octave_value_list; |
|
39 class octave_lvalue; |
|
40 |
|
41 #include "ov.h" |
|
42 #include "pt-exp.h" |
|
43 |
|
44 // Simple assignment expressions. |
|
45 |
|
46 class |
|
47 tree_simple_assignment : public tree_expression |
|
48 { |
|
49 public: |
|
50 |
|
51 tree_simple_assignment (bool plhs = false, int l = -1, int c = -1, |
|
52 octave_value::assign_op t = octave_value::asn_eq) |
|
53 : tree_expression (l, c), lhs (0), rhs (0), preserve (plhs), etype (t) { } |
|
54 |
|
55 tree_simple_assignment (tree_expression *le, tree_expression *re, |
|
56 bool plhs = false, int l = -1, int c = -1, |
|
57 octave_value::assign_op t = octave_value::asn_eq) |
|
58 : tree_expression (l, c), lhs (le), rhs (re), preserve (plhs), |
|
59 etype (t) { } |
|
60 |
|
61 ~tree_simple_assignment (void); |
|
62 |
|
63 bool rvalue_ok (void) const |
|
64 { return true; } |
|
65 |
|
66 octave_value rvalue (void); |
|
67 |
|
68 octave_value_list rvalue (int nargout); |
|
69 |
|
70 bool is_assignment_expression (void) const |
|
71 { return true; } |
|
72 |
|
73 void eval_error (void); |
|
74 |
|
75 string oper (void) const; |
|
76 |
|
77 tree_expression *left_hand_side (void) { return lhs; } |
|
78 |
|
79 tree_expression *right_hand_side (void) { return rhs; } |
|
80 |
|
81 void accept (tree_walker& tw); |
|
82 |
|
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 |
|
99 // True if this is an assignment to the built-in variable ans. |
|
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, |
|
120 octave_value::assign_op t = octave_value::asn_eq) |
|
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, |
|
125 octave_value::assign_op t = octave_value::asn_eq) |
|
126 : tree_expression (l, c), lhs (lst), rhs (r), preserve (plhs), |
|
127 etype (t) { } |
2980
|
128 |
|
129 ~tree_multi_assignment (void); |
|
130 |
|
131 bool is_assignment_expression (void) const |
|
132 { return true; } |
|
133 |
|
134 bool rvalue_ok (void) const |
|
135 { return true; } |
|
136 |
|
137 octave_value rvalue (void); |
|
138 |
|
139 octave_value_list rvalue (int nargout); |
|
140 |
|
141 void eval_error (void); |
|
142 |
3208
|
143 string oper (void) const; |
|
144 |
2980
|
145 tree_argument_list *left_hand_side (void) { return lhs; } |
|
146 |
|
147 tree_expression *right_hand_side (void) { return rhs; } |
|
148 |
|
149 void accept (tree_walker& tw); |
|
150 |
|
151 private: |
|
152 |
3208
|
153 // The left hand side of the assignment. |
2980
|
154 tree_argument_list *lhs; |
3208
|
155 |
|
156 // The right hand side of the assignment. |
2980
|
157 tree_expression *rhs; |
2988
|
158 |
3208
|
159 // True if we should not delete the lhs. |
|
160 bool preserve; |
|
161 |
|
162 // The type of the expression. |
|
163 octave_value::assign_op etype; |
|
164 |
2988
|
165 // No copying! |
|
166 |
2989
|
167 tree_multi_assignment (const tree_multi_assignment&); |
2988
|
168 |
2989
|
169 tree_multi_assignment& operator = (const tree_multi_assignment&); |
2980
|
170 }; |
|
171 |
|
172 #endif |
|
173 |
|
174 /* |
|
175 ;;; Local Variables: *** |
|
176 ;;; mode: C++ *** |
|
177 ;;; End: *** |
|
178 */ |