Mercurial > octave
comparison libinterp/corefcn/load-save.cc @ 25201:c80323fe4938 stable
improve handling of global symbols (bug #53599)
* load-save.cc (install_loaded_variable): For global values, check
global status and link to global symbol if needed.
* symrec.h (symbol_record::symbol_record_rep::unbind_global_rep):
New function.
(symbol_record::symbol_record_rep::clear): Use unbind_global_rep to
clearing global symbols.
(symbol_record::symbol_record_rep::is_marked_global): New function.
(symbol_record::symbol_record_rep::is_global): Use it.
(symbol_record::symbol_record_rep::bind_fwd_rep): Don't forward again
if symbol is already global.
(symbol_record::unbind_fwd_rep): Eliminate argument. Change all uses.
(symbol_record::symbol_record_rep::unbind_fwd_rep):
Eliminate argument. Simplify.
* test/bug-53599.tst: New file.
* test/module.mk: Update.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 10 Apr 2018 22:22:37 -0400 |
parents | d7ad543255c5 |
children | 3ff9192b676e 07c2c42f457e |
comparison
equal
deleted
inserted
replaced
25200:b3ee0179d7b0 | 25201:c80323fe4938 |
---|---|
151 octave::symbol_scope scope | 151 octave::symbol_scope scope |
152 = symtab.require_current_scope ("install_loaded_variable"); | 152 = symtab.require_current_scope ("install_loaded_variable"); |
153 | 153 |
154 if (global) | 154 if (global) |
155 { | 155 { |
156 scope.clear_variable (name); | 156 octave::symbol_record sym = scope.find_symbol (name); |
157 scope.mark_global (name); | 157 |
158 symtab.assign (name, val); | 158 if (! sym.is_global ()) |
159 } | 159 { |
160 else | 160 octave::symbol_scope global_scope = symtab.global_scope (); |
161 scope.assign (name, val); | 161 octave::symbol_record global_sym = global_scope.find_symbol (name); |
162 | |
163 sym.bind_fwd_rep (global_scope.get_rep (), global_sym); | |
164 } | |
165 } | |
166 | |
167 scope.assign (name, val); | |
162 } | 168 } |
163 | 169 |
164 // Return TRUE if NAME matches one of the given globbing PATTERNS. | 170 // Return TRUE if NAME matches one of the given globbing PATTERNS. |
165 | 171 |
166 static bool | 172 static bool |