GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
pt-assign.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2018 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
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License 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 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if ! defined (octave_pt_assign_h)
24 #define octave_pt_assign_h 1
25 
26 #include "octave-config.h"
27 
28 #include <iosfwd>
29 #include <string>
30 
31 class octave_value;
32 class octave_value_list;
33 
34 #include "ov.h"
35 #include "pt-exp.h"
36 #include "pt-walk.h"
37 
38 namespace octave
39 {
40  class symbol_scope;
41  class octave_lvalue;
42  class tree_argument_list;
43 
44  // Simple assignment expressions.
45 
47  {
48  public:
49 
50  tree_simple_assignment (bool plhs = false, int l = -1, int c = -1,
52  : tree_expression (l, c), m_lhs (nullptr), m_rhs (nullptr),
53  m_preserve (plhs), m_ans_assign (), m_etype (t)
54  { }
55 
57  bool plhs = false, int l = -1, int c = -1,
59 
60  // No copying!
61 
63 
65 
67 
68  bool has_magic_end (void) const { return (m_rhs && m_rhs->has_magic_end ()); }
69 
70  bool rvalue_ok (void) const { return true; }
71 
72  bool is_assignment_expression (void) const { return true; }
73 
74  std::string oper (void) const;
75 
76  tree_expression * left_hand_side (void) { return m_lhs; }
77 
78  tree_expression * right_hand_side (void) { return m_rhs; }
79 
80  tree_expression * dup (symbol_scope& scope) const;
81 
82  void accept (tree_walker& tw)
83  {
84  tw.visit_simple_assignment (*this);
85  }
86 
87  octave_value::assign_op op_type (void) const { return m_etype; }
88 
89  private:
90 
91  void do_assign (octave_lvalue& ult, const octave_value_list& args,
92  const octave_value& rhs_val);
93 
94  void do_assign (octave_lvalue& ult, const octave_value& rhs_val);
95 
96  // The left hand side of the assignment.
98 
99  // The right hand side of the assignment.
101 
102  // True if we should not delete the lhs.
104 
105  // True if this is an assignment to the automatic variable ans.
107 
108  // The type of the expression.
110  };
111 
112  // Multi-valued assignment expressions.
113 
115  {
116  public:
117 
118  tree_multi_assignment (bool plhs = false, int l = -1, int c = -1)
119  : tree_expression (l, c), m_lhs (nullptr), m_rhs (nullptr),
120  m_preserve (plhs)
121  { }
122 
124  bool plhs = false, int l = -1, int c = -1);
125 
126  // No copying!
127 
129 
131 
132  ~tree_multi_assignment (void);
133 
134  bool has_magic_end (void) const
135  {
136  return (m_rhs && m_rhs->has_magic_end ());
137  }
138 
139  bool is_assignment_expression (void) const { return true; }
140 
141  bool rvalue_ok (void) const { return true; }
142 
143  std::string oper (void) const;
144 
146 
147  tree_expression * right_hand_side (void) { return m_rhs; }
148 
149  tree_expression * dup (symbol_scope& scope) const;
150 
151  void accept (tree_walker& tw)
152  {
153  tw.visit_multi_assignment (*this);
154  }
155 
157  {
159  }
160 
161  private:
162 
163  // The left hand side of the assignment.
165 
166  // The right hand side of the assignment.
168 
169  // True if we should not delete the lhs.
171  };
172 }
173 
174 #if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS)
175 
176 OCTAVE_DEPRECATED (4.4, "use 'octave::tree_simple_assignment' instead")
177 typedef octave::tree_simple_assignment tree_simple_assignment;
178 
179 OCTAVE_DEPRECATED (4.4, "use 'octave::tree_multi_assignment' instead")
180 typedef octave::tree_multi_assignment tree_multi_assignment;
181 
182 #endif
183 
184 #endif
tree_expression * right_hand_side(void)
Definition: pt-assign.h:78
tree_multi_assignment & operator=(const tree_multi_assignment &)=delete
assign_op
Definition: ov.h:136
bool rvalue_ok(void) const
Definition: pt-assign.h:70
tree_simple_assignment(bool plhs=false, int l=-1, int c=-1, octave_value::assign_op t=octave_value::op_asn_eq)
Definition: pt-assign.h:50
virtual void visit_multi_assignment(tree_multi_assignment &)=0
bool rvalue_ok(void) const
Definition: pt-assign.h:141
tree_expression * m_rhs
Definition: pt-assign.h:167
virtual bool has_magic_end(void) const =0
tree_expression * m_lhs
Definition: pt-assign.h:97
std::string oper(void) const
Definition: pt-assign.cc:56
octave_value::assign_op m_etype
Definition: pt-assign.h:109
tree_expression * dup(symbol_scope &scope) const
Definition: pt-assign.cc:97
bool is_assignment_expression(void) const
Definition: pt-assign.h:139
tree_simple_assignment & operator=(const tree_simple_assignment &)=delete
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function t
Definition: ov-usr-fcn.cc:997
nd example oindent opens the file binary numeric values will be read assuming they are stored in IEEE format with the least significant bit and then converted to the native representation Opening a file that is already open simply opens it again and returns a separate file id It is not an error to open a file several though writing to the same file through several different file ids may produce unexpected results The possible values of text mode reading and writing automatically converts linefeeds to the appropriate line end character for the you may append a you must also open the file in binary mode The parameter conversions are currently only supported for and permissions will be set to and then everything is written in a single operation This is very efficient and improves performance c
Definition: file-io.cc:587
std::string oper(void) const
Definition: pt-assign.cc:91
bool is_assignment_expression(void) const
Definition: pt-assign.h:72
bool has_magic_end(void) const
Definition: pt-assign.h:134
void accept(tree_walker &tw)
Definition: pt-assign.h:82
void do_assign(octave_lvalue &ult, const octave_value_list &args, const octave_value &rhs_val)
tree_multi_assignment(bool plhs=false, int l=-1, int c=-1)
Definition: pt-assign.h:118
tree_expression * left_hand_side(void)
Definition: pt-assign.h:76
tree_expression * right_hand_side(void)
Definition: pt-assign.h:147
virtual void visit_simple_assignment(tree_simple_assignment &)=0
tree_argument_list * m_lhs
Definition: pt-assign.h:164
octave_value::assign_op op_type(void) const
Definition: pt-assign.h:156
tree_argument_list * left_hand_side(void)
Definition: pt-assign.h:145
bool has_magic_end(void) const
Definition: pt-assign.h:68
tree_expression * dup(symbol_scope &scope) const
Definition: pt-assign.cc:62
void accept(tree_walker &tw)
Definition: pt-assign.h:151
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:888
tree_expression * m_rhs
Definition: pt-assign.h:100
octave_value::assign_op op_type(void) const
Definition: pt-assign.h:87