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; |
|
104 }; |
|
105 |
|
106 // Multi-valued assignment expressions. |
|
107 |
|
108 class |
|
109 tree_multi_assignment : public tree_expression |
|
110 { |
|
111 public: |
|
112 |
|
113 tree_multi_assignment (bool plhs = false, int l = -1, int c = -1) |
|
114 : tree_expression (l, c), preserve (plhs), lhs (0), rhs (0) { } |
|
115 |
|
116 tree_multi_assignment (tree_argument_list *lst, tree_expression *r, |
|
117 bool plhs = false, int l = -1, int c = -1) |
|
118 : tree_expression (l, c), preserve (plhs), lhs (lst), rhs (r) { } |
|
119 |
|
120 ~tree_multi_assignment (void); |
|
121 |
|
122 bool is_assignment_expression (void) const |
|
123 { return true; } |
|
124 |
|
125 bool rvalue_ok (void) const |
|
126 { return true; } |
|
127 |
|
128 octave_value rvalue (void); |
|
129 |
|
130 octave_value_list rvalue (int nargout); |
|
131 |
|
132 void eval_error (void); |
|
133 |
|
134 tree_argument_list *left_hand_side (void) { return lhs; } |
|
135 |
|
136 tree_expression *right_hand_side (void) { return rhs; } |
|
137 |
|
138 void accept (tree_walker& tw); |
|
139 |
|
140 private: |
|
141 |
|
142 bool preserve; |
|
143 tree_argument_list *lhs; |
|
144 tree_expression *rhs; |
|
145 }; |
|
146 |
|
147 #endif |
|
148 |
|
149 /* |
|
150 ;;; Local Variables: *** |
|
151 ;;; mode: C++ *** |
|
152 ;;; End: *** |
|
153 */ |