comparison libinterp/corefcn/stack-frame.cc @ 27211:8c27802a76c4

store reference to evaluator instead of call stack in stack frame * pt-eval.h, pt-eval.cc (tree_evaluator::max_stack_depth, tree_evaluator::global_varref, tree_evaluator::display_call_stack): New functions. * call-stack.cc (display_call_stack): Delete. (call_stack::push): Use evaluator instead of call_stack to create stack_frame object. (Fmax_stack_depth): Eliminate direct access of call stack. * stack-frame.h, stack-frame.cc (stack_frame::install_variable, script_stack_frame::varval, script_stack_frame::varref, user_fcn_stack_frame::varval, usr_fcn_stack_frame::varref, scope_stack_frame::varval, scope_stack_frame::varref): Access global values through evaluator to eliminate direct access to call stack. (stack_frame::m_call_stack): Delete. (stack_frame::m_evaluator): New member variable. Update constructors.
author John W. Eaton <jwe@octave.org>
date Tue, 02 Apr 2019 11:51:24 +0000
parents 61226b7bd6b9
children b442ec6dda5c
comparison
equal deleted inserted replaced
27210:bd684aad1821 27211:8c27802a76c4
25 #endif 25 #endif
26 26
27 #include "lo-regexp.h" 27 #include "lo-regexp.h"
28 #include "str-vec.h" 28 #include "str-vec.h"
29 29
30 #include "call-stack.h"
31 #include "defun.h" 30 #include "defun.h"
32 #include "interpreter.h" 31 #include "interpreter.h"
33 #include "interpreter-private.h" 32 #include "interpreter-private.h"
34 #include "oct-map.h" 33 #include "oct-map.h"
35 #include "ov.h" 34 #include "ov.h"
36 #include "ov-fcn.h" 35 #include "ov-fcn.h"
37 #include "ov-fcn-handle.h" 36 #include "ov-fcn-handle.h"
38 #include "ov-usr-fcn.h" 37 #include "ov-usr-fcn.h"
39 #include "pager.h" 38 #include "pager.h"
40 #include "parse.h" 39 #include "parse.h"
40 #include "pt-eval.h"
41 #include "stack-frame.h" 41 #include "stack-frame.h"
42 #include "stack-frame-walker.h" 42 #include "stack-frame-walker.h"
43 #include "syminfo.h" 43 #include "syminfo.h"
44 #include "syminfo-accumulator.h" 44 #include "syminfo-accumulator.h"
45 #include "symrec.h" 45 #include "symrec.h"
384 384
385 // If the symbol is defined in the local but not the 385 // If the symbol is defined in the local but not the
386 // global scope, then use the local value as the 386 // global scope, then use the local value as the
387 // initial value. This value will also override any 387 // initial value. This value will also override any
388 // initializer in the global statement. 388 // initializer in the global statement.
389 octave_value global_val = m_call_stack.global_varval (nm); 389 octave_value global_val = m_evaluator.global_varval (nm);
390 390
391 if (global_val.is_defined ()) 391 if (global_val.is_defined ())
392 { 392 {
393 warning_with_id ("Octave:global-local-conflict", 393 warning_with_id ("Octave:global-local-conflict",
394 "global: global value overrides existing local value"); 394 "global: global value overrides existing local value");
398 else 398 else
399 { 399 {
400 warning_with_id ("Octave:global-local-conflict", 400 warning_with_id ("Octave:global-local-conflict",
401 "global: existing local value used to initialize global variable"); 401 "global: existing local value used to initialize global variable");
402 402
403 m_call_stack.global_varref (nm) = val; 403 m_evaluator.global_varref (nm) = val;
404 } 404 }
405 } 405 }
406 406
407 mark_global (sym); 407 mark_global (sym);
408 } 408 }
554 void compiled_fcn_stack_frame::accept (stack_frame_walker& sfw) 554 void compiled_fcn_stack_frame::accept (stack_frame_walker& sfw)
555 { 555 {
556 sfw.visit_compiled_fcn_stack_frame (*this); 556 sfw.visit_compiled_fcn_stack_frame (*this);
557 } 557 }
558 558
559 script_stack_frame::script_stack_frame (call_stack& cs, 559 script_stack_frame::script_stack_frame (tree_evaluator& tw,
560 octave_user_script *script, 560 octave_user_script *script,
561 unwind_protect *up_frame, 561 unwind_protect *up_frame,
562 size_t index, 562 size_t index,
563 stack_frame *static_link) 563 stack_frame *static_link)
564 : stack_frame (cs, index, static_link, get_access_link (static_link)), 564 : stack_frame (tw, index, static_link, get_access_link (static_link)),
565 m_script (script), m_unwind_protect_frame (up_frame), 565 m_script (script), m_unwind_protect_frame (up_frame),
566 m_lexical_frame_offsets (get_num_symbols (script), 1), 566 m_lexical_frame_offsets (get_num_symbols (script), 1),
567 m_value_offsets (get_num_symbols (script), 0) 567 m_value_offsets (get_num_symbols (script), 0)
568 { 568 {
569 set_script_offsets (); 569 set_script_offsets ();
1032 1032
1033 return scope.persistent_varval (data_offset); 1033 return scope.persistent_varval (data_offset);
1034 } 1034 }
1035 1035
1036 case GLOBAL: 1036 case GLOBAL:
1037 return m_call_stack.global_varval (sym.name ()); 1037 return m_evaluator.global_varval (sym.name ());
1038 } 1038 }
1039 1039
1040 error ("internal error: invalid switch case"); 1040 error ("internal error: invalid switch case");
1041 } 1041 }
1042 1042
1068 1068
1069 return scope.persistent_varref (data_offset); 1069 return scope.persistent_varref (data_offset);
1070 } 1070 }
1071 1071
1072 case GLOBAL: 1072 case GLOBAL:
1073 return m_call_stack.global_varref (sym.name ()); 1073 return m_evaluator.global_varref (sym.name ());
1074 } 1074 }
1075 1075
1076 error ("internal error: invalid switch case"); 1076 error ("internal error: invalid switch case");
1077 } 1077 }
1078 1078
1349 1349
1350 return scope.persistent_varval (data_offset); 1350 return scope.persistent_varval (data_offset);
1351 } 1351 }
1352 1352
1353 case GLOBAL: 1353 case GLOBAL:
1354 return m_call_stack.global_varval (sym.name ()); 1354 return m_evaluator.global_varval (sym.name ());
1355 } 1355 }
1356 1356
1357 error ("internal error: invalid switch case"); 1357 error ("internal error: invalid switch case");
1358 } 1358 }
1359 1359
1384 1384
1385 return scope.persistent_varref (data_offset); 1385 return scope.persistent_varref (data_offset);
1386 } 1386 }
1387 1387
1388 case GLOBAL: 1388 case GLOBAL:
1389 return m_call_stack.global_varref (sym.name ()); 1389 return m_evaluator.global_varref (sym.name ());
1390 } 1390 }
1391 1391
1392 error ("internal error: invalid switch case"); 1392 error ("internal error: invalid switch case");
1393 } 1393 }
1394 1394
1482 1482
1483 case PERSISTENT: 1483 case PERSISTENT:
1484 return m_scope.persistent_varval (data_offset); 1484 return m_scope.persistent_varval (data_offset);
1485 1485
1486 case GLOBAL: 1486 case GLOBAL:
1487 return m_call_stack.global_varval (sym.name ()); 1487 return m_evaluator.global_varval (sym.name ());
1488 } 1488 }
1489 1489
1490 error ("internal error: invalid switch case"); 1490 error ("internal error: invalid switch case");
1491 } 1491 }
1492 1492
1507 1507
1508 case PERSISTENT: 1508 case PERSISTENT:
1509 return m_scope.persistent_varref (data_offset); 1509 return m_scope.persistent_varref (data_offset);
1510 1510
1511 case GLOBAL: 1511 case GLOBAL:
1512 return m_call_stack.global_varref (sym.name ()); 1512 return m_evaluator.global_varref (sym.name ());
1513 } 1513 }
1514 1514
1515 error ("internal error: invalid switch case"); 1515 error ("internal error: invalid switch case");
1516 } 1516 }
1517 1517