Mercurial > hg > octave-nkf
annotate src/pt-assign.h @ 8011:3100283874d7
improve backtrace error messages
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 05 Aug 2008 23:09:32 -0400 |
parents | 71f068b22fcc |
children | 0be8cf23b95c |
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 |
3523 | 68 std::string oper (void) const; |
2980 | 69 |
70 tree_expression *left_hand_side (void) { return lhs; } | |
71 | |
72 tree_expression *right_hand_side (void) { return rhs; } | |
73 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
74 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
|
75 symbol_table::context_id context); |
5861 | 76 |
2980 | 77 void accept (tree_walker& tw); |
78 | |
7087 | 79 octave_value::assign_op op_type (void) const { return etype; } |
80 | |
2980 | 81 private: |
82 | |
83 void do_assign (octave_lvalue& ult, const octave_value_list& args, | |
84 const octave_value& rhs_val); | |
85 | |
86 void do_assign (octave_lvalue& ult, const octave_value& rhs_val); | |
87 | |
88 // The left hand side of the assignment. | |
89 tree_expression *lhs; | |
90 | |
91 // The right hand side of the assignment. | |
92 tree_expression *rhs; | |
93 | |
94 // True if we should not delete the lhs. | |
95 bool preserve; | |
96 | |
5794 | 97 // True if this is an assignment to the automatic variable ans. |
2980 | 98 bool ans_ass; |
99 | |
100 // The type of the expression. | |
101 octave_value::assign_op etype; | |
2988 | 102 |
103 // No copying! | |
104 | |
2989 | 105 tree_simple_assignment (const tree_simple_assignment&); |
2988 | 106 |
2989 | 107 tree_simple_assignment& operator = (const tree_simple_assignment&); |
2980 | 108 }; |
109 | |
110 // Multi-valued assignment expressions. | |
111 | |
112 class | |
113 tree_multi_assignment : public tree_expression | |
114 { | |
115 public: | |
116 | |
3208 | 117 tree_multi_assignment (bool plhs = false, int l = -1, int c = -1, |
3527 | 118 octave_value::assign_op t = octave_value::op_asn_eq) |
3208 | 119 : tree_expression (l, c), lhs (0), rhs (0), preserve (plhs), etype(t) { } |
2980 | 120 |
121 tree_multi_assignment (tree_argument_list *lst, tree_expression *r, | |
3208 | 122 bool plhs = false, int l = -1, int c = -1, |
6253 | 123 octave_value::assign_op t = octave_value::op_asn_eq); |
2980 | 124 |
125 ~tree_multi_assignment (void); | |
126 | |
4267 | 127 bool has_magic_end (void) const { return (rhs && rhs->has_magic_end ()); } |
128 | |
3933 | 129 bool is_assignment_expression (void) const { return true; } |
2980 | 130 |
3933 | 131 bool rvalue_ok (void) const { return true; } |
2980 | 132 |
133 octave_value rvalue (void); | |
134 | |
135 octave_value_list rvalue (int nargout); | |
136 | |
3523 | 137 std::string oper (void) const; |
3208 | 138 |
2980 | 139 tree_argument_list *left_hand_side (void) { return lhs; } |
140 | |
141 tree_expression *right_hand_side (void) { return rhs; } | |
142 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
143 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
|
144 symbol_table::context_id context); |
5861 | 145 |
2980 | 146 void accept (tree_walker& tw); |
7087 | 147 |
148 octave_value::assign_op op_type (void) const { return etype; } | |
2980 | 149 |
150 private: | |
151 | |
3208 | 152 // The left hand side of the assignment. |
2980 | 153 tree_argument_list *lhs; |
3208 | 154 |
155 // The right hand side of the assignment. | |
2980 | 156 tree_expression *rhs; |
2988 | 157 |
3208 | 158 // True if we should not delete the lhs. |
159 bool preserve; | |
160 | |
161 // The type of the expression. | |
162 octave_value::assign_op etype; | |
163 | |
2988 | 164 // No copying! |
165 | |
2989 | 166 tree_multi_assignment (const tree_multi_assignment&); |
2988 | 167 |
2989 | 168 tree_multi_assignment& operator = (const tree_multi_assignment&); |
2980 | 169 }; |
170 | |
171 #endif | |
172 | |
173 /* | |
174 ;;; Local Variables: *** | |
175 ;;; mode: C++ *** | |
176 ;;; End: *** | |
177 */ |