GNU Octave  9.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
symscope.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1993-2024 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_symscope_h)
27 #define octave_symscope_h 1
28 
29 #include "octave-config.h"
30 
31 #include <deque>
32 #include <list>
33 #include <map>
34 #include <memory>
35 #include <set>
36 #include <string>
37 
38 #include "glob-match.h"
39 #include "lo-regexp.h"
40 #include "oct-refcount.h"
41 
42 class tree_argument_list;
43 class octave_user_code;
44 
45 #include "ov.h"
46 #include "ovl.h"
47 #include "symrec.h"
48 
50 
51 class symbol_scope;
52 
54  : public std::enable_shared_from_this<symbol_scope_rep>
55 {
56 public:
57 
58  typedef std::map<std::string, symbol_record>::const_iterator
60  typedef std::map<std::string, symbol_record>::iterator
62 
63  typedef std::map<std::string, octave_value>::const_iterator
65  typedef std::map<std::string, octave_value>::iterator
67 
68  symbol_scope_rep (const std::string& name = "", bool add_ans = true)
69  : m_name (name), m_symbols (), m_subfunctions (),
70  m_persistent_values (), m_code (nullptr), m_fcn_name (),
71  m_fcn_file_name (), m_dir_name (), m_parent (),
72  m_primary_parent (), m_children (), m_nesting_depth (0),
73  m_is_static (false), m_is_primary_fcn_scope (false)
74  {
75  // Most scopes have ans as the first symbol, initially undefined.
76  if (add_ans)
77  insert_local ("ans");
78  }
79 
80  OCTAVE_DISABLE_COPY_MOVE (symbol_scope_rep)
81 
82  ~symbol_scope_rep () = default;
83 
84  std::size_t num_symbols () const { return m_symbols.size (); }
85 
86  // Simply inserts symbol. No non-local searching.
87 
88  symbol_record insert_local (const std::string& name);
89 
91 
92  bool is_nested () const { return m_nesting_depth > 0; }
93 
94  std::size_t nesting_depth () const { return m_nesting_depth; }
95 
96  void set_nesting_depth (std::size_t depth) { m_nesting_depth = depth; }
97 
98  bool is_parent () const { return ! m_children.empty (); }
99 
100  bool is_static () const { return m_is_static; }
101 
102  void mark_static () { m_is_static = true; }
103 
104  std::shared_ptr<symbol_scope_rep> parent_scope_rep () const
105  {
106  return m_parent.lock ();
107  }
108 
109  std::shared_ptr<symbol_scope_rep> primary_parent_scope_rep () const
110  {
111  return m_primary_parent.lock ();
112  }
113 
114  std::shared_ptr<symbol_scope_rep> dup () const
115  {
116  std::shared_ptr<symbol_scope_rep> new_sid
117  = std::shared_ptr<symbol_scope_rep> (new symbol_scope_rep (m_name));
118 
119  for (const auto& nm_sr : m_symbols)
120  new_sid->m_symbols[nm_sr.first] = nm_sr.second.dup ();
121 
122  new_sid->m_subfunctions = m_subfunctions;
123  new_sid->m_persistent_values = m_persistent_values;
124  new_sid->m_subfunction_names = m_subfunction_names;
125  new_sid->m_code = m_code;
126  new_sid->m_fcn_name = m_fcn_name;
127  new_sid->m_fcn_file_name = m_fcn_file_name;
128  new_sid->m_dir_name = m_dir_name;
129  new_sid->m_parent = m_parent;
130  new_sid->m_primary_parent = m_primary_parent;
131  new_sid->m_children = m_children;
132  new_sid->m_nesting_depth = m_nesting_depth;
133  new_sid->m_is_static = m_is_static;
134  new_sid->m_is_primary_fcn_scope = m_is_primary_fcn_scope;
135 
136  return new_sid;
137  }
138 
139  octave_value& persistent_varref (std::size_t data_offset)
140  {
141  return m_persistent_values[data_offset];
142  }
143 
144  octave_value persistent_varval (std::size_t data_offset) const
145  {
146  auto p = m_persistent_values.find (data_offset);
147 
148  return p == m_persistent_values.end () ? octave_value () : p->second;
149  }
150 
151  symbol_record find_symbol (const std::string& name)
152  {
153  auto p = m_symbols.find (name);
154 
155  if (p == m_symbols.end ())
156  return insert (name);
157  else
158  return p->second;
159  }
160 
161  symbol_record lookup_symbol (const std::string& name) const
162  {
163  auto p = m_symbols.find (name);
164 
165  return p == m_symbols.end () ? symbol_record () : p->second;
166  }
167 
168  symbol_record insert (const std::string& name);
169 
170  void rename (const std::string& old_name, const std::string& new_name)
171  {
172  auto p = m_symbols.find (old_name);
173 
174  if (p != m_symbols.end ())
175  {
176  symbol_record sr = p->second;
177 
178  sr.rename (new_name);
179 
180  m_symbols.erase (p);
181 
182  m_symbols[new_name] = sr;
183  }
184  }
185 
186  void install_subfunction (const std::string& name,
187  const octave_value& fval)
188  {
189  m_subfunctions[name] = fval;
190  }
191 
192  void install_nestfunction (const std::string& name,
193  const octave_value& fval,
194  const symbol_scope& fcn_scope)
195  {
196  m_subfunctions[name] = fval;
197 
198  m_children.push_back (fcn_scope);
199  }
200 
201  octave_value find_subfunction (const std::string& name) const;
202 
204  {
205  for (auto& nm_sf : m_subfunctions)
206  nm_sf.second.lock ();
207  }
208 
210  {
211  for (auto& nm_sf : m_subfunctions)
212  nm_sf.second.unlock ();
213  }
214 
215  // Pairs of name, function objects.
216  std::map<std::string, octave_value> subfunctions () const
217  {
218  return m_subfunctions;
219  }
220 
222  {
223  m_subfunctions.clear ();
224  }
225 
226  void mark_subfunctions_in_scope_as_private (const std::string& class_name);
227 
228  bool has_subfunctions () const
229  {
230  return ! m_subfunction_names.empty ();
231  }
232 
233  void stash_subfunction_names (const std::list<std::string>& names)
234  {
235  m_subfunction_names = names;
236  }
237 
238  std::list<std::string> subfunction_names () const
239  {
240  return m_subfunction_names;
241  }
242 
243  std::list<octave_value> localfunctions () const;
244 
245  octave_value dump () const;
246 
247  std::string name () const { return m_name; }
248 
249  void cache_name (const std::string& name) { m_name = name; }
250 
251  std::string fcn_name () const { return m_fcn_name; }
252 
253  void cache_fcn_name (const std::string& name) { m_fcn_name = name; }
254 
255  std::list<std::string> parent_fcn_names () const;
256 
257  octave_user_code * user_code () const { return m_code; }
258 
259  void set_user_code (octave_user_code *code) { m_code = code; }
260 
261  void set_parent (const std::shared_ptr<symbol_scope_rep>& parent);
262 
263  void set_primary_parent (const std::shared_ptr<symbol_scope_rep>& parent);
264 
265  void cache_fcn_file_name (const std::string& name)
266  {
267  m_fcn_file_name = name;
268  }
269 
270  std::string fcn_file_name () const { return m_fcn_file_name; }
271 
272  void cache_dir_name (const std::string& name);
273 
274  std::string dir_name () const { return m_dir_name; }
275 
276  void mark_primary_fcn_scope () { m_is_primary_fcn_scope = true; }
277 
278  bool is_primary_fcn_scope () const { return m_is_primary_fcn_scope; }
279 
280  bool is_relative (const std::shared_ptr<symbol_scope_rep>& scope) const;
281 
282  void mark_as_variable (const std::string& nm);
283  void mark_as_variables (const std::list<std::string>& lst);
284 
285  bool is_variable (const std::string& nm) const;
286 
287  void update_nest ();
288 
289  bool look_nonlocal (const std::string& name, std::size_t offset,
290  symbol_record& result);
291 
293 
294  const std::map<std::string, symbol_record>& symbols () const
295  {
296  return m_symbols;
297  }
298 
299  std::map<std::string, symbol_record>& symbols ()
300  {
301  return m_symbols;
302  }
303 
304  std::list<symbol_record> symbol_list () const;
305 
306 private:
307 
308  //! Name for this scope (usually the corresponding filename of the
309  //! function corresponding to the scope).
310 
311  std::string m_name;
312 
313  //! Map from symbol names to symbol info.
314 
315  std::map<std::string, symbol_record> m_symbols;
316 
317  //! Map from symbol names to subfunctions.
318 
319  std::map<std::string, octave_value> m_subfunctions;
320 
321  //! Map from data offset to persistent values in this scope.
322  std::map<std::size_t, octave_value> m_persistent_values;
323 
324  //! The list of subfunctions (if any) in the order they appear in
325  //! the function file.
326 
327  std::list<std::string> m_subfunction_names;
328 
329  //! The associated user code (may be null).
330 
331  octave_user_code *m_code;
332 
333  //! Simple name of the function corresponding to this scope.
334 
335  std::string m_fcn_name;
336 
337  //! The file name associated with m_code.
338 
339  std::string m_fcn_file_name;
340 
341  //! The directory associated with m_code.
342 
343  std::string m_dir_name;
344 
345  //! Parent of nested function (may be null).
346 
347  std::weak_ptr<symbol_scope_rep> m_parent;
348 
349  //! Primary (top) parent of nested function (may be null). Used
350  //! to determine whether two nested functions are related.
351 
352  std::weak_ptr<symbol_scope_rep> m_primary_parent;
353 
354  //! Child nested functions.
355 
356  std::vector<symbol_scope> m_children;
357 
358  //! If true, then this scope belongs to a nested function.
359 
360  std::size_t m_nesting_depth;
361 
362  //! If true then no variables can be added.
363 
364  bool m_is_static;
365 
366  //! If true, this is the scope of a primary function.
367  bool m_is_primary_fcn_scope;
368 };
369 
371 {
372 public:
373 
374  symbol_scope () = delete;
375 
376  // Create a valid but possibly anonymous scope. If NAME is empty, the
377  // scope is anonymous, but it is better to state that intent clearly
378  // by using the symbol_scope::anonymous function instead.
379  symbol_scope (const std::string& name)
380  : m_rep (new symbol_scope_rep (name))
381  { }
382 
383  // FIXME: is there a way to make the following constructor private and
384  // not expose the symbol_scope_rep object in the interface (see the
385  // parent_scope, primary_parent_scope, and get_rep functions)?
386 
387  // If NEW_REP is nullptr, the scope is invalid. But if you wish to
388  // create an invalid scope, it is probably better to state that intent
389  // clearly by using the symbol_scope::invalid function instead.
390  symbol_scope (const std::shared_ptr<symbol_scope_rep> new_rep)
391  : m_rep (new_rep)
392  { }
393 
394  symbol_scope (const symbol_scope&) = default;
395 
397 
398  ~symbol_scope () = default;
399 
401  {
402  return symbol_scope (std::shared_ptr<symbol_scope_rep> (nullptr));
403  }
404 
406  {
407  return symbol_scope ("");
408  }
409 
410  bool is_valid () const { return bool (m_rep); }
411 
412  explicit operator bool () const { return is_valid (); }
413 
414  std::size_t num_symbols () const
415  {
416  return m_rep ? m_rep->num_symbols () : 0;
417  }
418 
419  symbol_record insert_local (const std::string& name)
420  {
421  return m_rep ? m_rep->insert_local (name) : symbol_record ();
422  }
423 
425  {
426  if (m_rep)
427  m_rep->insert_symbol_record (sr);
428  }
429 
430  bool is_nested () const
431  {
432  return m_rep ? m_rep->is_nested () : false;
433  }
434 
435  bool is_parent () const
436  {
437  return m_rep ? m_rep->is_parent () : false;
438  }
439 
440  void set_nesting_depth (std::size_t depth)
441  {
442  if (m_rep)
443  m_rep->set_nesting_depth (depth);
444  }
445 
446  std::size_t nesting_depth () const
447  {
448  return m_rep ? m_rep->nesting_depth () : 0;
449  }
450 
451  bool is_static () const
452  {
453  return m_rep ? m_rep->is_static () : false;
454  }
455 
456  void mark_static ()
457  {
458  if (m_rep)
459  m_rep->mark_static ();
460  }
461 
462  std::shared_ptr<symbol_scope_rep> parent_scope () const
463  {
464  return m_rep ? m_rep->parent_scope_rep () : nullptr;
465  }
466 
467  std::shared_ptr<symbol_scope_rep> primary_parent_scope () const
468  {
469  return m_rep ? m_rep->primary_parent_scope_rep () : nullptr;
470  }
471 
472  symbol_scope dup () const
473  {
474  return symbol_scope (m_rep ? m_rep->dup () : nullptr);
475  }
476 
477  octave_value& persistent_varref (std::size_t data_offset)
478  {
479  static octave_value dummy_value;
480 
481  return m_rep ? m_rep->persistent_varref (data_offset) : dummy_value;
482  }
483 
484  octave_value persistent_varval (std::size_t data_offset) const
485  {
486  return m_rep ? m_rep->persistent_varval (data_offset) : octave_value ();
487  }
488 
489  symbol_record find_symbol (const std::string& name)
490  {
491  return m_rep ? m_rep->find_symbol (name) : symbol_record ();
492  }
493 
494  // Like find_symbol, but does not insert.
495  symbol_record lookup_symbol (const std::string& name) const
496  {
497  return m_rep ? m_rep->lookup_symbol (name) : symbol_record ();
498  }
499 
500  symbol_record insert (const std::string& name)
501  {
502  return m_rep ? m_rep->insert (name) : symbol_record ();
503  }
504 
505  void rename (const std::string& old_name, const std::string& new_name)
506  {
507  if (m_rep)
508  m_rep->rename (old_name, new_name);
509  }
510 
511  void install_subfunction (const std::string& name,
512  const octave_value& fval)
513  {
514  if (m_rep)
515  m_rep->install_subfunction (name, fval);
516  }
517 
518  void install_nestfunction (const std::string& name,
519  const octave_value& fval,
520  const symbol_scope& fcn_scope)
521  {
522  if (m_rep)
523  m_rep->install_nestfunction (name, fval, fcn_scope);
524  }
525 
526  octave_value find_subfunction (const std::string& name) const
527  {
528  return m_rep ? m_rep->find_subfunction (name) : octave_value ();
529  }
530 
532  {
533  if (m_rep)
534  m_rep->lock_subfunctions ();
535  }
536 
538  {
539  if (m_rep)
540  m_rep->unlock_subfunctions ();
541  }
542 
543  std::map<std::string, octave_value> subfunctions () const
544  {
545  return (m_rep
546  ? m_rep->subfunctions ()
547  : std::map<std::string, octave_value> ());
548  }
549 
551  {
552  if (m_rep)
553  m_rep->erase_subfunctions ();
554  }
555 
556  void mark_subfunctions_in_scope_as_private (const std::string& class_name)
557  {
558  if (m_rep)
559  m_rep->mark_subfunctions_in_scope_as_private (class_name);
560  }
561 
562  bool has_subfunctions () const
563  {
564  return m_rep ? m_rep->has_subfunctions () : false;
565  }
566 
567  void stash_subfunction_names (const std::list<std::string>& names)
568  {
569  if (m_rep)
570  m_rep->stash_subfunction_names (names);
571  }
572 
573  std::list<std::string> subfunction_names () const
574  {
575  return m_rep ? m_rep->subfunction_names () : std::list<std::string> ();
576  }
577 
578  // List of function handle objects.
579  std::list<octave_value> localfunctions () const;
580 
582  {
583  return m_rep ? m_rep->dump () : octave_value ();
584  }
585 
586  std::string name () const
587  {
588  return m_rep ? m_rep->name () : "";
589  }
590 
591  void cache_name (const std::string& name)
592  {
593  if (m_rep)
594  m_rep->cache_name (name);
595  }
596 
597  std::string fcn_name () const
598  {
599  return m_rep ? m_rep->fcn_name () : "";
600  }
601 
602  void cache_fcn_name (const std::string& name)
603  {
604  if (m_rep)
605  m_rep->cache_fcn_name (name);
606  }
607 
608  std::list<std::string> parent_fcn_names () const
609  {
610  return m_rep ? m_rep->parent_fcn_names () : std::list<std::string> ();
611  }
612 
614  {
615  return m_rep ? m_rep->user_code () : nullptr;
616  }
617 
619  {
620  if (m_rep)
621  m_rep->set_user_code (code);
622  }
623 
624  void set_parent (const symbol_scope& p)
625  {
626  if (m_rep)
627  m_rep->set_parent (p.get_rep ());
628  }
629 
631  {
632  if (m_rep)
633  m_rep->set_primary_parent (p.get_rep ());
634  }
635 
636  void cache_fcn_file_name (const std::string& name)
637  {
638  if (m_rep)
639  m_rep->cache_fcn_file_name (name);
640  }
641 
642  void cache_dir_name (const std::string& name)
643  {
644  if (m_rep)
645  m_rep->cache_dir_name (name);
646  }
647 
648  std::string fcn_file_name () const
649  {
650  return m_rep ? m_rep->fcn_file_name () : "";
651  }
652 
653  std::string dir_name () const
654  {
655  return m_rep ? m_rep->dir_name () : "";
656  }
657 
659  {
660  if (m_rep)
661  m_rep->mark_primary_fcn_scope ();
662  }
663 
664  bool is_primary_fcn_scope () const
665  {
666  return m_rep ? m_rep->is_primary_fcn_scope () : false;
667  }
668 
669  bool is_relative (const symbol_scope& scope) const
670  {
671  return m_rep ? m_rep->is_relative (scope.get_rep ()) : false;
672  }
673 
674  void mark_as_variable (const std::string& nm)
675  {
676  if (m_rep)
677  m_rep->mark_as_variable (nm);
678  }
679 
680  void mark_as_variables (const std::list<std::string>& lst)
681  {
682  if (m_rep)
683  m_rep->mark_as_variables (lst);
684  }
685 
686  bool is_variable (const std::string& nm) const
687  {
688  return m_rep ? m_rep->is_variable (nm) : false;
689  }
690 
691  void update_nest ()
692  {
693  if (m_rep)
694  m_rep->update_nest ();
695  }
696 
697  bool look_nonlocal (const std::string& name, std::size_t offset,
698  symbol_record& result)
699  {
700  return m_rep ? m_rep->look_nonlocal (name, offset, result) : false;
701  }
702 
703  std::shared_ptr<symbol_scope_rep> get_rep () const
704  {
705  return m_rep;
706  }
707 
708  friend bool operator == (const symbol_scope& a, const symbol_scope& b)
709  {
710  return a.m_rep == b.m_rep;
711  }
712 
713  friend bool operator != (const symbol_scope& a, const symbol_scope& b)
714  {
715  return a.m_rep != b.m_rep;
716  }
717 
718  const std::map<std::string, symbol_record>& symbols () const
719  {
720  static const std::map<std::string, symbol_record> empty_map;
721 
722  return m_rep ? m_rep->symbols () : empty_map;
723  }
724 
725  std::map<std::string, symbol_record>& symbols ()
726  {
727  static std::map<std::string, symbol_record> empty_map;
728 
729  return m_rep ? m_rep->symbols () : empty_map;
730  }
731 
732  std::list<symbol_record> symbol_list () const
733  {
734  static const std::list<symbol_record> empty_list;
735 
736  return m_rep ? m_rep->symbol_list () : empty_list;
737  }
738 
739 private:
740 
741  std::shared_ptr<symbol_scope_rep> m_rep;
742 };
743 
744 OCTAVE_END_NAMESPACE(octave)
745 
746 #endif
void rename(const std::string &new_name)
Definition: symrec.h:209
std::size_t nesting_depth() const
Definition: symscope.h:94
symbol_record insert_local(const std::string &name)
Definition: symscope.cc:45
void erase_subfunctions()
Definition: symscope.h:221
void lock_subfunctions()
Definition: symscope.h:203
void mark_subfunctions_in_scope_as_private(const std::string &class_name)
Definition: symscope.cc:193
std::shared_ptr< symbol_scope_rep > parent_scope_rep() const
Definition: symscope.h:104
void mark_primary_fcn_scope()
Definition: symscope.h:276
octave_user_code * user_code() const
Definition: symscope.h:257
void rename(const std::string &old_name, const std::string &new_name)
Definition: symscope.h:170
octave_value dump_symbols_map() const
Definition: symscope.cc:151
std::map< std::string, octave_value >::iterator subfunctions_iterator
Definition: symscope.h:66
std::string fcn_name() const
Definition: symscope.h:251
void cache_fcn_file_name(const std::string &name)
Definition: symscope.h:265
~symbol_scope_rep()=default
void cache_dir_name(const std::string &name)
Definition: symscope.cc:234
bool is_primary_fcn_scope() const
Definition: symscope.h:278
const std::map< std::string, symbol_record > & symbols() const
Definition: symscope.h:294
bool is_relative(const std::shared_ptr< symbol_scope_rep > &scope) const
Definition: symscope.cc:240
std::map< std::string, symbol_record > & symbols()
Definition: symscope.h:299
std::shared_ptr< symbol_scope_rep > dup() const
Definition: symscope.h:114
void unlock_subfunctions()
Definition: symscope.h:209
void set_nesting_depth(std::size_t depth)
Definition: symscope.h:96
bool is_static() const
Definition: symscope.h:100
std::string name() const
Definition: symscope.h:247
std::map< std::string, octave_value > subfunctions() const
Definition: symscope.h:216
void cache_fcn_name(const std::string &name)
Definition: symscope.h:253
void set_primary_parent(const std::shared_ptr< symbol_scope_rep > &parent)
Definition: symscope.cc:228
std::map< std::string, symbol_record >::iterator table_iterator
Definition: symscope.h:61
symbol_record find_symbol(const std::string &name)
Definition: symscope.h:151
std::list< std::string > parent_fcn_names() const
Definition: symscope.cc:205
void mark_as_variables(const std::list< std::string > &lst)
Definition: symscope.cc:288
void install_nestfunction(const std::string &name, const octave_value &fval, const symbol_scope &fcn_scope)
Definition: symscope.h:192
bool is_variable(const std::string &nm) const
Definition: symscope.cc:295
symbol_scope_rep(const std::string &name="", bool add_ans=true)
Definition: symscope.h:68
std::map< std::string, octave_value >::const_iterator subfunctions_const_iterator
Definition: symscope.h:64
std::size_t num_symbols() const
Definition: symscope.h:84
void update_nest()
Definition: symscope.cc:315
void cache_name(const std::string &name)
Definition: symscope.h:249
void stash_subfunction_names(const std::list< std::string > &names)
Definition: symscope.h:233
symbol_record insert(const std::string &name)
Definition: symscope.cc:66
std::shared_ptr< symbol_scope_rep > primary_parent_scope_rep() const
Definition: symscope.h:109
octave_value find_subfunction(const std::string &name) const
Definition: symscope.cc:177
octave_value & persistent_varref(std::size_t data_offset)
Definition: symscope.h:139
void set_user_code(octave_user_code *code)
Definition: symscope.h:259
octave_value dump() const
Definition: symscope.cc:136
bool is_nested() const
Definition: symscope.h:92
void set_parent(const std::shared_ptr< symbol_scope_rep > &parent)
Definition: symscope.cc:222
void mark_as_variable(const std::string &nm)
Definition: symscope.cc:279
bool has_subfunctions() const
Definition: symscope.h:228
bool is_parent() const
Definition: symscope.h:98
std::list< std::string > subfunction_names() const
Definition: symscope.h:238
symbol_record lookup_symbol(const std::string &name) const
Definition: symscope.h:161
std::list< symbol_record > symbol_list() const
Definition: symscope.cc:166
std::map< std::string, symbol_record >::const_iterator table_const_iterator
Definition: symscope.h:59
void mark_static()
Definition: symscope.h:102
octave_value persistent_varval(std::size_t data_offset) const
Definition: symscope.h:144
void insert_symbol_record(symbol_record &sr)
Definition: symscope.cc:55
std::string fcn_file_name() const
Definition: symscope.h:270
std::list< octave_value > localfunctions() const
Definition: symscope.cc:98
bool look_nonlocal(const std::string &name, std::size_t offset, symbol_record &result)
Definition: symscope.cc:347
std::string dir_name() const
Definition: symscope.h:274
void install_subfunction(const std::string &name, const octave_value &fval)
Definition: symscope.h:186
octave_user_code * user_code() const
Definition: symscope.h:613
bool is_primary_fcn_scope() const
Definition: symscope.h:664
std::map< std::string, symbol_record > & symbols()
Definition: symscope.h:725
friend bool operator==(const symbol_scope &a, const symbol_scope &b)
Definition: symscope.h:708
friend bool operator!=(const symbol_scope &a, const symbol_scope &b)
Definition: symscope.h:713
symbol_record insert_local(const std::string &name)
Definition: symscope.h:419
std::string name() const
Definition: symscope.h:586
void lock_subfunctions()
Definition: symscope.h:531
bool is_parent() const
Definition: symscope.h:435
bool is_valid() const
Definition: symscope.h:410
std::shared_ptr< symbol_scope_rep > primary_parent_scope() const
Definition: symscope.h:467
std::string fcn_file_name() const
Definition: symscope.h:648
void set_user_code(octave_user_code *code)
Definition: symscope.h:618
bool is_static() const
Definition: symscope.h:451
void insert_symbol_record(symbol_record &sr)
Definition: symscope.h:424
void stash_subfunction_names(const std::list< std::string > &names)
Definition: symscope.h:567
symbol_scope(const std::shared_ptr< symbol_scope_rep > new_rep)
Definition: symscope.h:390
std::list< octave_value > localfunctions() const
Definition: symscope.cc:383
void cache_fcn_name(const std::string &name)
Definition: symscope.h:602
void mark_as_variable(const std::string &nm)
Definition: symscope.h:674
bool is_nested() const
Definition: symscope.h:430
symbol_scope(const std::string &name)
Definition: symscope.h:379
octave_value find_subfunction(const std::string &name) const
Definition: symscope.h:526
bool is_variable(const std::string &nm) const
Definition: symscope.h:686
static symbol_scope anonymous()
Definition: symscope.h:405
std::map< std::string, octave_value > subfunctions() const
Definition: symscope.h:543
symbol_record find_symbol(const std::string &name)
Definition: symscope.h:489
std::size_t num_symbols() const
Definition: symscope.h:414
void update_nest()
Definition: symscope.h:691
void mark_primary_fcn_scope()
Definition: symscope.h:658
std::list< symbol_record > symbol_list() const
Definition: symscope.h:732
symbol_scope()=delete
static symbol_scope invalid()
Definition: symscope.h:400
std::string dir_name() const
Definition: symscope.h:653
symbol_scope(const symbol_scope &)=default
std::shared_ptr< symbol_scope_rep > parent_scope() const
Definition: symscope.h:462
void set_parent(const symbol_scope &p)
Definition: symscope.h:624
std::shared_ptr< symbol_scope_rep > get_rep() const
Definition: symscope.h:703
void mark_as_variables(const std::list< std::string > &lst)
Definition: symscope.h:680
void install_subfunction(const std::string &name, const octave_value &fval)
Definition: symscope.h:511
bool has_subfunctions() const
Definition: symscope.h:562
octave_value dump() const
Definition: symscope.h:581
symbol_scope & operator=(const symbol_scope &)=default
octave_value persistent_varval(std::size_t data_offset) const
Definition: symscope.h:484
void mark_static()
Definition: symscope.h:456
symbol_record insert(const std::string &name)
Definition: symscope.h:500
void cache_fcn_file_name(const std::string &name)
Definition: symscope.h:636
void unlock_subfunctions()
Definition: symscope.h:537
std::list< std::string > parent_fcn_names() const
Definition: symscope.h:608
void erase_subfunctions()
Definition: symscope.h:550
octave_value & persistent_varref(std::size_t data_offset)
Definition: symscope.h:477
const std::map< std::string, symbol_record > & symbols() const
Definition: symscope.h:718
void set_nesting_depth(std::size_t depth)
Definition: symscope.h:440
void rename(const std::string &old_name, const std::string &new_name)
Definition: symscope.h:505
void set_primary_parent(const symbol_scope &p)
Definition: symscope.h:630
bool is_relative(const symbol_scope &scope) const
Definition: symscope.h:669
std::list< std::string > subfunction_names() const
Definition: symscope.h:573
symbol_record lookup_symbol(const std::string &name) const
Definition: symscope.h:495
void mark_subfunctions_in_scope_as_private(const std::string &class_name)
Definition: symscope.h:556
symbol_scope dup() const
Definition: symscope.h:472
void cache_name(const std::string &name)
Definition: symscope.h:591
void install_nestfunction(const std::string &name, const octave_value &fval, const symbol_scope &fcn_scope)
Definition: symscope.h:518
~symbol_scope()=default
void cache_dir_name(const std::string &name)
Definition: symscope.h:642
std::string fcn_name() const
Definition: symscope.h:597
bool look_nonlocal(const std::string &name, std::size_t offset, symbol_record &result)
Definition: symscope.h:697
std::size_t nesting_depth() const
Definition: symscope.h:446
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))