Mercurial > octave
diff libinterp/corefcn/oct-lvalue.h @ 24037:21915520ac7b
use more direct method for non-local symbol access (bug #38236)
* pt-id.h, pd-id.cc (tree_evaluator::get_current_scope): New function.
* symtab.h, symtab.cc (symbol_table::symbol_reference): Delete class.
(symbol_table::dummy_symbol_record): Delete static data member.
* oct-lvalue.h, oct-lvalue.cc (octave_lvalue::sym): Use symbol_record,
not symbol_reference. Change all uses.
(octave_lvalue::black_hole): New data member.
(octave_lvalue:is_black_hole): Use it.
(octave_lvalue::mark_black_hole): New function.
* pt-eval.cc (tree_identifier::sym): Use symbol_record, not
symbol_reference. Change all uses.
(tree_black_hole::lvalue): Explicitly mark retval as black_hole.
(tree_evaluator::visit_tree_identifier): Adapt to
tree_identifier::symbol returning symbol_record, not symbol_reference.
* oct-parse.in.yy (push_script_symtab, begin_file): New non-terminals.
(file): Use begin_file to start script and classdef files.
Use separate symbol table scope when parsing scripts.
* ov-usr-fcn.h, ov-usr-fcn.cc (octave_user_code::m_scope): Move here
from octave_user_fcn.
(octave_user_code::scope): Likewise.
(octave_user_script::octave_user_script): New argument scope.
(octave_user_script::call): Add
symbol_table::scope::unbind_script_symbols to unwind_protect frame.
Call scope::bind_script_symbols to access evaluation scope.
(octave_user_function::octave_user_function): Pass scope argument to
octave_user_code base class.
* symtab.h, symtab.cc (symbol_record_rep::m_fwd_rep): New data
member. Change member functions to forward to secondary rep if it is
defined.
(symbol_record::bind_fwd_rep, symbol_record_rep::bind_fwd_rep,
symbol_record::unbind_fwd_rep, symbol_record_rep::unbind_fwd_rep):
New functions.
(scope::bind_script_symbols, scope::unbind_script_symbols): New functions.
(scope::varval, scope::global_varval, scope::top_level_varval):
Now const.
(scope::update_nest): Set forwarding rep for nonlocal symbol.
(scope::look_nonlocal): Likewise.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 13 Sep 2017 17:10:51 -0400 |
parents | b9378eff6d13 |
children | bc3819b7cca1 |
line wrap: on
line diff
--- a/libinterp/corefcn/oct-lvalue.h Wed Sep 13 16:42:14 2017 -0700 +++ b/libinterp/corefcn/oct-lvalue.h Wed Sep 13 17:10:51 2017 -0400 @@ -38,13 +38,13 @@ { public: - octave_lvalue (const octave::symbol_table::symbol_reference& s - = octave::symbol_table::symbol_reference ()) - : sym (s), type (), idx (), nel (1) + octave_lvalue (const octave::symbol_table::symbol_record& s + = octave::symbol_table::symbol_record ()) + : sym (s), black_hole (false), type (), idx (), nel (1) { } octave_lvalue (const octave_lvalue& vr) - : sym (vr.sym), type (vr.type), idx (vr.idx), nel (vr.nel) + : sym (vr.sym), black_hole (vr.black_hole), type (vr.type), idx (vr.idx), nel (vr.nel) { } octave_lvalue& operator = (const octave_lvalue& vr) @@ -52,6 +52,7 @@ if (this != &vr) { sym = vr.sym; + black_hole = vr.black_hole; type = vr.type; idx = vr.idx; nel = vr.nel; @@ -62,21 +63,23 @@ ~octave_lvalue (void) = default; - bool is_black_hole (void) const { return sym.is_black_hole (); } + bool is_black_hole (void) const { return black_hole; } + + void mark_black_hole (void) { black_hole = true; } bool is_defined (void) const { - return ! is_black_hole () && sym->is_defined (); + return ! is_black_hole () && sym.is_defined (); } bool is_undefined (void) const { - return is_black_hole () || sym->is_undefined (); + return is_black_hole () || sym.is_undefined (); } bool isstruct (void) const { return value().isstruct (); } - void define (const octave_value& v) { sym->assign (v); } + void define (const octave_value& v) { sym.assign (v); } void assign (octave_value::assign_op, const octave_value&); @@ -98,7 +101,9 @@ private: - octave::symbol_table::symbol_reference sym; + octave::symbol_table::symbol_record sym; + + bool black_hole; std::string type;