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