Mercurial > octave
annotate libinterp/corefcn/stack-frame.cc @ 27932:b018f553fd85
maint: Use Octave coding conventions in libinterp/
* __ftp__.cc, __ichol__.cc, call-stack.cc, error.h, event-manager.cc,
file-io.cc, gl-render.cc, graphics.cc, help.cc, input.cc, interpreter.cc,
load-path.cc, load-save.cc, ls-hdf5.cc, ls-hdf5.h, mex.cc, oct-hist.cc,
oct-stream.cc, sighandlers.h, stack-frame.cc, stack-frame.h, strfns.cc,
syminfo.cc, sysdep.cc, text-engine.h, url-handle-manager.h, urlwrite.cc,
xpow.cc, __init_fltk__.cc, __ode15__.cc, ccolamd.cc, colamd.cc, cdef-class.cc,
cdef-manager.cc, cdef-manager.h, cdef-method.cc, cdef-object.cc,
cdef-package.h, cdef-property.cc, ov-class.cc, ov-classdef.cc, ov-cx-sparse.cc,
ov-fcn-handle.cc, ov-fcn-inline.cc, ov-fcn.h, ov-java.cc, ov-typeinfo.h,
bp-table.cc, jit-ir.h, jit-typeinfo.h, pt-classdef.h, pt-eval.cc, pt-eval.h,
pt-idx.cc: Use Octave coding conventions in libinterp.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 10 Jan 2020 17:25:12 -0800 |
parents | bd51beb6205e |
children | 8db2d4c9a64f |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
3 // Copyright (C) 1995-2020 The Octave Project Developers |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 # include "config.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 #endif |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 #include "lo-regexp.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 #include "str-vec.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 #include "defun.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 #include "interpreter.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 #include "interpreter-private.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
36 #include "oct-map.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 #include "ov.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 #include "ov-fcn.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 #include "ov-fcn-handle.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
40 #include "ov-usr-fcn.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
41 #include "pager.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
42 #include "parse.h" |
27211
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27149
diff
changeset
|
43 #include "pt-eval.h" |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
44 #include "stack-frame.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
45 #include "stack-frame-walker.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
46 #include "syminfo.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
47 #include "syminfo-accumulator.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
48 #include "symrec.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
49 #include "symscope.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
50 #include "variables.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
51 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
52 namespace octave |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
53 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
54 // FIXME: There should probably be a display method for the script, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
55 // fcn, and scope objects and the script and function objects should |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
56 // be responsible for displaying the scopes they contain. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
57 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
58 static void display_scope (std::ostream& os, const symbol_scope& scope) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
59 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
60 if (scope) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
61 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
62 os << "scope: " << scope.name () << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
63 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
64 if (scope.num_symbols () > 0) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
65 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
66 os << "name (frame offset, data offset, storage class):" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
67 << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
68 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
69 std::list<symbol_record> symbols = scope.symbol_list (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
70 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
71 for (auto& sym : symbols) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
72 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
73 os << " " << sym.name () << " (" << sym.frame_offset () |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
74 << ", " << sym.data_offset () << ", " << sym.storage_class () |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
75 << ")" << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
76 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
77 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
78 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
79 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
80 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
81 class symbol_cleaner : public stack_frame_walker |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
82 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
83 public: |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
84 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
85 symbol_cleaner (const std::string& pattern, bool have_regexp = false) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
86 : stack_frame_walker (), m_patterns (pattern), |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
87 m_clear_all_names (false), m_clear_objects (false), |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
88 m_have_regexp (have_regexp), m_cleared_names () |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
89 { } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
90 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
91 symbol_cleaner (const string_vector& patterns, bool have_regexp = false) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
92 : stack_frame_walker (), m_patterns (patterns), |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
93 m_clear_all_names (false), m_clear_objects (false), |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
94 m_have_regexp (have_regexp), m_cleared_names () |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
95 { } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
96 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
97 symbol_cleaner (bool clear_all_names = true, bool clear_objects = false) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
98 : stack_frame_walker (), m_patterns (), |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
99 m_clear_all_names (clear_all_names), m_clear_objects (clear_objects), |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
100 m_have_regexp (false), m_cleared_names () |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
101 { } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
102 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
103 symbol_cleaner (const symbol_cleaner&) = delete; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
104 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
105 symbol_cleaner& operator = (const symbol_cleaner&) = delete; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
106 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
107 ~symbol_cleaner (void) = default; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
108 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
109 void visit_compiled_fcn_stack_frame (compiled_fcn_stack_frame& frame) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
110 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
111 // This one follows static link always. Hmm, should the access |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
112 // link for a compiled_fcn_stack_frame be the same as the static |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
113 // link? |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
114 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
115 stack_frame *slink = frame.static_link (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
116 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
117 if (slink) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
118 slink->accept (*this); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
119 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
120 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
121 void visit_script_stack_frame (script_stack_frame& frame) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
122 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
123 stack_frame *alink = frame.access_link (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
124 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
125 if (alink) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
126 alink->accept (*this); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
127 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
128 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
129 void visit_user_fcn_stack_frame (user_fcn_stack_frame& frame) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
130 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
131 clean_frame (frame); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
132 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
133 stack_frame *alink = frame.access_link (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
134 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
135 if (alink) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
136 alink->accept (*this); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
137 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
138 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
139 void visit_scope_stack_frame (scope_stack_frame& frame) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
140 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
141 clean_frame (frame); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
142 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
143 stack_frame *alink = frame.access_link (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
144 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
145 if (alink) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
146 alink->accept (*this); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
147 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
148 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
149 private: |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
150 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
151 void maybe_clear_symbol (stack_frame& frame, const symbol_record& sym) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
152 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
153 std::string name = sym.name (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
154 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
155 if (m_cleared_names.find (name) == m_cleared_names.end ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
156 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
157 // FIXME: Should we check that the name is defined and skip if |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
158 // it is not? Is it possible for another symbol with the same |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
159 // name to appear in a later stack frame? |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
160 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
161 // FIXME: If we are clearing objects and a symbol is found, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
162 // should we add it to the list of cleared names (since |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
163 // we did find a symbol) but skip clearing the object? |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
164 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
165 if (m_clear_objects && ! frame.is_object (sym)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
166 return; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
167 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
168 m_cleared_names.insert (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
169 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
170 frame.clear (sym); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
171 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
172 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
173 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
174 // FIXME: It would be nice to avoid the duplication in the following |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
175 // function. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
176 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
177 void clear_symbols (stack_frame& frame, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
178 const std::list<symbol_record>& symbols) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
179 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
180 if (m_clear_all_names) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
181 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
182 for (const auto& sym : symbols) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
183 maybe_clear_symbol (frame, sym); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
184 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
185 else if (m_have_regexp) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
186 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
187 octave_idx_type npatterns = m_patterns.numel (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
188 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
189 for (octave_idx_type j = 0; j < npatterns; j++) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
190 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
191 std::string pattern = m_patterns[j]; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
192 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
193 regexp pat (pattern); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
194 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
195 for (const auto& sym : symbols) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
196 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
197 if (pat.is_match (sym.name ())) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
198 maybe_clear_symbol (frame, sym); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
199 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
200 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
201 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
202 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
203 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
204 octave_idx_type npatterns = m_patterns.numel (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
205 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
206 for (octave_idx_type j = 0; j < npatterns; j++) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
207 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
208 std::string pattern = m_patterns[j]; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
209 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
210 glob_match pat (pattern); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
211 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
212 for (const auto& sym : symbols) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
213 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
214 if (pat.match (sym.name ())) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
215 maybe_clear_symbol (frame, sym); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
216 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
217 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
218 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
219 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
220 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
221 void clean_frame (stack_frame& frame) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
222 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
223 symbol_scope scope = frame.get_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
224 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
225 std::list<symbol_record> symbols = scope.symbol_list (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
226 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
227 if (m_clear_all_names || ! m_patterns.empty ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
228 clear_symbols (frame, symbols); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
229 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
230 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
231 string_vector m_patterns; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
232 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
233 bool m_clear_all_names; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
234 bool m_clear_objects; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
235 bool m_have_regexp; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
236 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
237 std::set<std::string> m_cleared_names; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
238 }; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
239 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
240 // This function is only implemented for user_fcn stack frames and |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
241 // only called for those objects using unwind_protect and the |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
242 // call_stack::clear_current_frame_values function. Anything else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
243 // indicates an error in the implementation. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
244 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
245 void stack_frame::clear_values (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
246 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
247 panic_impossible (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
248 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
249 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
250 // Return first occurrence of variables in current stack frame and any |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
251 // parent frames reachable through access links. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
252 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
253 symbol_info_list stack_frame::all_variables (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
254 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
255 symbol_info_accumulator sia (true, true); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
256 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
257 accept (sia); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
258 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
259 return sia.symbol_info (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
260 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
261 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
262 std::list<symbol_record> |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
263 stack_frame::glob (const std::string& pattern) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
264 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
265 std::list<symbol_record> retval; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
266 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
267 symbol_scope scope = get_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
268 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
269 const std::map<std::string, symbol_record>& symbols = scope.symbols (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
270 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
271 glob_match pat (pattern); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
272 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
273 for (const auto& nm_sr : symbols) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
274 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
275 if (pat.match (nm_sr.first)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
276 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
277 symbol_record sr = nm_sr.second; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
278 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
279 if (! is_variable (sr)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
280 continue; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
281 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
282 retval.push_back (sr); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
283 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
284 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
285 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
286 return retval; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
287 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
288 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
289 std::list<symbol_record> |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
290 stack_frame::regexp (const std::string& pattern) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
291 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
292 std::list<symbol_record> retval; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
293 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
294 symbol_scope scope = get_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
295 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
296 const std::map<std::string, symbol_record>& symbols = scope.symbols (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
297 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
298 octave::regexp pat (pattern); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
299 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
300 for (const auto& nm_sr : symbols) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
301 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
302 if (pat.is_match (nm_sr.first)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
303 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
304 symbol_record sr = nm_sr.second; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
305 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
306 if (! is_variable (sr)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
307 continue; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
308 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
309 retval.push_back (sr); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
310 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
311 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
312 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
313 return retval; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
314 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
315 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
316 std::list<std::string> stack_frame::variable_names (void) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
317 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
318 std::list<std::string> retval; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
319 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
320 symbol_scope scope = get_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
321 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
322 const std::map<std::string, symbol_record>& symbols = scope.symbols (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
323 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
324 for (const auto& nm_sr : symbols) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
325 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
326 if (is_variable (nm_sr.second)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
327 retval.push_back (nm_sr.first); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
328 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
329 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
330 retval.sort (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
331 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
332 return retval; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
333 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
334 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
335 size_t stack_frame::size (void) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
336 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
337 // This function should only be called for user_fcn_stack_frame or |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
338 // scope_stack_frame objects. Anything else indicates an error in |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
339 // the implementation. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
340 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
341 panic_impossible (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
342 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
343 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
344 void stack_frame::resize (size_t) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
345 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
346 // This function should only be called for user_fcn_stack_frame or |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
347 // scope_stack_frame objects. Anything else indicates an error in |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
348 // the implementation. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
349 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
350 panic_impossible (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
351 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
352 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
353 stack_frame::scope_flags stack_frame::get_scope_flag (size_t) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
354 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
355 // This function should only be called for user_fcn_stack_frame or |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
356 // scope_stack_frame objects. Anything else indicates an error in |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
357 // the implementation. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
358 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
359 panic_impossible (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
360 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
361 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
362 void stack_frame::set_scope_flag (size_t, scope_flags) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
363 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
364 // This function should only be called for user_fcn_stack_frame or |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
365 // scope_stack_frame objects. Anything else indicates an error in |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
366 // the implementation. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
367 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
368 panic_impossible (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
369 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
370 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
371 void stack_frame::install_variable (const symbol_record& sym, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
372 const octave_value& value, bool global) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
373 { |
26673
4271b53b24a6
when installing global variable don't warn if it is already global
John W. Eaton <jwe@octave.org>
parents:
26663
diff
changeset
|
374 if (global && ! is_global (sym)) |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
375 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
376 octave_value val = varval (sym); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
377 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
378 if (val.is_defined ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
379 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
380 std::string nm = sym.name (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
381 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
382 warning_with_id ("Octave:global-local-conflict", |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
383 "global: '%s' is defined in the current scope.\n", |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
384 nm.c_str ()); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
385 warning_with_id ("Octave:global-local-conflict", |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
386 "global: in a future version, global variables must be declared before use.\n"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
387 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
388 // If the symbol is defined in the local but not the |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
389 // global scope, then use the local value as the |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
390 // initial value. This value will also override any |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
391 // initializer in the global statement. |
27211
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27149
diff
changeset
|
392 octave_value global_val = m_evaluator.global_varval (nm); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
393 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
394 if (global_val.is_defined ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
395 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
396 warning_with_id ("Octave:global-local-conflict", |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
397 "global: global value overrides existing local value"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
398 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
399 clear (sym); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
400 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
401 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
402 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
403 warning_with_id ("Octave:global-local-conflict", |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
404 "global: existing local value used to initialize global variable"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
405 |
27211
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27149
diff
changeset
|
406 m_evaluator.global_varref (nm) = val; |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
407 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
408 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
409 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
410 mark_global (sym); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
411 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
412 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
413 if (value.is_defined ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
414 assign (sym, value); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
415 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
416 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
417 octave_value stack_frame::varval (size_t) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
418 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
419 // This function should only be called for user_fcn_stack_frame or |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
420 // scope_stack_frame objects. Anything else indicates an error in |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
421 // the implementation. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
422 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
423 panic_impossible (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
424 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
425 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
426 octave_value& stack_frame::varref (size_t) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
427 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
428 // This function should only be called for user_fcn_stack_frame or |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
429 // scope_stack_frame objects. Anything else indicates an error in |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
430 // the implementation. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
431 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
432 panic_impossible (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
433 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
434 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
435 void stack_frame::clear_objects (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
436 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
437 symbol_cleaner sc (true, true); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
438 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
439 accept (sc); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
440 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
441 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
442 void stack_frame::clear_variable (const std::string& name) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
443 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
444 symbol_cleaner sc (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
445 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
446 accept (sc); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
447 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
448 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
449 void stack_frame::clear_variable_pattern (const std::string& pattern) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
450 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
451 symbol_cleaner sc (pattern); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
452 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
453 accept (sc); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
454 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
455 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
456 void stack_frame::clear_variable_pattern (const string_vector& patterns) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
457 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
458 symbol_cleaner sc (patterns); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
459 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
460 accept (sc); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
461 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
462 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
463 void stack_frame::clear_variable_regexp (const std::string& pattern) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
464 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
465 symbol_cleaner sc (pattern, true); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
466 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
467 accept (sc); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
468 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
469 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
470 void stack_frame::clear_variable_regexp (const string_vector& patterns) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
471 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
472 symbol_cleaner sc (patterns, true); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
473 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
474 accept (sc); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
475 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
476 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
477 void stack_frame::clear_variables (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
478 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
479 symbol_cleaner sc; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
480 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
481 accept (sc); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
482 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
483 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
484 void stack_frame::display_stopped_in_message (std::ostream& os) const |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
485 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
486 if (index () == 0) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
487 os << "at top level" << std::endl; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
488 else |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
489 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
490 os << "stopped in " << fcn_name (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
491 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
492 int l = line (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
493 if (l > 0) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
494 os << " at line " << line (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
495 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
496 os << " [" << fcn_file_name () << "] " << std::endl; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
497 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
498 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
499 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
500 void stack_frame::display (bool follow) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
501 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
502 std::ostream& os = octave_stdout; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
503 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
504 os << "-- [stack_frame] (" << this << ") --" << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
505 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
506 os << "static link: "; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
507 if (m_static_link) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
508 os << m_static_link; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
509 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
510 os << "NULL"; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
511 os << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
512 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
513 os << "access link: "; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
514 if (m_access_link) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
515 os << m_access_link; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
516 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
517 os << "NULL"; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
518 os << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
519 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
520 os << "line: " << m_line << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
521 os << "column: " << m_column << std::endl; |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
522 os << "index: " << m_index << std::endl; |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
523 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
524 os << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
525 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
526 if (! follow) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
527 return; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
528 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
529 os << "FOLLOWING ACCESS LINKS:" << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
530 const stack_frame *frm = access_link (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
531 while (frm) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
532 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
533 frm->display (false); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
534 os << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
535 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
536 frm = frm->access_link (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
537 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
538 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
539 |
26824
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
540 compiled_fcn_stack_frame * |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
541 compiled_fcn_stack_frame::dup (void) const |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
542 { |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
543 return new compiled_fcn_stack_frame (*this); |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
544 } |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
545 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
546 void compiled_fcn_stack_frame::display (bool follow) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
547 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
548 std::ostream& os = octave_stdout; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
549 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
550 os << "-- [compiled_fcn_stack_frame] (" << this << ") --" << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
551 stack_frame::display (follow); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
552 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
553 os << "fcn: " << m_fcn->name () |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
554 << " (" << m_fcn->type_name () << ")" << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
555 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
556 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
557 void compiled_fcn_stack_frame::accept (stack_frame_walker& sfw) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
558 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
559 sfw.visit_compiled_fcn_stack_frame (*this); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
560 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
561 |
27211
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27149
diff
changeset
|
562 script_stack_frame::script_stack_frame (tree_evaluator& tw, |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
563 octave_user_script *script, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
564 unwind_protect *up_frame, |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
565 size_t index, |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
566 stack_frame *static_link) |
27211
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27149
diff
changeset
|
567 : stack_frame (tw, index, static_link, get_access_link (static_link)), |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
568 m_script (script), m_unwind_protect_frame (up_frame), |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
569 m_lexical_frame_offsets (get_num_symbols (script), 1), |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
570 m_value_offsets (get_num_symbols (script), 0) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
571 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
572 set_script_offsets (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
573 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
574 |
26824
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
575 script_stack_frame * |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
576 script_stack_frame::dup (void) const |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
577 { |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
578 return new script_stack_frame (*this); |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
579 } |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
580 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
581 size_t script_stack_frame::get_num_symbols (octave_user_script *script) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
582 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
583 symbol_scope script_scope = script->scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
584 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
585 return script_scope.num_symbols (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
586 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
587 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
588 void script_stack_frame::set_script_offsets (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
589 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
590 // Set frame and data offsets inside stack frame based on enclosing |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
591 // scope(s). |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
592 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
593 symbol_scope script_scope = m_script->scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
594 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
595 size_t num_script_symbols = script_scope.num_symbols (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
596 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
597 resize (num_script_symbols); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
598 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
599 const std::map<std::string, symbol_record>& script_symbols |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
600 = script_scope.symbols (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
601 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
602 set_script_offsets_internal (script_symbols); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
603 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
604 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
605 void script_stack_frame::set_script_offsets_internal |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
606 (const std::map<std::string, symbol_record>& script_symbols) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
607 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
608 // This scope will be used to evaluate the script. Find (or |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
609 // possibly insert) symbols from the dummy script scope here. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
610 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
611 symbol_scope eval_scope = m_access_link->get_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
612 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
613 if (eval_scope.is_nested ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
614 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
615 bool found = false; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
616 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
617 for (const auto& nm_sr : script_symbols) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
618 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
619 std::string name = nm_sr.first; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
620 symbol_record script_sr = nm_sr.second; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
621 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
622 symbol_scope parent_scope = eval_scope; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
623 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
624 size_t count = 1; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
625 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
626 while (parent_scope) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
627 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
628 const std::map<std::string, symbol_record>& parent_scope_symbols |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
629 = parent_scope.symbols (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
630 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
631 auto p = parent_scope_symbols.find (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
632 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
633 if (p != parent_scope_symbols.end ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
634 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
635 found = true; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
636 symbol_record parent_scope_sr = p->second; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
637 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
638 size_t script_sr_data_offset = script_sr.data_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
639 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
640 m_lexical_frame_offsets.at (script_sr_data_offset) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
641 = parent_scope_sr.frame_offset () + 1; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
642 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
643 m_value_offsets.at (script_sr_data_offset) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
644 = parent_scope_sr.data_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
645 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
646 break; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
647 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
648 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
649 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
650 count++; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
651 parent_scope = parent_scope.parent_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
652 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
653 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
654 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
655 if (! found) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
656 error ("symbol '%s' cannot be added to static scope", |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
657 name.c_str ()); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
658 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
659 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
660 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
661 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
662 const std::map<std::string, symbol_record>& eval_scope_symbols |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
663 = eval_scope.symbols (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
664 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
665 for (const auto& nm_sr : script_symbols) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
666 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
667 std::string name = nm_sr.first; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
668 symbol_record script_sr = nm_sr.second; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
669 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
670 auto p = eval_scope_symbols.find (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
671 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
672 symbol_record eval_scope_sr; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
673 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
674 if (p == eval_scope_symbols.end ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
675 eval_scope_sr = eval_scope.insert (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
676 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
677 eval_scope_sr = p->second; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
678 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
679 size_t script_sr_data_offset = script_sr.data_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
680 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
681 // The +1 is for going from the script frame to the eval |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
682 // frame. Only one access_link should need to be followed. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
683 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
684 m_lexical_frame_offsets.at (script_sr_data_offset) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
685 = eval_scope_sr.frame_offset () + 1; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
686 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
687 m_value_offsets.at (script_sr_data_offset) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
688 = eval_scope_sr.data_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
689 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
690 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
691 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
692 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
693 void script_stack_frame::resize_and_update_script_offsets (const symbol_record& sym) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
694 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
695 size_t data_offset = sym.data_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
696 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
697 // This function is called when adding new symbols to a script |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
698 // scope. If the symbol wasn't present before, it should be outside |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
699 // the range so we need to resize then update offsets. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
700 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
701 assert (data_offset >= size ()); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
702 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
703 resize (data_offset+1); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
704 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
705 // FIXME: We should be able to avoid creating the map object and the |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
706 // looping in the set_scripts_offsets_internal function. Can we do |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
707 // that without (or with minimal) code duplication? |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
708 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
709 std::map<std::string, symbol_record> tmp_symbols; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
710 tmp_symbols[sym.name ()] = sym; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
711 set_script_offsets_internal (tmp_symbols); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
712 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
713 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
714 // If this is a nested scope, set access_link to nearest parent |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
715 // stack frame that corresponds to the lexical parent of this scope. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
716 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
717 stack_frame * |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
718 script_stack_frame::get_access_link (stack_frame *static_link) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
719 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
720 stack_frame *alink = nullptr; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
721 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
722 // If this script is called from another script, set access |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
723 // link to ultimate parent stack frame. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
724 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
725 alink = static_link; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
726 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
727 while (alink->is_user_script_frame ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
728 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
729 if (alink->access_link ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
730 alink = alink->access_link (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
731 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
732 break; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
733 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
734 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
735 return alink; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
736 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
737 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
738 symbol_record script_stack_frame::lookup_symbol (const std::string& name) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
739 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
740 symbol_scope scope = get_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
741 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
742 symbol_record sym = scope.lookup_symbol (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
743 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
744 if (sym) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
745 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
746 assert (sym.frame_offset () == 0); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
747 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
748 return sym; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
749 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
750 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
751 sym = m_access_link->lookup_symbol (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
752 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
753 // Return symbol record with adjusted frame offset. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
754 symbol_record new_sym = sym.dup (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
755 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
756 new_sym.set_frame_offset (sym.frame_offset () + 1); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
757 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
758 return new_sym; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
759 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
760 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
761 symbol_record script_stack_frame::insert_symbol (const std::string& name) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
762 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
763 // If the symbols is already in the immediate scope, there is |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
764 // nothing more to do. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
765 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
766 symbol_scope scope = get_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
767 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
768 symbol_record sym = scope.lookup_symbol (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
769 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
770 if (sym) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
771 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
772 // All symbol records in a script scope should have zero offset, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
773 // which means we redirect our lookup using |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
774 // lexical_frame_offsets and values_offets. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
775 assert (sym.frame_offset () == 0); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
776 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
777 return sym; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
778 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
779 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
780 // Insert the symbol in the current scope then resize and update |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
781 // offsets. This operation should never fail. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
782 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
783 sym = scope.find_symbol (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
784 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
785 assert (sym); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
786 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
787 resize_and_update_script_offsets (sym); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
788 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
789 return sym; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
790 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
791 |
26663
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
792 // Similar to set_script_offsets_internal except that we only return |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
793 // frame and data offsets for symbols found by name in parent scopes |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
794 // instead of updating the offsets stored in the script frame itself. |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
795 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
796 bool |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
797 script_stack_frame::get_val_offsets_internal (const symbol_record& script_sr, |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
798 size_t& frame_offset, |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
799 size_t& data_offset) const |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
800 { |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
801 bool found = false; |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
802 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
803 // This scope will be used to evaluate the script. Find symbols |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
804 // here by name. |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
805 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
806 symbol_scope eval_scope = m_access_link->get_scope (); |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
807 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
808 if (eval_scope.is_nested ()) |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
809 { |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
810 std::string name = script_sr.name (); |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
811 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
812 symbol_scope parent_scope = eval_scope; |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
813 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
814 size_t count = 1; |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
815 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
816 while (parent_scope) |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
817 { |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
818 const std::map<std::string, symbol_record>& parent_scope_symbols |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
819 = parent_scope.symbols (); |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
820 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
821 auto p = parent_scope_symbols.find (name); |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
822 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
823 if (p != parent_scope_symbols.end ()) |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
824 { |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
825 found = true; |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
826 symbol_record parent_scope_sr = p->second; |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
827 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
828 frame_offset = parent_scope_sr.frame_offset () + 1; |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
829 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
830 data_offset = parent_scope_sr.data_offset (); |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
831 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
832 break; |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
833 } |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
834 else |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
835 { |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
836 count++; |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
837 parent_scope = parent_scope.parent_scope (); |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
838 } |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
839 } |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
840 } |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
841 else |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
842 { |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
843 const std::map<std::string, symbol_record>& eval_scope_symbols |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
844 = eval_scope.symbols (); |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
845 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
846 std::string name = script_sr.name (); |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
847 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
848 auto p = eval_scope_symbols.find (name); |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
849 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
850 symbol_record eval_scope_sr; |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
851 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
852 if (p != eval_scope_symbols.end ()) |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
853 { |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
854 found = true; |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
855 eval_scope_sr = p->second; |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
856 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
857 // The +1 is for going from the script frame to the eval |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
858 // frame. Only one access_link should need to be followed. |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
859 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
860 frame_offset = eval_scope_sr.frame_offset () + 1; |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
861 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
862 data_offset = eval_scope_sr.data_offset (); |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
863 } |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
864 } |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
865 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
866 return found; |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
867 } |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
868 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
869 bool script_stack_frame::get_val_offsets (const symbol_record& sym, |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
870 size_t& frame_offset, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
871 size_t& data_offset) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
872 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
873 data_offset = sym.data_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
874 frame_offset = sym.frame_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
875 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
876 if (frame_offset == 0) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
877 { |
26663
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
878 // An out of range data_offset value here means that we have a |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
879 // symbol that was not originally in the script. But this |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
880 // function is called in places where we can't insert a new |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
881 // symbol, so we fail and it is up to the caller to decide what |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
882 // to do. |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
883 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
884 if (data_offset >= size ()) |
26663
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
885 return get_val_offsets_internal (sym, frame_offset, data_offset); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
886 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
887 // Use frame and value offsets stored in this stack frame, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
888 // indexed by data_offset from the symbol_record to find the |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
889 // values. These offsets were determined by |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
890 // script_stack_frame::set_script_offsets when this script was |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
891 // invoked. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
892 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
893 frame_offset = m_lexical_frame_offsets.at (data_offset); |
27149
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
894 |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
895 if (frame_offset == 0) |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
896 { |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
897 // If the frame offset stored in m_lexical_frame_offsets is |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
898 // zero, then the data offset in the evaluation scope has |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
899 // not been determined so try to do that now. The symbol |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
900 // may have been added by eval and without calling |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
901 // resize_and_update_script_offsets. |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
902 |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
903 return get_val_offsets_internal (sym, frame_offset, data_offset); |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
904 } |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
905 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
906 data_offset = m_value_offsets.at (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
907 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
908 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
909 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
910 // If frame_offset is not zero, then then we must have a symbol |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
911 // that was not originally in the script. The values should |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
912 // have been determined by the script_stack_frame::lookup function. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
913 } |
26663
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
914 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
915 return true; |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
916 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
917 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
918 void script_stack_frame::get_val_offsets_with_insert (const symbol_record& sym, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
919 size_t& frame_offset, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
920 size_t& data_offset) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
921 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
922 data_offset = sym.data_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
923 frame_offset = sym.frame_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
924 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
925 if (frame_offset == 0) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
926 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
927 if (data_offset >= size ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
928 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
929 // If the data_offset is out of range, then we must have a |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
930 // symbol that was not originally in the script. Resize and |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
931 // update the offsets. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
932 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
933 resize_and_update_script_offsets (sym); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
934 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
935 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
936 // Use frame and value offsets stored in this stack frame, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
937 // indexed by data_offset from the symbol_record to find the |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
938 // values. These offsets were determined by |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
939 // script_stack_frame::set_script_offsets when this script was |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
940 // invoked. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
941 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
942 frame_offset = m_lexical_frame_offsets.at (data_offset); |
27149
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
943 |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
944 if (frame_offset == 0) |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
945 { |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
946 // If the frame offset stored in m_lexical_frame_offsets is |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
947 // zero, then the data offset in the evaluation scope has |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
948 // not been determined so try to do that now. The symbol |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
949 // may have been added by eval and without calling |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
950 // resize_and_update_script_offsets. |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
951 |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
952 // We don't need to resize here. That case is handled above. |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
953 |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
954 // FIXME: We should be able to avoid creating the map object |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
955 // and the looping in the set_scripts_offsets_internal |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
956 // function. Can we do that without (or with minimal) code |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
957 // duplication? |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
958 |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
959 std::map<std::string, symbol_record> tmp_symbols; |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
960 tmp_symbols[sym.name ()] = sym; |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
961 set_script_offsets_internal (tmp_symbols); |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
962 } |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
963 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
964 data_offset = m_value_offsets.at (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
965 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
966 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
967 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
968 // If frame_offset is not zero, then then we must have a symbol |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
969 // that was not originally in the script. The values were |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
970 // determined by the script_stack_frame::lookup function. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
971 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
972 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
973 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
974 stack_frame::scope_flags |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
975 script_stack_frame::scope_flag (const symbol_record& sym) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
976 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
977 size_t frame_offset; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
978 size_t data_offset; |
26663
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
979 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
980 bool found = get_val_offsets (sym, frame_offset, data_offset); |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
981 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
982 // It can't be global or persistent, so call it local. |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
983 if (! found) |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
984 return LOCAL; |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
985 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
986 // Follow frame_offset access links to stack frame that holds |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
987 // the value. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
988 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
989 const stack_frame *frame = this; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
990 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
991 for (size_t i = 0; i < frame_offset; i++) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
992 frame = frame->access_link (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
993 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
994 if (! frame) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
995 error ("internal error: invalid access link in function call stack"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
996 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
997 if (data_offset >= frame->size ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
998 return LOCAL; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
999 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1000 return frame->get_scope_flag (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1001 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1002 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1003 octave_value script_stack_frame::varval (const symbol_record& sym) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1004 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1005 size_t frame_offset; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1006 size_t data_offset; |
26663
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1007 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1008 bool found = get_val_offsets (sym, frame_offset, data_offset); |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1009 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1010 if (! found) |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1011 return octave_value (); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1012 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1013 // Follow frame_offset access links to stack frame that holds |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1014 // the value. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1015 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1016 const stack_frame *frame = this; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1017 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1018 for (size_t i = 0; i < frame_offset; i++) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1019 frame = frame->access_link (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1020 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1021 if (! frame) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1022 error ("internal error: invalid access link in function call stack"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1023 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1024 if (data_offset >= frame->size ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1025 return octave_value (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1026 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1027 switch (frame->get_scope_flag (data_offset)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1028 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1029 case LOCAL: |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1030 return frame->varval (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1031 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1032 case PERSISTENT: |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1033 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1034 symbol_scope scope = frame->get_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1035 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1036 return scope.persistent_varval (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1037 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1038 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1039 case GLOBAL: |
27211
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27149
diff
changeset
|
1040 return m_evaluator.global_varval (sym.name ()); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1041 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1042 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1043 error ("internal error: invalid switch case"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1044 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1045 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1046 octave_value& script_stack_frame::varref (const symbol_record& sym) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1047 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1048 size_t frame_offset; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1049 size_t data_offset; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1050 get_val_offsets_with_insert (sym, frame_offset, data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1051 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1052 // Follow frame_offset access links to stack frame that holds |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1053 // the value. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1054 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1055 stack_frame *frame = this; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1056 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1057 for (size_t i = 0; i < frame_offset; i++) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1058 frame = frame->access_link (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1059 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1060 if (data_offset >= frame->size ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1061 frame->resize (data_offset+1); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1062 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1063 switch (frame->get_scope_flag (data_offset)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1064 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1065 case LOCAL: |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1066 return frame->varref (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1067 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1068 case PERSISTENT: |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1069 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1070 symbol_scope scope = frame->get_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1071 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1072 return scope.persistent_varref (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1073 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1074 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1075 case GLOBAL: |
27211
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27149
diff
changeset
|
1076 return m_evaluator.global_varref (sym.name ()); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1077 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1078 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1079 error ("internal error: invalid switch case"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1080 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1081 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1082 void script_stack_frame::mark_scope (const symbol_record& sym, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1083 scope_flags flag) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1084 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1085 size_t data_offset = sym.data_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1086 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1087 // Redirection to evaluation context for the script. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1088 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1089 size_t frame_offset = m_lexical_frame_offsets.at (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1090 data_offset = m_value_offsets.at (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1091 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1092 if (frame_offset > 1) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1093 error ("variables must be made PERSISTENT or GLOBAL in the first scope in which they are used"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1094 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1095 stack_frame *frame = access_link (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1096 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1097 if (data_offset >= frame->size ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1098 frame->resize (data_offset+1); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1099 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1100 frame->set_scope_flag (data_offset, flag); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1101 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1102 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1103 void script_stack_frame::display (bool follow) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1104 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1105 std::ostream& os = octave_stdout; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1106 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1107 os << "-- [script_stack_frame] (" << this << ") --" << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1108 stack_frame::display (follow); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1109 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1110 os << "script: " << m_script->name () |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1111 << " (" << m_script->type_name () << ")" << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1112 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1113 os << "lexical_offsets: " << m_lexical_frame_offsets.size () |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1114 << " elements:"; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1115 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1116 for (size_t i = 0; i < m_lexical_frame_offsets.size (); i++) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1117 os << " " << m_lexical_frame_offsets.at (i); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1118 os << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1119 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1120 os << "value_offsets: " << m_value_offsets.size () << " elements:"; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1121 for (size_t i = 0; i < m_value_offsets.size (); i++) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1122 os << " " << m_value_offsets.at (i); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1123 os << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1124 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1125 display_scope (os, get_scope ()); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1126 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1127 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1128 void script_stack_frame::accept (stack_frame_walker& sfw) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1129 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1130 sfw.visit_script_stack_frame (*this); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1131 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1132 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1133 void base_value_stack_frame::display (bool follow) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1134 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1135 std::ostream& os = octave_stdout; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1136 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1137 os << "-- [base_value_stack_frame] (" << this << ") --" << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1138 stack_frame::display (follow); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1139 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1140 os << "values: " << m_values.size () |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1141 << " elements (idx, scope flag, type):" << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1142 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1143 for (size_t i = 0; i < m_values.size (); i++) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1144 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1145 os << " (" << i << ", " << m_flags.at (i) << ", "; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1146 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1147 octave_value val = varval (i); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1148 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1149 os << (val.is_defined () ? val.type_name () : " UNDEFINED") << ")" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1150 << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1151 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1152 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1153 |
26824
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
1154 user_fcn_stack_frame * |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
1155 user_fcn_stack_frame::dup (void) const |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
1156 { |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
1157 return new user_fcn_stack_frame (*this); |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
1158 } |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
1159 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1160 // If this is a nested scope, set access_link to nearest parent |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1161 // stack frame that corresponds to the lexical parent of this scope. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1162 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1163 stack_frame * |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1164 user_fcn_stack_frame::get_access_link (octave_user_function *fcn, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1165 stack_frame *static_link) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1166 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1167 stack_frame *alink = nullptr; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1168 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1169 symbol_scope fcn_scope = fcn->scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1170 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1171 if (fcn_scope.is_nested ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1172 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1173 if (! static_link) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1174 error ("internal call stack error (invalid static link)"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1175 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1176 symbol_scope caller_scope = static_link->get_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1177 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1178 int nesting_depth = fcn_scope.nesting_depth (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1179 int caller_nesting_depth = caller_scope.nesting_depth (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1180 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1181 if (caller_nesting_depth < nesting_depth) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1182 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1183 // FIXME: do we need to ensure that the called |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1184 // function is a child of the caller? Does it hurt |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1185 // to assert this condition, at least for now? |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1186 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1187 alink = static_link; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1188 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1189 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1190 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1191 // FIXME: do we need to check that the parent of the |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1192 // called function is also a parent of the caller? |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1193 // Does it hurt to assert this condition, at least |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1194 // for now? |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1195 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1196 int links_to_follow = caller_nesting_depth - nesting_depth + 1; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1197 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1198 alink = static_link; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1199 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1200 while (alink && --links_to_follow >= 0) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1201 alink = alink->access_link (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1202 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1203 if (! alink) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1204 error ("internal function nesting error (invalid access link)"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1205 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1206 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1207 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1208 return alink; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1209 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1210 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1211 void user_fcn_stack_frame::clear_values (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1212 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1213 symbol_scope fcn_scope = m_fcn->scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1214 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1215 const std::list<symbol_record>& symbols = fcn_scope.symbol_list (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1216 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1217 if (size () == 0) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1218 return; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1219 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1220 for (const auto& sym : symbols) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1221 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1222 size_t frame_offset = sym.frame_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1223 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1224 if (frame_offset > 0) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1225 continue; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1226 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1227 size_t data_offset = sym.data_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1228 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1229 if (data_offset >= size ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1230 continue; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1231 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1232 if (get_scope_flag (data_offset) == LOCAL) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1233 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1234 octave_value& ref = m_values.at (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1235 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1236 if (ref.get_count () == 1) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1237 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1238 ref.call_object_destructor (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1239 ref = octave_value (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1240 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1241 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1242 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1243 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1244 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1245 symbol_record user_fcn_stack_frame::lookup_symbol (const std::string& name) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1246 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1247 const stack_frame *frame = this; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1248 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1249 while (frame) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1250 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1251 symbol_scope scope = frame->get_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1252 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1253 symbol_record sym = scope.lookup_symbol (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1254 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1255 if (sym) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1256 return sym; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1257 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1258 frame = frame->access_link (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1259 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1260 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1261 return symbol_record (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1262 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1263 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1264 symbol_record user_fcn_stack_frame::insert_symbol (const std::string& name) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1265 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1266 // If the symbols is already in the immediate scope, there is |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1267 // nothing more to do. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1268 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1269 symbol_scope scope = get_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1270 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1271 symbol_record sym = scope.lookup_symbol (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1272 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1273 if (sym) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1274 return sym; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1275 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1276 // FIXME: This needs some thought... We may need to add a symbol to |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1277 // a static workspace, but the symbol can never be defined as a |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1278 // variable. This currently works by tagging the added symbol as |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1279 // "added_static". Aside from the bad name, this doesn't seem like |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1280 // the best solution. Maybe scopes should have a separate set of |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1281 // symbols that may only be defined as functions? |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1282 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1283 // Insert the symbol in the current scope. This is not possible for |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1284 // anonymous functions, nested functions, or functions that contain |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1285 // nested functions (their scopes will all be marked static). |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1286 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1287 // if (scope.is_static ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1288 // error ("can not add variable '%s' to a static workspace", |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1289 // name.c_str ()); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1290 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1291 // At this point, non-local references are not possible so we only |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1292 // need to look in the current scope and insert there. This |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1293 // operation should never fail. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1294 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1295 sym = scope.find_symbol (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1296 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1297 assert (sym); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1298 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1299 return sym; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1300 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1301 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1302 stack_frame::scope_flags |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1303 user_fcn_stack_frame::scope_flag (const symbol_record& sym) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1304 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1305 size_t frame_offset = sym.frame_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1306 size_t data_offset = sym.data_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1307 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1308 // Follow frame_offset access links to stack frame that holds |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1309 // the value. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1310 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1311 const stack_frame *frame = this; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1312 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1313 for (size_t i = 0; i < frame_offset; i++) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1314 frame = frame->access_link (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1315 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1316 if (! frame) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1317 error ("internal error: invalid access link in function call stack"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1318 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1319 if (data_offset >= frame->size ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1320 return LOCAL; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1321 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1322 return frame->get_scope_flag (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1323 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1324 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1325 octave_value user_fcn_stack_frame::varval (const symbol_record& sym) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1326 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1327 size_t frame_offset = sym.frame_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1328 size_t data_offset = sym.data_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1329 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1330 // Follow frame_offset access links to stack frame that holds |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1331 // the value. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1332 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1333 const stack_frame *frame = this; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1334 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1335 for (size_t i = 0; i < frame_offset; i++) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1336 frame = frame->access_link (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1337 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1338 if (! frame) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1339 error ("internal error: invalid access link in function call stack"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1340 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1341 if (data_offset >= frame->size ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1342 return octave_value (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1343 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1344 switch (frame->get_scope_flag (data_offset)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1345 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1346 case LOCAL: |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1347 return frame->varval (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1348 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1349 case PERSISTENT: |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1350 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1351 symbol_scope scope = frame->get_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1352 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1353 return scope.persistent_varval (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1354 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1355 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1356 case GLOBAL: |
27211
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27149
diff
changeset
|
1357 return m_evaluator.global_varval (sym.name ()); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1358 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1359 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1360 error ("internal error: invalid switch case"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1361 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1362 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1363 octave_value& user_fcn_stack_frame::varref (const symbol_record& sym) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1364 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1365 size_t frame_offset = sym.frame_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1366 size_t data_offset = sym.data_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1367 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1368 // Follow frame_offset access links to stack frame that holds |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1369 // the value. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1370 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1371 stack_frame *frame = this; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1372 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1373 for (size_t i = 0; i < frame_offset; i++) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1374 frame = frame->access_link (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1375 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1376 if (data_offset >= frame->size ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1377 frame->resize (data_offset+1); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1378 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1379 switch (frame->get_scope_flag (data_offset)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1380 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1381 case LOCAL: |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1382 return frame->varref (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1383 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1384 case PERSISTENT: |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1385 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1386 symbol_scope scope = frame->get_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1387 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1388 return scope.persistent_varref (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1389 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1390 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1391 case GLOBAL: |
27211
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27149
diff
changeset
|
1392 return m_evaluator.global_varref (sym.name ()); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1393 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1394 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1395 error ("internal error: invalid switch case"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1396 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1397 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1398 void user_fcn_stack_frame::mark_scope (const symbol_record& sym, scope_flags flag) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1399 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1400 size_t frame_offset = sym.frame_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1401 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1402 if (frame_offset > 0 && (flag == PERSISTENT || flag == GLOBAL)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1403 error ("variables must be made PERSISTENT or GLOBAL in the first scope in which they are used"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1404 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1405 size_t data_offset = sym.data_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1406 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1407 if (data_offset >= size ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1408 resize (data_offset+1); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1409 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1410 set_scope_flag (data_offset, flag); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1411 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1412 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1413 void user_fcn_stack_frame::display (bool follow) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1414 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1415 std::ostream& os = octave_stdout; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1416 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1417 os << "-- [user_fcn_stack_frame] (" << this << ") --" << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1418 base_value_stack_frame::display (follow); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1419 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1420 os << "fcn: " << m_fcn->name () |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1421 << " (" << m_fcn->type_name () << ")" << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1422 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1423 display_scope (os, get_scope ()); |
27932
b018f553fd85
maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1424 } |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1425 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1426 void user_fcn_stack_frame::accept (stack_frame_walker& sfw) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1427 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1428 sfw.visit_user_fcn_stack_frame (*this); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1429 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1430 |
26824
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
1431 scope_stack_frame * |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
1432 scope_stack_frame::dup (void) const |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
1433 { |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
1434 return new scope_stack_frame (*this); |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
1435 } |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
1436 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1437 symbol_record scope_stack_frame::insert_symbol (const std::string& name) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1438 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1439 // There is no access link for scope frames, so there is no other |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1440 // frame to search in and the offset must be zero. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1441 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1442 symbol_record sym = m_scope.lookup_symbol (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1443 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1444 if (sym) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1445 return sym; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1446 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1447 // If the symbol is not found, insert it. We only need to search in |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1448 // the local scope object. This operation should never fail. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1449 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1450 sym = m_scope.find_symbol (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1451 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1452 assert (sym); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1453 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1454 return sym; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1455 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1456 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1457 stack_frame::scope_flags |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1458 scope_stack_frame::scope_flag (const symbol_record& sym) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1459 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1460 // There is no access link for scope frames, so the frame |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1461 // offset must be zero. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1462 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1463 size_t data_offset = sym.data_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1464 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1465 if (data_offset >= size ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1466 return LOCAL; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1467 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1468 return get_scope_flag (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1469 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1470 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1471 octave_value scope_stack_frame::varval (const symbol_record& sym) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1472 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1473 // There is no access link for scope frames, so the frame |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1474 // offset must be zero. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1475 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1476 size_t data_offset = sym.data_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1477 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1478 if (data_offset >= size ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1479 return octave_value (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1480 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1481 switch (get_scope_flag (data_offset)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1482 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1483 case LOCAL: |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1484 return m_values.at (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1485 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1486 case PERSISTENT: |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1487 return m_scope.persistent_varval (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1488 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1489 case GLOBAL: |
27211
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27149
diff
changeset
|
1490 return m_evaluator.global_varval (sym.name ()); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1491 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1492 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1493 error ("internal error: invalid switch case"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1494 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1495 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1496 octave_value& scope_stack_frame::varref (const symbol_record& sym) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1497 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1498 // There is no access link for scope frames, so the frame |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1499 // offset must be zero. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1500 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1501 size_t data_offset = sym.data_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1502 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1503 if (data_offset >= size ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1504 resize (data_offset+1); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1505 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1506 switch (get_scope_flag (data_offset)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1507 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1508 case LOCAL: |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1509 return m_values.at (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1510 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1511 case PERSISTENT: |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1512 return m_scope.persistent_varref (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1513 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1514 case GLOBAL: |
27211
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27149
diff
changeset
|
1515 return m_evaluator.global_varref (sym.name ()); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1516 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1517 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1518 error ("internal error: invalid switch case"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1519 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1520 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1521 void scope_stack_frame::mark_scope (const symbol_record& sym, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1522 scope_flags flag) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1523 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1524 // There is no access link for scope frames, so the frame |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1525 // offset must be zero. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1526 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1527 size_t data_offset = sym.data_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1528 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1529 if (data_offset >= size ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1530 resize (data_offset+1); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1531 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1532 set_scope_flag (data_offset, flag); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1533 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1534 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1535 void scope_stack_frame::display (bool follow) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1536 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1537 std::ostream& os = octave_stdout; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1538 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1539 os << "-- [scope_stack_frame] (" << this << ") --" << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1540 base_value_stack_frame::display (follow); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1541 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1542 display_scope (os, m_scope); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1543 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1544 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1545 void scope_stack_frame::accept (stack_frame_walker& sfw) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1546 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1547 sfw.visit_scope_stack_frame (*this); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1548 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1549 } |