Mercurial > octave
view libinterp/corefcn/symrec.cc @ 24361:8bcfddad15ec
use shared_ptr to manage symbol_scope objects
* symscope.h, symscope.cc (symbol_scope_rep): New class, renamed and
adapted from symbol_scope.
(symbol_scope): New class to manage symbol_scope_rep with shared_ptr.
Change all uses of pointers ot symbol_scope objects to be symbol_scope
objects or, in a few cases, pointers to symbol_scope_rep objects
instead.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 27 Nov 2017 01:12:05 -0500 |
parents | 8b14ba8296af |
children | 2706adccf4e9 |
line wrap: on
line source
/* Copyright (C) 1993-2017 John W. Eaton Copyright (C) 2009 VZLU Prague, a.s. This file is part of Octave. Octave is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. Octave is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Octave; see the file COPYING. If not, see <http://www.gnu.org/licenses/>. */ #if defined (HAVE_CONFIG_H) # include "config.h" #endif #include <sstream> #include "file-ops.h" #include "file-stat.h" #include "oct-env.h" #include "oct-time.h" #include "fcn-info.h" #include "interpreter-private.h" #include "interpreter.h" #include "symrec.h" #include "symscope.h" #include "symtab.h" namespace octave { symbol_record::context_id symbol_record::symbol_record_rep::get_fwd_scope_context (void) const { return m_fwd_scope ? m_fwd_scope->current_context () : 0; } void symbol_record::symbol_record_rep::init_persistent (void) { if (auto t_fwd_rep = m_fwd_rep.lock ()) { t_fwd_rep->init_persistent (); return; } mark_persistent (); } symbol_record::symbol_record_rep * symbol_record::symbol_record_rep::dup (symbol_scope_rep *new_scope) const { // FIXME: is this the right thing do to? if (auto t_fwd_rep = m_fwd_rep.lock ()) return t_fwd_rep->dup (new_scope); static const context_id FIXME_CONTEXT = 0; return new symbol_record_rep (m_name, varval (FIXME_CONTEXT), m_storage_class); } octave_value symbol_record::symbol_record_rep::dump (context_id context) const { if (auto t_fwd_rep = m_fwd_rep.lock ()) return t_fwd_rep->dump (context); std::map<std::string, octave_value> m = {{ "name", m_name }, { "local", is_local () }, { "automatic", is_automatic () }, { "formal", is_formal () }, { "hidden", is_hidden () }, { "inherited", is_inherited () }, { "global", is_global () }, { "persistent", is_persistent () }}; octave_value val = varval (context); if (val.is_defined ()) m["value"] = val; return octave_value (m); } octave_value symbol_record::find (context_id context, const octave_value_list& args) const { octave_value retval; symbol_table& symtab = __get_symbol_table__ ("symbol_record::find"); retval = varval (context); if (retval.is_undefined ()) { // FIXME retval = symtab.find_function (name (), args); if (retval.is_defined ()) return retval; } return retval; } octave_value symbol_record::dummy_octave_value; }