GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
oct-lvalue.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 "error.h"
28 #include "ovl.h"
29 #include "oct-lvalue.h"
30 #include "ov.h"
31 
32 namespace octave
33 {
35  const octave_value& rhs)
36  {
37  if (! is_black_hole ())
38  {
39  if (m_idx.empty ())
40  m_sym.assign (op, rhs, m_context);
41  else
42  m_sym.assign (op, m_type, m_idx, rhs, m_context);
43  }
44  }
45 
47  const std::list<octave_value_list>& i)
48  {
49  if (! m_idx.empty ())
50  error ("invalid index expression in assignment");
51 
52  m_type = t;
53  m_idx = i;
54  }
55 
57  {
58  bool retval = false;
59 
60  if (m_idx.size () == 1)
61  {
62  octave_value_list tmp = m_idx.front ();
63 
64  retval = (tmp.length () == 1 && tmp(0).isempty ());
65  }
66 
67  return retval;
68  }
69 
71  {
72  if (! is_black_hole ())
73  {
74  if (m_idx.empty ())
76  else
78  }
79  }
80 
82  {
84 
85  if (! is_black_hole ())
86  {
88 
89  if (m_idx.empty ())
90  retval = val;
91  else
92  {
93  if (val.is_constant ())
94  retval = val.subsref (m_type, m_idx);
95  else
96  {
97  octave_value_list t = val.subsref (m_type, m_idx, 1);
98  if (t.length () > 0)
99  retval = t(0);
100  }
101  }
102  }
103 
104  return retval;
105  }
106 }
void do_unary_op(octave_value::unary_op op)
Definition: oct-lvalue.cc:70
assign_op
Definition: ov.h:136
void assign(const octave_value &value, context_id context)
Definition: symrec.h:592
std::string m_type
Definition: oct-lvalue.h:99
identity matrix If supplied two scalar respectively For allows like xample val
Definition: data.cc:4986
void error(const char *fmt,...)
Definition: error.cc:578
std::list< octave_value_list > m_idx
Definition: oct-lvalue.h:101
void do_non_const_unary_op(octave_value::unary_op op, context_id context)
Definition: symrec.h:611
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
octave_value value(void) const
Definition: oct-lvalue.cc:81
symbol_record::context_id m_context
Definition: oct-lvalue.h:95
symbol_record m_sym
Definition: oct-lvalue.h:93
void assign(octave_value::assign_op, const octave_value &)
Definition: oct-lvalue.cc:34
double tmp
Definition: data.cc:6252
octave_value retval
Definition: data.cc:6246
bool index_is_empty(void) const
Definition: oct-lvalue.cc:56
octave_idx_type length(void) const
Definition: ovl.h:96
void set_index(const std::string &t, const std::list< octave_value_list > &i)
Definition: oct-lvalue.cc:46
for i
Definition: data.cc:5264
octave_value varval(context_id context) const
Definition: symrec.h:624
unary_op
Definition: ov.h:81
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
bool is_black_hole(void) const
Definition: oct-lvalue.h:55