Mercurial > octave
changeset 24355:cc3b3ceb155c
update octave_lvalue class and move inside octave namespace
* oct-lvalue.h, oct-lvalue.cc (class octave_lvalue): Use m_ prefix for
member variable names. Move inside Octave namespace. Change all uses.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 04 Dec 2017 01:26:06 -0500 |
parents | 11d3603dd880 |
children | 8b14ba8296af |
files | libinterp/parse-tree/oct-lvalue.cc libinterp/parse-tree/oct-lvalue.h libinterp/parse-tree/pt-assign.h libinterp/parse-tree/pt-exp.h libinterp/parse-tree/pt-idx.h |
diffstat | 5 files changed, 111 insertions(+), 128 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/parse-tree/oct-lvalue.cc Sun Dec 03 16:42:16 2017 -0500 +++ b/libinterp/parse-tree/oct-lvalue.cc Mon Dec 04 01:26:06 2017 -0500 @@ -29,79 +29,78 @@ #include "oct-lvalue.h" #include "ov.h" -void -octave_lvalue::assign (octave_value::assign_op op, const octave_value& rhs) +namespace octave { - if (! is_black_hole ()) - { - if (idx.empty ()) - sym.assign (op, rhs); - else - sym.assign (op, type, idx, rhs); - } -} - -void -octave_lvalue::set_index (const std::string& t, - const std::list<octave_value_list>& i) -{ - if (! idx.empty ()) - error ("invalid index expression in assignment"); + void octave_lvalue::assign (octave_value::assign_op op, + const octave_value& rhs) + { + if (! is_black_hole ()) + { + if (m_idx.empty ()) + m_sym.assign (op, rhs); + else + m_sym.assign (op, m_type, m_idx, rhs); + } + } - type = t; - idx = i; -} + void octave_lvalue::set_index (const std::string& t, + const std::list<octave_value_list>& i) + { + if (! m_idx.empty ()) + error ("invalid index expression in assignment"); -bool -octave_lvalue::index_is_empty (void) const -{ - bool retval = false; + m_type = t; + m_idx = i; + } - if (idx.size () == 1) - { - octave_value_list tmp = idx.front (); + bool octave_lvalue::index_is_empty (void) const + { + bool retval = false; - retval = (tmp.length () == 1 && tmp(0).isempty ()); - } + if (m_idx.size () == 1) + { + octave_value_list tmp = m_idx.front (); - return retval; -} + retval = (tmp.length () == 1 && tmp(0).isempty ()); + } + + return retval; + } -void -octave_lvalue::do_unary_op (octave_value::unary_op op) -{ - if (! is_black_hole ()) - { - if (idx.empty ()) - sym.do_non_const_unary_op (op); - else - sym.do_non_const_unary_op (op, type, idx); - } -} + void octave_lvalue::do_unary_op (octave_value::unary_op op) + { + if (! is_black_hole ()) + { + if (m_idx.empty ()) + m_sym.do_non_const_unary_op (op); + else + m_sym.do_non_const_unary_op (op, m_type, m_idx); + } + } -octave_value -octave_lvalue::value (void) const -{ - octave_value retval; + octave_value octave_lvalue::value (void) const + { + octave_value retval; + + if (! is_black_hole ()) + { + octave_value val = m_sym.varval (); - if (! is_black_hole ()) - { - octave_value val = sym.varval (); + if (m_idx.empty ()) + retval = val; + else + { + if (val.is_constant ()) + retval = val.subsref (m_type, m_idx); + else + { + octave_value_list t = val.subsref (m_type, m_idx, 1); + if (t.length () > 0) + retval = t(0); + } + } + } - if (idx.empty ()) - retval = val; - else - { - if (val.is_constant ()) - retval = val.subsref (type, idx); - else - { - octave_value_list t = val.subsref (type, idx, 1); - if (t.length () > 0) - retval = t(0); - } - } - } - - return retval; + return retval; + } }
--- a/libinterp/parse-tree/oct-lvalue.h Sun Dec 03 16:42:16 2017 -0500 +++ b/libinterp/parse-tree/oct-lvalue.h Mon Dec 04 01:26:06 2017 -0500 @@ -25,91 +25,75 @@ #include "octave-config.h" -class octave_value; -class octave_value_list; - #include <string> #include "ovl.h" #include "symtab.h" -class -octave_lvalue +namespace octave { -public: - - octave_lvalue (const octave::symbol_record& s - = octave::symbol_record ()) - : sym (s), black_hole (false), type (), idx (), nel (1) - { } - - octave_lvalue (const octave_lvalue& vr) - : sym (vr.sym), black_hole (vr.black_hole), type (vr.type), idx (vr.idx), nel (vr.nel) - { } - - octave_lvalue& operator = (const octave_lvalue& vr) + class octave_lvalue { - if (this != &vr) - { - sym = vr.sym; - black_hole = vr.black_hole; - type = vr.type; - idx = vr.idx; - nel = vr.nel; - } + public: + + octave_lvalue (const symbol_record& sr = symbol_record ()) + : m_sym (sr), m_black_hole (false), m_type (), m_idx (), m_nel (1) + { } + + octave_lvalue (const octave_lvalue& vr) = default; + + octave_lvalue& operator = (const octave_lvalue& vr) = default; + + ~octave_lvalue (void) = default; + + bool is_black_hole (void) const { return m_black_hole; } - return *this; - } + void mark_black_hole (void) { m_black_hole = true; } - ~octave_lvalue (void) = default; - - bool is_black_hole (void) const { return black_hole; } + bool is_defined (void) const + { + return ! is_black_hole () && m_sym.is_defined (); + } - void mark_black_hole (void) { black_hole = true; } + bool is_undefined (void) const + { + return is_black_hole () || m_sym.is_undefined (); + } - bool is_defined (void) const - { - return ! is_black_hole () && sym.is_defined (); - } + bool isstruct (void) const { return value().isstruct (); } - bool is_undefined (void) const - { - return is_black_hole () || sym.is_undefined (); - } + void define (const octave_value& v) { m_sym.assign (v); } + + void assign (octave_value::assign_op, const octave_value&); - bool isstruct (void) const { return value().isstruct (); } + void numel (octave_idx_type n) { m_nel = n; } - void define (const octave_value& v) { sym.assign (v); } + octave_idx_type numel (void) const { return m_nel; } - void assign (octave_value::assign_op, const octave_value&); + void set_index (const std::string& t, const std::list<octave_value_list>& i); - void numel (octave_idx_type n) { nel = n; } + void clear_index (void) { m_type = ""; m_idx.clear (); } - octave_idx_type numel (void) const { return nel; } + std::string index_type (void) const { return m_type; } - void set_index (const std::string& t, const std::list<octave_value_list>& i); - - void clear_index (void) { type = ""; idx.clear (); } + bool index_is_empty (void) const; - std::string index_type (void) const { return type; } + void do_unary_op (octave_value::unary_op op); - bool index_is_empty (void) const; + octave_value value (void) const; - void do_unary_op (octave_value::unary_op op); + private: - octave_value value (void) const; - -private: + symbol_record m_sym; - octave::symbol_record sym; + bool m_black_hole; - bool black_hole; + std::string m_type; - std::string type; + std::list<octave_value_list> m_idx; - std::list<octave_value_list> idx; - - octave_idx_type nel; -}; + octave_idx_type m_nel; + }; +} #endif
--- a/libinterp/parse-tree/pt-assign.h Sun Dec 03 16:42:16 2017 -0500 +++ b/libinterp/parse-tree/pt-assign.h Mon Dec 04 01:26:06 2017 -0500 @@ -30,7 +30,6 @@ class octave_value; class octave_value_list; -class octave_lvalue; #include "ov.h" #include "pt-exp.h" @@ -39,6 +38,7 @@ namespace octave { + class octave_lvalue; class tree_argument_list; // Simple assignment expressions.
--- a/libinterp/parse-tree/pt-exp.h Sun Dec 03 16:42:16 2017 -0500 +++ b/libinterp/parse-tree/pt-exp.h Mon Dec 04 01:26:06 2017 -0500 @@ -29,13 +29,13 @@ #include <list> class octave_value; -class octave_lvalue; #include "pt.h" #include "symtab.h" namespace octave { + class octave_lvalue; class tree_evaluator; // A base class for expressions.
--- a/libinterp/parse-tree/pt-idx.h Sun Dec 03 16:42:16 2017 -0500 +++ b/libinterp/parse-tree/pt-idx.h Mon Dec 04 01:26:06 2017 -0500 @@ -30,7 +30,6 @@ class octave_map; class octave_value; class octave_value_list; -class octave_lvalue; #include "str-vec.h" @@ -40,6 +39,7 @@ namespace octave { + class octave_lvalue; class tree_argument_list; class tree_evaluator;