GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
pt-assign.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2013 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 3 of the License, or (at your
10 option) any 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, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if !defined (octave_pt_assign_h)
24 #define octave_pt_assign_h 1
25 
26 #include <iosfwd>
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"
38 #include "symtab.h"
39 
40 // Simple assignment expressions.
41 
42 class
44 {
45 public:
46 
47  tree_simple_assignment (bool plhs = false, int l = -1, int c = -1,
49  : tree_expression (l, c), lhs (0), rhs (0), preserve (plhs), ans_ass (),
50  etype (t) { }
51 
53  bool plhs = false, int l = -1, int c = -1,
55 
56  ~tree_simple_assignment (void);
57 
58  bool has_magic_end (void) const { return (rhs && rhs->has_magic_end ()); }
59 
60  bool rvalue_ok (void) const { return true; }
61 
62  octave_value rvalue1 (int nargout = 1);
63 
64  octave_value_list rvalue (int nargout);
65 
66  bool is_assignment_expression (void) const { return true; }
67 
68  std::string oper (void) const;
69 
70  tree_expression *left_hand_side (void) { return lhs; }
71 
72  tree_expression *right_hand_side (void) { return rhs; }
73 
76 
77  void accept (tree_walker& tw);
78 
79  octave_value::assign_op op_type (void) const { return etype; }
80 
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.
90 
91  // The right hand side of the assignment.
93 
94  // True if we should not delete the lhs.
95  bool preserve;
96 
97  // True if this is an assignment to the automatic variable ans.
98  bool ans_ass;
99 
100  // The type of the expression.
102 
103  // No copying!
104 
106 
108 };
109 
110 // Multi-valued assignment expressions.
111 
112 class
114 {
115 public:
116 
117  tree_multi_assignment (bool plhs = false, int l = -1, int c = -1)
118  : tree_expression (l, c), lhs (0), rhs (0), preserve (plhs) { }
119 
121  bool plhs = false, int l = -1, int c = -1);
122 
123  ~tree_multi_assignment (void);
124 
125  bool has_magic_end (void) const { return (rhs && rhs->has_magic_end ()); }
126 
127  bool is_assignment_expression (void) const { return true; }
128 
129  bool rvalue_ok (void) const { return true; }
130 
131  octave_value rvalue1 (int nargout = 1);
132 
133  octave_value_list rvalue (int nargout);
134 
135  std::string oper (void) const;
136 
137  tree_argument_list *left_hand_side (void) { return lhs; }
138 
139  tree_expression *right_hand_side (void) { return rhs; }
140 
143 
144  void accept (tree_walker& tw);
145 
146  octave_value::assign_op op_type (void) const
147  { return octave_value::op_asn_eq; }
148 
149 private:
150 
151  // The left hand side of the assignment.
153 
154  // The right hand side of the assignment.
156 
157  // True if we should not delete the lhs.
158  bool preserve;
159 
160  // No copying!
161 
163 
165 };
166 
167 #endif