GNU Octave  6.2.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-2021 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 
49 namespace octave
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 = "")
70  m_code (nullptr), m_fcn_name (), m_parent_fcn_names (),
72  m_children (), m_nesting_depth (0), m_is_static (false),
74  {
75  // All scopes have ans as the first symbol, initially undefined.
76 
77  insert_local ("ans");
78  }
79 
80  // No copying!
81 
82  symbol_scope_rep (const symbol_scope&) = delete;
83 
85 
86  ~symbol_scope_rep (void) = default;
87 
88  size_t num_symbols (void) const { return m_symbols.size (); }
89 
90  // Simply inserts symbol. No non-local searching.
91 
92  symbol_record insert_local (const std::string& name);
93 
95 
96  bool is_nested (void) const { return m_nesting_depth > 0; }
97 
98  size_t nesting_depth (void) const { return m_nesting_depth; }
99 
100  void set_nesting_depth (size_t depth) { m_nesting_depth = depth; }
101 
102  bool is_parent (void) const { return ! m_children.empty (); }
103 
104  bool is_static (void) const { return m_is_static; }
105 
106  void mark_static (void) { m_is_static = true; }
107 
108  std::shared_ptr<symbol_scope_rep> parent_scope_rep (void) const
109  {
110  return m_parent.lock ();
111  }
112 
113  std::shared_ptr<symbol_scope_rep> primary_parent_scope_rep (void) const
114  {
115  return m_primary_parent.lock ();
116  }
117 
118  std::shared_ptr<symbol_scope_rep> dup (void) const
119  {
120  std::shared_ptr<symbol_scope_rep> new_sid
121  = std::shared_ptr<symbol_scope_rep> (new symbol_scope_rep (m_name));
122 
123  for (const auto& nm_sr : m_symbols)
124  new_sid->m_symbols[nm_sr.first] = nm_sr.second.dup ();
125 
126  new_sid->m_subfunctions = m_subfunctions;
127  new_sid->m_persistent_values = m_persistent_values;
128  new_sid->m_subfunction_names = m_subfunction_names;
129  new_sid->m_code = m_code;
130  new_sid->m_fcn_name = m_fcn_name;
131  new_sid->m_parent_fcn_names = m_parent_fcn_names;
132  new_sid->m_fcn_file_name = m_fcn_file_name;
133  new_sid->m_dir_name = m_dir_name;
134  new_sid->m_parent = m_parent;
135  new_sid->m_primary_parent = m_primary_parent;
136  new_sid->m_children = m_children;
137  new_sid->m_nesting_depth = m_nesting_depth;
138  new_sid->m_is_static = m_is_static;
139  new_sid->m_is_primary_fcn_scope = m_is_primary_fcn_scope;
140 
141  return new_sid;
142  }
143 
144  octave_value& persistent_varref (size_t data_offset)
145  {
146  return m_persistent_values[data_offset];
147  }
148 
149  octave_value persistent_varval (size_t data_offset) const
150  {
151  auto p = m_persistent_values.find (data_offset);
152 
153  return p == m_persistent_values.end () ? octave_value () : p->second;
154  }
155 
156  symbol_record find_symbol (const std::string& name)
157  {
158  auto p = m_symbols.find (name);
159 
160  if (p == m_symbols.end ())
161  return insert (name);
162  else
163  return p->second;
164  }
165 
166  symbol_record lookup_symbol (const std::string& name) const
167  {
168  auto p = m_symbols.find (name);
169 
170  return p == m_symbols.end () ? symbol_record () : p->second;
171  }
172 
173  symbol_record insert (const std::string& name);
174 
175  void rename (const std::string& old_name, const std::string& new_name)
176  {
177  auto p = m_symbols.find (old_name);
178 
179  if (p != m_symbols.end ())
180  {
181  symbol_record sr = p->second;
182 
183  sr.rename (new_name);
184 
185  m_symbols.erase (p);
186 
187  m_symbols[new_name] = sr;
188  }
189  }
190 
191  void install_subfunction (const std::string& name,
192  const octave_value& fval)
193  {
194  m_subfunctions[name] = fval;
195  }
196 
197  void install_nestfunction (const std::string& name,
198  const octave_value& fval,
199  const symbol_scope& fcn_scope)
200  {
201  m_subfunctions[name] = fval;
202 
203  m_children.push_back (fcn_scope);
204  }
205 
206  octave_value find_subfunction (const std::string& name) const;
207 
208  void lock_subfunctions (void)
209  {
210  for (auto& nm_sf : m_subfunctions)
211  nm_sf.second.lock ();
212  }
213 
215  {
216  for (auto& nm_sf : m_subfunctions)
217  nm_sf.second.unlock ();
218  }
219 
220  // Pairs of name, function objects.
221  std::map<std::string, octave_value> subfunctions (void) const
222  {
223  return m_subfunctions;
224  }
225 
226  void erase_subfunctions (void)
227  {
228  m_subfunctions.clear ();
229  }
230 
231  void mark_subfunctions_in_scope_as_private (const std::string& class_name);
232 
233  bool has_subfunctions (void) const
234  {
235  return ! m_subfunction_names.empty ();
236  }
237 
238  void stash_subfunction_names (const std::list<std::string>& names)
239  {
240  m_subfunction_names = names;
241  }
242 
243  std::list<std::string> subfunction_names (void) const
244  {
245  return m_subfunction_names;
246  }
247 
248  std::list<octave_value> localfunctions (void) const;
249 
250  octave_value dump (void) const;
251 
252  std::string name (void) const { return m_name; }
253 
254  void cache_name (const std::string& name) { m_name = name; }
255 
256  std::string fcn_name (void) const { return m_fcn_name; }
257 
258  void cache_fcn_name (const std::string& name) { m_fcn_name = name; }
259 
260  std::list<std::string> parent_fcn_names (void) const
261  {
262  return m_parent_fcn_names;
263  }
264 
265  void cache_parent_fcn_names (const std::list<std::string>& names)
266  {
267  m_parent_fcn_names = names;
268  }
269 
270  octave_user_code *user_code (void) const { return m_code; }
271 
272  void set_user_code (octave_user_code *code) { m_code = code; }
273 
274  void set_parent (const std::shared_ptr<symbol_scope_rep>& parent);
275 
276  void set_primary_parent (const std::shared_ptr<symbol_scope_rep>& parent);
277 
278  void cache_fcn_file_name (const std::string& name)
279  {
281  }
282 
283  std::string fcn_file_name (void) const { return m_fcn_file_name; }
284 
285  void cache_dir_name (const std::string& name);
286 
287  std::string dir_name (void) const { return m_dir_name; }
288 
290 
291  bool is_primary_fcn_scope (void) const { return m_is_primary_fcn_scope; }
292 
293  bool is_relative (const std::shared_ptr<symbol_scope_rep>& scope) const;
294 
295  void update_nest (void);
296 
297  bool look_nonlocal (const std::string& name, size_t offset,
298  symbol_record& result);
299 
300  octave_value dump_symbols_map (void) const;
301 
302  const std::map<std::string, symbol_record>& symbols (void) const
303  {
304  return m_symbols;
305  }
306 
307  std::map<std::string, symbol_record>& symbols (void)
308  {
309  return m_symbols;
310  }
311 
312  std::list<symbol_record> symbol_list (void) const;
313 
314  private:
315 
316  //! Name for this scope (usually the corresponding filename of the
317  //! function corresponding to the scope).
318 
319  std::string m_name;
320 
321  //! Map from symbol names to symbol info.
322 
323  std::map<std::string, symbol_record> m_symbols;
324 
325  //! Map from symbol names to subfunctions.
326 
327  std::map<std::string, octave_value> m_subfunctions;
328 
329  //! Map from data offset to persistent values in this scope.
330  std::map<size_t, octave_value> m_persistent_values;
331 
332  //! The list of subfunctions (if any) in the order they appear in
333  //! the function file.
334 
335  std::list<std::string> m_subfunction_names;
336 
337  //! The associated user code (may be null).
338 
340 
341  //! Simple name of the function corresponding to this scope.
342 
343  std::string m_fcn_name;
344 
345  //! List Simple names of the parent functions corresponding to this scope.
346 
347  std::list<std::string> m_parent_fcn_names;
348 
349  //! The file name associated with m_code.
350 
351  std::string m_fcn_file_name;
352 
353  //! The directory associated with m_code.
354 
355  std::string m_dir_name;
356 
357  //! Parent of nested function (may be null).
358 
359  std::weak_ptr<symbol_scope_rep> m_parent;
360 
361  //! Primary (top) parent of nested function (may be null). Used
362  //! to determine whether two nested functions are related.
363 
364  std::weak_ptr<symbol_scope_rep> m_primary_parent;
365 
366  //! Child nested functions.
367 
368  std::vector<symbol_scope> m_children;
369 
370  //! If true, then this scope belongs to a nested function.
371 
373 
374  //! If true then no variables can be added.
375 
377 
378  //! If true, this is the scope of a primary function.
380  };
381 
383  {
384  public:
385 
386  // Create a valid but possibly unnamed scope.
387  symbol_scope (const std::string& name)
388  : m_rep (new symbol_scope_rep (name))
389  { }
390 
391  // NEW_REP must be dynamically allocated or nullptr. If it is
392  // nullptr, the scope is invalid.
393  symbol_scope (const std::shared_ptr<symbol_scope_rep> new_rep = nullptr)
394  : m_rep (new_rep)
395  { }
396 
397  symbol_scope (const symbol_scope&) = default;
398 
400 
401  ~symbol_scope (void) = default;
402 
403  bool is_valid (void) const { return bool (m_rep); }
404 
405  explicit operator bool () const { return bool (m_rep); }
406 
407  size_t num_symbols (void) const
408  {
409  return m_rep ? m_rep->num_symbols () : 0;
410  }
411 
412  symbol_record insert_local (const std::string& name)
413  {
414  return m_rep ? m_rep->insert_local (name) : symbol_record ();
415  }
416 
418  {
419  if (m_rep)
420  m_rep->insert_symbol_record (sr);
421  }
422 
423  bool is_nested (void) const
424  {
425  return m_rep ? m_rep->is_nested () : false;
426  }
427 
428  bool is_parent (void) const
429  {
430  return m_rep ? m_rep->is_parent () : false;
431  }
432 
433  void set_nesting_depth (size_t depth)
434  {
435  if (m_rep)
436  m_rep->set_nesting_depth (depth);
437  }
438 
439  size_t nesting_depth (void) const
440  {
441  return m_rep ? m_rep->nesting_depth () : 0;
442  }
443 
444  bool is_static (void) const
445  {
446  return m_rep ? m_rep->is_static () : false;
447  }
448 
449  void mark_static (void)
450  {
451  if (m_rep)
452  m_rep->mark_static ();
453  }
454 
455  std::shared_ptr<symbol_scope_rep> parent_scope (void) const
456  {
457  return m_rep ? m_rep->parent_scope_rep () : nullptr;
458  }
459 
460  std::shared_ptr<symbol_scope_rep> primary_parent_scope (void) const
461  {
462  return m_rep ? m_rep->primary_parent_scope_rep () : nullptr;
463  }
464 
465  symbol_scope dup (void) const
466  {
467  return symbol_scope (m_rep ? m_rep->dup () : nullptr);
468  }
469 
470  octave_value& persistent_varref (size_t data_offset)
471  {
472  static octave_value dummy_value;
473 
474  return m_rep ? m_rep->persistent_varref (data_offset) : dummy_value;
475  }
476 
477  octave_value persistent_varval (size_t data_offset) const
478  {
479  return m_rep ? m_rep->persistent_varval (data_offset) : octave_value ();
480  }
481 
482  symbol_record find_symbol (const std::string& name)
483  {
484  return m_rep ? m_rep->find_symbol (name) : symbol_record ();
485  }
486 
487  // Like find_symbol, but does not insert.
488  symbol_record lookup_symbol (const std::string& name) const
489  {
490  return m_rep ? m_rep->lookup_symbol (name) : symbol_record ();
491  }
492 
493  symbol_record insert (const std::string& name)
494  {
495  return m_rep ? m_rep->insert (name) : symbol_record ();
496  }
497 
498  void rename (const std::string& old_name, const std::string& new_name)
499  {
500  if (m_rep)
501  m_rep->rename (old_name, new_name);
502  }
503 
504  void install_subfunction (const std::string& name,
505  const octave_value& fval)
506  {
507  if (m_rep)
508  m_rep->install_subfunction (name, fval);
509  }
510 
511  void install_nestfunction (const std::string& name,
512  const octave_value& fval,
513  const symbol_scope& fcn_scope)
514  {
515  if (m_rep)
516  m_rep->install_nestfunction (name, fval, fcn_scope);
517  }
518 
519  octave_value find_subfunction (const std::string& name) const
520  {
521  return m_rep ? m_rep->find_subfunction (name) : octave_value ();
522  }
523 
524  void lock_subfunctions (void)
525  {
526  if (m_rep)
527  m_rep->lock_subfunctions ();
528  }
529 
531  {
532  if (m_rep)
533  m_rep->unlock_subfunctions ();
534  }
535 
536  std::map<std::string, octave_value> subfunctions (void) const
537  {
538  return (m_rep
539  ? m_rep->subfunctions ()
540  : std::map<std::string, octave_value> ());
541  }
542 
543  void erase_subfunctions (void)
544  {
545  if (m_rep)
546  m_rep->erase_subfunctions ();
547  }
548 
549  void mark_subfunctions_in_scope_as_private (const std::string& class_name)
550  {
551  if (m_rep)
552  m_rep->mark_subfunctions_in_scope_as_private (class_name);
553  }
554 
555  bool has_subfunctions (void) const
556  {
557  return m_rep ? m_rep->has_subfunctions () : false;
558  }
559 
560  void stash_subfunction_names (const std::list<std::string>& names)
561  {
562  if (m_rep)
563  m_rep->stash_subfunction_names (names);
564  }
565 
566  std::list<std::string> subfunction_names (void) const
567  {
568  return m_rep ? m_rep->subfunction_names () : std::list<std::string> ();
569  }
570 
571  // List of function handle objects.
572  std::list<octave_value> localfunctions (void) const;
573 
574  octave_value dump (void) const
575  {
576  return m_rep ? m_rep->dump () : octave_value ();
577  }
578 
579  std::string name (void) const
580  {
581  return m_rep ? m_rep->name () : "";
582  }
583 
584  void cache_name (const std::string& name)
585  {
586  if (m_rep)
587  m_rep->cache_name (name);
588  }
589 
590  std::string fcn_name (void) const
591  {
592  return m_rep ? m_rep->fcn_name () : "";
593  }
594 
595  void cache_fcn_name (const std::string& name)
596  {
597  if (m_rep)
598  m_rep->cache_fcn_name (name);
599  }
600 
601  std::list<std::string> parent_fcn_names (void) const
602  {
603  return m_rep ? m_rep->parent_fcn_names () : std::list<std::string> ();
604  }
605 
606  void cache_parent_fcn_names (const std::list<std::string>& names)
607  {
608  if (m_rep)
609  m_rep->cache_parent_fcn_names (names);
610  }
611 
613  {
614  return m_rep ? m_rep->user_code () : nullptr;
615  }
616 
618  {
619  if (m_rep)
620  m_rep->set_user_code (code);
621  }
622 
623  void set_parent (const symbol_scope& p)
624  {
625  if (m_rep)
626  m_rep->set_parent (p.get_rep ());
627  }
628 
630  {
631  if (m_rep)
632  m_rep->set_primary_parent (p.get_rep ());
633  }
634 
635  void cache_fcn_file_name (const std::string& name)
636  {
637  if (m_rep)
638  m_rep->cache_fcn_file_name (name);
639  }
640 
641  void cache_dir_name (const std::string& name)
642  {
643  if (m_rep)
644  m_rep->cache_dir_name (name);
645  }
646 
647  std::string fcn_file_name (void) const
648  {
649  return m_rep ? m_rep->fcn_file_name () : "";
650  }
651 
652  std::string dir_name (void) const
653  {
654  return m_rep ? m_rep->dir_name () : "";
655  }
656 
658  {
659  if (m_rep)
660  m_rep->mark_primary_fcn_scope ();
661  }
662 
663  bool is_primary_fcn_scope (void) const
664  {
665  return m_rep ? m_rep->is_primary_fcn_scope () : false;
666  }
667 
668  bool is_relative (const symbol_scope& scope) const
669  {
670  return m_rep ? m_rep->is_relative (scope.get_rep ()) : false;
671  }
672 
673  void update_nest (void)
674  {
675  if (m_rep)
676  m_rep->update_nest ();
677  }
678 
679  bool look_nonlocal (const std::string& name, size_t offset,
680  symbol_record& result)
681  {
682  return m_rep ? m_rep->look_nonlocal (name, offset, result) : false;
683  }
684 
685  std::shared_ptr<symbol_scope_rep> get_rep (void) const
686  {
687  return m_rep;
688  }
689 
690  friend bool operator == (const symbol_scope& a, const symbol_scope& b)
691  {
692  return a.m_rep == b.m_rep;
693  }
694 
695  friend bool operator != (const symbol_scope& a, const symbol_scope& b)
696  {
697  return a.m_rep != b.m_rep;
698  }
699 
700  const std::map<std::string, symbol_record>& symbols (void) const
701  {
702  static const std::map<std::string, symbol_record> empty_map;
703 
704  return m_rep ? m_rep->symbols () : empty_map;
705  }
706 
707  std::map<std::string, symbol_record>& symbols (void)
708  {
709  static std::map<std::string, symbol_record> empty_map;
710 
711  return m_rep ? m_rep->symbols () : empty_map;
712  }
713 
714  std::list<symbol_record> symbol_list (void) const
715  {
716  static const std::list<symbol_record> empty_list;
717 
718  return m_rep ? m_rep->symbol_list () : empty_list;
719  }
720 
721  private:
722 
723  std::shared_ptr<symbol_scope_rep> m_rep;
724  };
725 }
726 
727 #endif
void rename(const std::string &new_name)
Definition: symrec.h:187
std::weak_ptr< symbol_scope_rep > m_primary_parent
Primary (top) parent of nested function (may be null).
Definition: symscope.h:364
std::string m_name
Name for this scope (usually the corresponding filename of the function corresponding to the scope).
Definition: symscope.h:319
void set_nesting_depth(size_t depth)
Definition: symscope.h:100
void unlock_subfunctions(void)
Definition: symscope.h:214
std::vector< symbol_scope > m_children
Child nested functions.
Definition: symscope.h:368
std::shared_ptr< symbol_scope_rep > parent_scope_rep(void) const
Definition: symscope.h:108
std::string name(void) const
Definition: symscope.h:252
std::map< std::string, symbol_record >::iterator table_iterator
Definition: symscope.h:61
bool has_subfunctions(void) const
Definition: symscope.h:233
std::list< std::string > m_parent_fcn_names
List Simple names of the parent functions corresponding to this scope.
Definition: symscope.h:347
void stash_subfunction_names(const std::list< std::string > &names)
Definition: symscope.h:238
std::string m_dir_name
The directory associated with m_code.
Definition: symscope.h:355
std::shared_ptr< symbol_scope_rep > dup(void) const
Definition: symscope.h:118
void install_nestfunction(const std::string &name, const octave_value &fval, const symbol_scope &fcn_scope)
Definition: symscope.h:197
std::string m_fcn_file_name
The file name associated with m_code.
Definition: symscope.h:351
std::map< std::string, octave_value >::const_iterator subfunctions_const_iterator
Definition: symscope.h:64
void cache_parent_fcn_names(const std::list< std::string > &names)
Definition: symscope.h:265
bool is_primary_fcn_scope(void) const
Definition: symscope.h:291
std::map< std::string, octave_value > m_subfunctions
Map from symbol names to subfunctions.
Definition: symscope.h:327
bool is_relative(const std::shared_ptr< symbol_scope_rep > &scope) const
Definition: symscope.cc:218
void cache_fcn_name(const std::string &name)
Definition: symscope.h:258
octave_value dump(void) const
Definition: symscope.cc:133
size_t m_nesting_depth
If true, then this scope belongs to a nested function.
Definition: symscope.h:372
void set_parent(const std::shared_ptr< symbol_scope_rep > &parent)
Definition: symscope.cc:200
std::map< std::string, symbol_record > m_symbols
Map from symbol names to symbol info.
Definition: symscope.h:323
void erase_subfunctions(void)
Definition: symscope.h:226
symbol_record insert_local(const std::string &name)
Definition: symscope.cc:45
octave_value & persistent_varref(size_t data_offset)
Definition: symscope.h:144
void mark_static(void)
Definition: symscope.h:106
std::map< std::string, symbol_record >::const_iterator table_const_iterator
Definition: symscope.h:59
std::string fcn_file_name(void) const
Definition: symscope.h:283
void mark_subfunctions_in_scope_as_private(const std::string &class_name)
Definition: symscope.cc:188
void mark_primary_fcn_scope(void)
Definition: symscope.h:289
std::string m_fcn_name
Simple name of the function corresponding to this scope.
Definition: symscope.h:343
size_t nesting_depth(void) const
Definition: symscope.h:98
void lock_subfunctions(void)
Definition: symscope.h:208
bool look_nonlocal(const std::string &name, size_t offset, symbol_record &result)
Definition: symscope.cc:293
octave_value dump_symbols_map(void) const
Definition: symscope.cc:147
size_t num_symbols(void) const
Definition: symscope.h:88
std::list< std::string > m_subfunction_names
The list of subfunctions (if any) in the order they appear in the function file.
Definition: symscope.h:335
void rename(const std::string &old_name, const std::string &new_name)
Definition: symscope.h:175
symbol_scope_rep(const symbol_scope &)=delete
symbol_scope_rep(const std::string &name="")
Definition: symscope.h:68
bool is_parent(void) const
Definition: symscope.h:102
~symbol_scope_rep(void)=default
symbol_record insert(const std::string &name)
Definition: symscope.cc:64
octave_value find_subfunction(const std::string &name) const
Definition: symscope.cc:172
std::shared_ptr< symbol_scope_rep > primary_parent_scope_rep(void) const
Definition: symscope.h:113
symbol_scope_rep & operator=(const symbol_scope &)=delete
std::list< octave_value > localfunctions(void) const
Definition: symscope.cc:95
std::list< std::string > subfunction_names(void) const
Definition: symscope.h:243
void cache_fcn_file_name(const std::string &name)
Definition: symscope.h:278
bool m_is_static
If true then no variables can be added.
Definition: symscope.h:376
symbol_record lookup_symbol(const std::string &name) const
Definition: symscope.h:166
bool is_static(void) const
Definition: symscope.h:104
std::weak_ptr< symbol_scope_rep > m_parent
Parent of nested function (may be null).
Definition: symscope.h:359
std::map< size_t, octave_value > m_persistent_values
Map from data offset to persistent values in this scope.
Definition: symscope.h:330
std::string dir_name(void) const
Definition: symscope.h:287
bool is_nested(void) const
Definition: symscope.h:96
octave_user_code * user_code(void) const
Definition: symscope.h:270
std::map< std::string, octave_value > subfunctions(void) const
Definition: symscope.h:221
symbol_record find_symbol(const std::string &name)
Definition: symscope.h:156
bool m_is_primary_fcn_scope
If true, this is the scope of a primary function.
Definition: symscope.h:379
std::map< std::string, octave_value >::iterator subfunctions_iterator
Definition: symscope.h:66
void set_primary_parent(const std::shared_ptr< symbol_scope_rep > &parent)
Definition: symscope.cc:206
const std::map< std::string, symbol_record > & symbols(void) const
Definition: symscope.h:302
void insert_symbol_record(symbol_record &sr)
Definition: symscope.cc:54
std::string fcn_name(void) const
Definition: symscope.h:256
void install_subfunction(const std::string &name, const octave_value &fval)
Definition: symscope.h:191
std::list< std::string > parent_fcn_names(void) const
Definition: symscope.h:260
octave_value persistent_varval(size_t data_offset) const
Definition: symscope.h:149
void cache_name(const std::string &name)
Definition: symscope.h:254
octave_user_code * m_code
The associated user code (may be null).
Definition: symscope.h:339
void cache_dir_name(const std::string &name)
Definition: symscope.cc:212
std::list< symbol_record > symbol_list(void) const
Definition: symscope.cc:161
std::map< std::string, symbol_record > & symbols(void)
Definition: symscope.h:307
void set_user_code(octave_user_code *code)
Definition: symscope.h:272
symbol_scope & operator=(const symbol_scope &)=default
friend bool operator==(const symbol_scope &a, const symbol_scope &b)
Definition: symscope.h:690
std::string name(void) const
Definition: symscope.h:579
friend bool operator!=(const symbol_scope &a, const symbol_scope &b)
Definition: symscope.h:695
void install_subfunction(const std::string &name, const octave_value &fval)
Definition: symscope.h:504
void set_primary_parent(const symbol_scope &p)
Definition: symscope.h:629
void mark_primary_fcn_scope(void)
Definition: symscope.h:657
octave_value & persistent_varref(size_t data_offset)
Definition: symscope.h:470
symbol_scope dup(void) const
Definition: symscope.h:465
std::shared_ptr< symbol_scope_rep > m_rep
Definition: symscope.h:723
size_t nesting_depth(void) const
Definition: symscope.h:439
void install_nestfunction(const std::string &name, const octave_value &fval, const symbol_scope &fcn_scope)
Definition: symscope.h:511
void cache_parent_fcn_names(const std::list< std::string > &names)
Definition: symscope.h:606
std::shared_ptr< symbol_scope_rep > parent_scope(void) const
Definition: symscope.h:455
octave_user_code * user_code(void) const
Definition: symscope.h:612
std::map< std::string, octave_value > subfunctions(void) const
Definition: symscope.h:536
symbol_record lookup_symbol(const std::string &name) const
Definition: symscope.h:488
std::string fcn_file_name(void) const
Definition: symscope.h:647
void set_user_code(octave_user_code *code)
Definition: symscope.h:617
octave_value find_subfunction(const std::string &name) const
Definition: symscope.h:519
symbol_record insert_local(const std::string &name)
Definition: symscope.h:412
std::list< symbol_record > symbol_list(void) const
Definition: symscope.h:714
std::list< std::string > subfunction_names(void) const
Definition: symscope.h:566
void erase_subfunctions(void)
Definition: symscope.h:543
void unlock_subfunctions(void)
Definition: symscope.h:530
~symbol_scope(void)=default
bool is_static(void) const
Definition: symscope.h:444
symbol_record find_symbol(const std::string &name)
Definition: symscope.h:482
symbol_scope(const std::string &name)
Definition: symscope.h:387
void set_parent(const symbol_scope &p)
Definition: symscope.h:623
void mark_subfunctions_in_scope_as_private(const std::string &class_name)
Definition: symscope.h:549
void set_nesting_depth(size_t depth)
Definition: symscope.h:433
bool look_nonlocal(const std::string &name, size_t offset, symbol_record &result)
Definition: symscope.h:679
std::list< std::string > parent_fcn_names(void) const
Definition: symscope.h:601
void update_nest(void)
Definition: symscope.h:673
void cache_dir_name(const std::string &name)
Definition: symscope.h:641
std::string fcn_name(void) const
Definition: symscope.h:590
bool is_valid(void) const
Definition: symscope.h:403
symbol_scope(const std::shared_ptr< symbol_scope_rep > new_rep=nullptr)
Definition: symscope.h:393
symbol_record insert(const std::string &name)
Definition: symscope.h:493
size_t num_symbols(void) const
Definition: symscope.h:407
octave_value persistent_varval(size_t data_offset) const
Definition: symscope.h:477
void stash_subfunction_names(const std::list< std::string > &names)
Definition: symscope.h:560
void lock_subfunctions(void)
Definition: symscope.h:524
std::map< std::string, symbol_record > & symbols(void)
Definition: symscope.h:707
bool is_primary_fcn_scope(void) const
Definition: symscope.h:663
bool is_relative(const symbol_scope &scope) const
Definition: symscope.h:668
void cache_fcn_name(const std::string &name)
Definition: symscope.h:595
std::shared_ptr< symbol_scope_rep > primary_parent_scope(void) const
Definition: symscope.h:460
const std::map< std::string, symbol_record > & symbols(void) const
Definition: symscope.h:700
bool is_nested(void) const
Definition: symscope.h:423
void rename(const std::string &old_name, const std::string &new_name)
Definition: symscope.h:498
void mark_static(void)
Definition: symscope.h:449
std::list< octave_value > localfunctions(void) const
Definition: symscope.cc:327
void insert_symbol_record(symbol_record &sr)
Definition: symscope.h:417
void cache_fcn_file_name(const std::string &name)
Definition: symscope.h:635
void cache_name(const std::string &name)
Definition: symscope.h:584
symbol_scope(const symbol_scope &)=default
std::shared_ptr< symbol_scope_rep > get_rep(void) const
Definition: symscope.h:685
bool is_parent(void) const
Definition: symscope.h:428
std::string dir_name(void) const
Definition: symscope.h:652
bool has_subfunctions(void) const
Definition: symscope.h:555
octave_value dump(void) const
Definition: symscope.h:574
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))