Mercurial > octave
comparison libinterp/corefcn/call-stack.cc @ 27844:e06ce39f78ad
allow mlock to lock current dynamically loaded function (bug #57245)
* pt-eval.cc (tree_evaluator::mlock): Simply forward to
call_stack::mlock.
* call-stack.h, call-stack.cc (call_stack::mlock): New function.
Lock first user-defined or dynamically loaded function on the call
stack. Silently skip the built-in Fmlock function. Warn if called
from any other built-in function.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 16 Dec 2019 14:34:34 -0500 |
parents | e091e09d26f0 |
children | 020d0e8f7ac6 |
comparison
equal
deleted
inserted
replaced
27843:48c77d47ea81 | 27844:e06ce39f78ad |
---|---|
718 { | 718 { |
719 while (! m_cs.empty ()) | 719 while (! m_cs.empty ()) |
720 pop (); | 720 pop (); |
721 } | 721 } |
722 | 722 |
723 void call_stack::mlock (void) const | |
724 { | |
725 if (m_cs.empty ()) | |
726 error ("mlock: call stack is empty"); | |
727 | |
728 octave_function *fcn = nullptr; | |
729 | |
730 size_t idx = size (); | |
731 | |
732 while (--idx) | |
733 { | |
734 const stack_frame *elt = m_cs[idx]; | |
735 fcn = elt->function (); | |
736 | |
737 if (fcn) | |
738 { | |
739 if (fcn->is_builtin_function ()) | |
740 { | |
741 if (fcn->name () == "mlock") | |
742 continue; | |
743 | |
744 warning ("mlock: locking built-in function has no effect"); | |
745 return; | |
746 } | |
747 | |
748 break; | |
749 } | |
750 } | |
751 | |
752 if (! fcn) | |
753 error ("mlock: invalid use outside a function"); | |
754 | |
755 fcn->lock (); | |
756 } | |
757 | |
723 symbol_info_list call_stack::all_variables (void) | 758 symbol_info_list call_stack::all_variables (void) |
724 { | 759 { |
725 return m_cs[m_curr_frame]->all_variables (); | 760 return m_cs[m_curr_frame]->all_variables (); |
726 } | 761 } |
727 | 762 |