GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
symrec.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1993-2018 John W. Eaton
4 Copyright (C) 2009 VZLU Prague, a.s.
5 
6 This file is part of Octave.
7 
8 Octave is free software: you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12 
13 Octave is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with Octave; see the file COPYING. If not, see
20 <https://www.gnu.org/licenses/>.
21 
22 */
23 
24 #if defined (HAVE_CONFIG_H)
25 # include "config.h"
26 #endif
27 
28 #include <sstream>
29 
30 #include "file-ops.h"
31 #include "file-stat.h"
32 #include "oct-env.h"
33 #include "oct-time.h"
34 
35 #include "fcn-info.h"
36 #include "interpreter-private.h"
37 #include "interpreter.h"
38 #include "symrec.h"
39 #include "symscope.h"
40 #include "symtab.h"
41 
42 namespace octave
43 {
46  {
47  // This should NOT recurse. We only want to know the current
48  // context of the immediately forwarded rep object. This is used
49  // only in symbol_record::symbol_record_rep::varref and
50  // symbol_record::symbol_record_rep::varval.
51 
52  auto t_fwd_scope = m_fwd_scope.lock ();
53  return t_fwd_scope ? t_fwd_scope->current_context () : 0;
54  }
55 
56  void
58  {
59  if (auto t_fwd_rep = m_fwd_rep.lock ())
60  {
61  t_fwd_rep->init_persistent ();
62  return;
63  }
64 
65  mark_persistent ();
66  }
67 
68  std::shared_ptr<symbol_record::symbol_record_rep>
69  symbol_record::symbol_record_rep::dup (const std::shared_ptr<symbol_scope_rep>& new_scope) const
70  {
71  // FIXME: is this the right thing do to?
72  if (auto t_fwd_rep = m_fwd_rep.lock ())
73  return t_fwd_rep->dup (new_scope);
74 
75  static const context_id FIXME_CONTEXT = 0;
76 
77  return std::shared_ptr<symbol_record_rep>
78  (new symbol_record_rep (m_name, varval (FIXME_CONTEXT),
79  m_storage_class));
80  }
81 
84  {
85  if (auto t_fwd_rep = m_fwd_rep.lock ())
86  return t_fwd_rep->dump (context);
87 
88  std::map<std::string, octave_value> m
89  = {{ "name", m_name },
90  { "local", is_local () },
91  { "automatic", is_automatic () },
92  { "formal", is_formal () },
93  { "hidden", is_hidden () },
94  { "inherited", is_inherited () },
95  { "global", is_global () },
96  { "persistent", is_persistent () }};
97 
99 
100  if (val.is_defined ())
101  m["value"] = val;
102 
103  return octave_value (m);
104  }
105 
108  const octave_value_list& args) const
109  {
110  // FIXME: it would be better if the symbol_record object did not
111  // look back to the symbol_table when the value is undefined. More
112  // refactoring is needed...
113 
114  symbol_table& symtab
115  = __get_symbol_table__ ("symbol_record::find_function");
116 
117  return symtab.find_function (name, args);
118  }
119 
121 }
octave_value find_function(const std::string &name, const octave_value_list &args=octave_value_list(), bool local_funcs=true)
Definition: symtab.cc:412
bool is_global(void) const
Definition: symrec.h:653
std::weak_ptr< symbol_scope_rep > m_fwd_scope
Definition: symrec.h:550
static octave_value dummy_octave_value
Definition: symrec.h:710
identity matrix If supplied two scalar respectively For allows like xample val
Definition: data.cc:4986
std::shared_ptr< symbol_record_rep > dup(const std::shared_ptr< symbol_scope_rep > &new_scope) const
Definition: symrec.cc:69
static llvm::LLVMContext & context
Definition: jit-typeinfo.cc:79
bool is_inherited(void) const
Definition: symrec.h:655
bool is_local(void) const
Definition: symrec.h:650
bool is_persistent(void) const
Definition: symrec.h:657
octave_value dump(void) const
Definition: ov.h:1399
octave_value find_function(const std::string &name, const octave_value_list &args) const
Definition: symrec.cc:107
symbol_table & __get_symbol_table__(const std::string &who)
octave_value dump(context_id context) const
Definition: symrec.cc:83
std::string name(void) const
Definition: symrec.h:576
bool is_formal(void) const
Definition: symrec.h:652
bool is_automatic(void) const
Definition: symrec.h:651
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
bool is_hidden(void) const
Definition: symrec.h:654
octave_value varval(context_id context) const
Definition: symrec.h:624
context_id get_fwd_scope_context(void) const
Definition: symrec.cc:45
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
void mark_persistent(void)
Definition: symrec.h:665