comparison src/symtab.h @ 9009:da58ec8f62e8

tag bug don't define forced variables
author John W. Eaton <jwe@octave.org>
date Mon, 23 Mar 2009 19:29:01 -0400
parents eb63fbe60fab
children c6463412aebb
comparison
equal deleted inserted replaced
9008:7a7cf569528d 9009:da58ec8f62e8
202 void force_variable (context_id context) 202 void force_variable (context_id context)
203 { 203 {
204 octave_value& val = varref (context); 204 octave_value& val = varref (context);
205 205
206 if (! val.is_defined ()) 206 if (! val.is_defined ())
207 { 207 mark_forced ();
208 val = Matrix ();
209 mark_forced ();
210 }
211 } 208 }
212 209
213 octave_value& varref (context_id context) 210 octave_value& varref (context_id context)
214 { 211 {
215 if (is_global ()) 212 if (is_global ())
291 288
292 varref (xcurrent_context) = octave_value (); 289 varref (xcurrent_context) = octave_value ();
293 } 290 }
294 } 291 }
295 292
296 void clear_forced (void)
297 {
298 if (is_forced ())
299 {
300 varref (xcurrent_context) = octave_value ();
301 unmark_forced ();
302 }
303 }
304
305 bool is_defined (context_id context) const 293 bool is_defined (context_id context) const
306 { 294 {
307 return varval (context).is_defined (); 295 return varval (context).is_defined ();
308 } 296 }
309 297
310 bool is_variable (context_id context) const 298 bool is_variable (context_id context) const
311 { 299 {
312 return (storage_class != local || is_defined (context)); 300 return (storage_class != local || is_defined (context) || is_forced ());
313 } 301 }
314 302
315 bool is_local (void) const { return storage_class & local; } 303 bool is_local (void) const { return storage_class & local; }
316 bool is_automatic (void) const { return storage_class & automatic; } 304 bool is_automatic (void) const { return storage_class & automatic; }
317 bool is_formal (void) const { return storage_class & formal; } 305 bool is_formal (void) const { return storage_class & formal; }
455 443
456 size_t pop_context (void) { return rep->pop_context (); } 444 size_t pop_context (void) { return rep->pop_context (); }
457 445
458 void clear (void) { rep->clear (); } 446 void clear (void) { rep->clear (); }
459 447
460 void clear_forced (void) { rep->clear_forced (); }
461
462 bool is_defined (context_id context = xcurrent_context) const 448 bool is_defined (context_id context = xcurrent_context) const
463 { 449 {
464 return rep->is_defined (context); 450 return rep->is_defined (context);
465 } 451 }
466 452
1351 1337
1352 if (inst) 1338 if (inst)
1353 inst->do_clear_variables (); 1339 inst->do_clear_variables ();
1354 } 1340 }
1355 1341
1356 static void clear_forced_variables (scope_id scope = xcurrent_scope) 1342 static void unmark_forced_variables (scope_id scope = xcurrent_scope)
1357 { 1343 {
1358 symbol_table *inst = get_instance (scope); 1344 symbol_table *inst = get_instance (scope);
1359 1345
1360 if (inst) 1346 if (inst)
1361 inst->do_clear_forced_variables (); 1347 inst->do_unmark_forced_variables ();
1362 } 1348 }
1363 1349
1364 // For unwind_protect. 1350 // For unwind_protect.
1365 static void clear_variables (void *) { clear_variables (); } 1351 static void clear_variables (void *) { clear_variables (); }
1366 1352
2131 { 2117 {
2132 for (table_iterator p = table.begin (); p != table.end (); p++) 2118 for (table_iterator p = table.begin (); p != table.end (); p++)
2133 p->second.clear (); 2119 p->second.clear ();
2134 } 2120 }
2135 2121
2136 void do_clear_forced_variables (void) 2122 void do_unmark_forced_variables (void)
2137 { 2123 {
2138 for (table_iterator p = table.begin (); p != table.end (); p++) 2124 for (table_iterator p = table.begin (); p != table.end (); p++)
2139 p->second.clear_forced (); 2125 p->second.unmark_forced ();
2140 } 2126 }
2141 2127
2142 void do_clear_global (const std::string& name) 2128 void do_clear_global (const std::string& name)
2143 { 2129 {
2144 table_iterator p = table.find (name); 2130 table_iterator p = table.find (name);