GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
pt-assign.cc
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 (HAVE_CONFIG_H)
24 # include "config.h"
25 #endif
26 
27 #include <iostream>
28 #include <string>
29 
30 #include "error.h"
31 #include "ov.h"
32 #include "pt-arg-list.h"
33 #include "pt-assign.h"
34 
35 namespace octave
36 {
37  // Simple assignment expressions.
38 
40  tree_expression *re,
41  bool plhs, int l, int c,
43  : tree_expression (l, c), m_lhs (le), m_rhs (re), m_preserve (plhs),
44  m_etype (t)
45  { }
46 
48  {
49  if (! m_preserve)
50  delete m_lhs;
51 
52  delete m_rhs;
53  }
54 
57  {
59  }
60 
63  {
65  = new tree_simple_assignment (m_lhs ? m_lhs->dup (scope) : nullptr,
66  m_rhs ? m_rhs->dup (scope) : nullptr,
68 
69  new_sa->copy_base (*this);
70 
71  return new_sa;
72  }
73 
74  // Multi-valued assignment expressions.
75 
77  tree_expression *r,
78  bool plhs, int l, int c)
79  : tree_expression (l, c), m_lhs (lst), m_rhs (r), m_preserve (plhs)
80  { }
81 
83  {
84  if (! m_preserve)
85  delete m_lhs;
86 
87  delete m_rhs;
88  }
89 
92  {
94  }
95 
98  {
100  return nullptr;
101  }
102 }
103 
104 /*
105 %!function varargout = f ()
106 %! varargout{1} = nargout;
107 %!endfunction
108 %!
109 %!test
110 %! [a, ~] = f ();
111 %! assert (a, 2);
112 %!test
113 %! [a, ~, ~, ~, ~] = f ();
114 %! assert (a, 5);
115 */
assign_op
Definition: ov.h:136
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
tree_expression * m_rhs
Definition: pt-assign.h:167
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
static std::string assign_op_as_string(assign_op)
Definition: ov.cc:348
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
virtual void copy_base(const tree_expression &e)
Definition: pt-exp.h:130
tree_multi_assignment(bool plhs=false, int l=-1, int c=-1)
Definition: pt-assign.h:118
#define panic_impossible()
Definition: error.h:40
tree_argument_list * m_lhs
Definition: pt-assign.h:164
octave_value::assign_op op_type(void) const
Definition: pt-assign.h:156
tree_expression * dup(symbol_scope &scope) const
Definition: pt-assign.cc:62
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
virtual tree_expression * dup(symbol_scope &scope) const =0