Mercurial > hg > octave-lyh
annotate libinterp/parse-tree/pt-assign.h @ 17509:5f884a545c06
Fix uminus op support with scalar type
author | LYH <lyh.kernel@gmail.com> |
---|---|
date | Thu, 26 Sep 2013 04:56:03 +0800 |
parents | 8fbc09eded8c |
children |
rev | line source |
---|---|
2980 | 1 /* |
2 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
3 Copyright (C) 1996-2012 John W. Eaton |
2980 | 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 | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
2980 | 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 | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
2980 | 20 |
21 */ | |
22 | |
23 #if !defined (octave_tree_assign_h) | |
24 #define octave_tree_assign_h 1 | |
25 | |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
26 #include <iosfwd> |
2980 | 27 #include <string> |
28 | |
29 class tree_argument_list; | |
30 class tree_walker; | |
31 | |
32 class octave_value; | |
33 class octave_value_list; | |
34 class octave_lvalue; | |
35 | |
36 #include "ov.h" | |
37 #include "pt-exp.h" | |
7336 | 38 #include "symtab.h" |
2980 | 39 |
40 // Simple assignment expressions. | |
41 | |
42 class | |
43 tree_simple_assignment : public tree_expression | |
44 { | |
45 public: | |
46 | |
47 tree_simple_assignment (bool plhs = false, int l = -1, int c = -1, | |
10313 | 48 octave_value::assign_op t = octave_value::op_asn_eq) |
11584
cda4aa780d58
Another round of initialising members in the constructor initialisation list
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
11523
diff
changeset
|
49 : tree_expression (l, c), lhs (0), rhs (0), preserve (plhs), ans_ass (), |
16893
8fbc09eded8c
Complete removal of warning about assigning to ancient built-in variables.
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
50 etype (t) { } |
2980 | 51 |
52 tree_simple_assignment (tree_expression *le, tree_expression *re, | |
10313 | 53 bool plhs = false, int l = -1, int c = -1, |
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 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8037
diff
changeset
|
62 octave_value rvalue1 (int nargout = 1); |
2980 | 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, |
10313 | 75 symbol_table::context_id context) const; |
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, | |
10313 | 84 const octave_value& rhs_val); |
2980 | 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 | |
10230
0a5a769b8fc0
disallow computed multiple assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
117 tree_multi_assignment (bool plhs = false, int l = -1, int c = -1) |
16893
8fbc09eded8c
Complete removal of warning about assigning to ancient built-in variables.
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
118 : tree_expression (l, c), lhs (0), rhs (0), preserve (plhs) { } |
2980 | 119 |
120 tree_multi_assignment (tree_argument_list *lst, tree_expression *r, | |
10313 | 121 bool plhs = false, int l = -1, int c = -1); |
2980 | 122 |
123 ~tree_multi_assignment (void); | |
124 | |
4267 | 125 bool has_magic_end (void) const { return (rhs && rhs->has_magic_end ()); } |
126 | |
3933 | 127 bool is_assignment_expression (void) const { return true; } |
2980 | 128 |
3933 | 129 bool rvalue_ok (void) const { return true; } |
2980 | 130 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8037
diff
changeset
|
131 octave_value rvalue1 (int nargout = 1); |
2980 | 132 |
133 octave_value_list rvalue (int nargout); | |
134 | |
3523 | 135 std::string oper (void) const; |
3208 | 136 |
2980 | 137 tree_argument_list *left_hand_side (void) { return lhs; } |
138 | |
139 tree_expression *right_hand_side (void) { return rhs; } | |
140 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
141 tree_expression *dup (symbol_table::scope_id scope, |
10313 | 142 symbol_table::context_id context) const; |
5861 | 143 |
2980 | 144 void accept (tree_walker& tw); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11584
diff
changeset
|
145 |
10230
0a5a769b8fc0
disallow computed multiple assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
146 octave_value::assign_op op_type (void) const { return octave_value::op_asn_eq; } |
2980 | 147 |
148 private: | |
149 | |
3208 | 150 // The left hand side of the assignment. |
2980 | 151 tree_argument_list *lhs; |
3208 | 152 |
153 // The right hand side of the assignment. | |
2980 | 154 tree_expression *rhs; |
2988 | 155 |
3208 | 156 // True if we should not delete the lhs. |
157 bool preserve; | |
158 | |
2988 | 159 // No copying! |
160 | |
2989 | 161 tree_multi_assignment (const tree_multi_assignment&); |
2988 | 162 |
2989 | 163 tree_multi_assignment& operator = (const tree_multi_assignment&); |
2980 | 164 }; |
165 | |
166 #endif |