Mercurial > octave
comparison libinterp/octave-value/ov-usr-fcn.cc @ 27207:242e66e014d9
eliminate direct access to call stack in ov-usr-fcn.cc
* ov-usr-fcn.cc (octave_user_function::restore_warning_states,
Fnargin, Fnargout, Fisargout): Eliminate direct access to call stack.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 01 Apr 2019 20:28:53 +0000 |
parents | 4274f6962e6b |
children | dccdc3b001a2 |
comparison
equal
deleted
inserted
replaced
27206:4e4a9d7b436e | 27207:242e66e014d9 |
---|---|
29 #include "file-info.h" | 29 #include "file-info.h" |
30 #include "file-stat.h" | 30 #include "file-stat.h" |
31 #include "str-vec.h" | 31 #include "str-vec.h" |
32 | 32 |
33 #include "builtin-defun-decls.h" | 33 #include "builtin-defun-decls.h" |
34 #include "call-stack.h" | |
35 #include "defaults.h" | 34 #include "defaults.h" |
36 #include "Cell.h" | 35 #include "Cell.h" |
37 #include "defun.h" | 36 #include "defun.h" |
38 #include "error.h" | 37 #include "error.h" |
39 #include "errwarn.h" | 38 #include "errwarn.h" |
592 octave_user_function::restore_warning_states (void) | 591 octave_user_function::restore_warning_states (void) |
593 { | 592 { |
594 octave::interpreter& interp | 593 octave::interpreter& interp |
595 = octave::__get_interpreter__ ("octave_user_function::restore_warning_states"); | 594 = octave::__get_interpreter__ ("octave_user_function::restore_warning_states"); |
596 | 595 |
597 octave::call_stack& cs = interp.get_call_stack (); | 596 octave::tree_evaluator& tw = interp.get_evaluator (); |
598 | 597 |
599 octave_value val | 598 octave_value val |
600 = cs.get_auto_fcn_var (octave::stack_frame::SAVED_WARNING_STATES); | 599 = tw.get_auto_fcn_var (octave::stack_frame::SAVED_WARNING_STATES); |
601 | 600 |
602 if (val.is_defined ()) | 601 if (val.is_defined ()) |
603 { | 602 { |
604 // Fail spectacularly if SAVED_WARNING_STATES is not an | 603 // Fail spectacularly if SAVED_WARNING_STATES is not an |
605 // octave_map (or octave_scalar_map) object. | 604 // octave_map (or octave_scalar_map) object. |
693 if (fcn->takes_varargs ()) | 692 if (fcn->takes_varargs ()) |
694 retval = -1 - retval; | 693 retval = -1 - retval; |
695 } | 694 } |
696 else | 695 else |
697 { | 696 { |
698 octave::call_stack& cs = interp.get_call_stack (); | 697 octave::tree_evaluator& tw = interp.get_evaluator (); |
699 | 698 |
700 retval = cs.get_auto_fcn_var (octave::stack_frame::NARGIN); | 699 retval = tw.get_auto_fcn_var (octave::stack_frame::NARGIN); |
701 | 700 |
702 if (retval.is_undefined ()) | 701 if (retval.is_undefined ()) |
703 retval = 0; | 702 retval = 0; |
704 } | 703 } |
705 | 704 |
820 else | 819 else |
821 { | 820 { |
822 if (interp.at_top_level ()) | 821 if (interp.at_top_level ()) |
823 error ("nargout: invalid call at top level"); | 822 error ("nargout: invalid call at top level"); |
824 | 823 |
825 octave::call_stack& cs = interp.get_call_stack (); | 824 octave::tree_evaluator& tw = interp.get_evaluator (); |
826 | 825 |
827 retval = cs.get_auto_fcn_var (octave::stack_frame::NARGOUT); | 826 retval = tw.get_auto_fcn_var (octave::stack_frame::NARGOUT); |
828 | 827 |
829 if (retval.is_undefined ()) | 828 if (retval.is_undefined ()) |
830 retval = 0; | 829 retval = 0; |
831 } | 830 } |
832 | 831 |
892 print_usage (); | 891 print_usage (); |
893 | 892 |
894 if (interp.at_top_level ()) | 893 if (interp.at_top_level ()) |
895 error ("isargout: invalid call at top level"); | 894 error ("isargout: invalid call at top level"); |
896 | 895 |
897 octave::call_stack& cs = interp.get_call_stack (); | 896 octave::tree_evaluator& tw = interp.get_evaluator (); |
898 | 897 |
899 octave_value tmp; | 898 octave_value tmp; |
900 | 899 |
901 int nargout1 = 0; | 900 int nargout1 = 0; |
902 tmp = cs.get_auto_fcn_var (octave::stack_frame::NARGOUT); | 901 tmp = tw.get_auto_fcn_var (octave::stack_frame::NARGOUT); |
903 if (tmp.is_defined ()) | 902 if (tmp.is_defined ()) |
904 nargout1 = tmp.int_value (); | 903 nargout1 = tmp.int_value (); |
905 | 904 |
906 Matrix ignored; | 905 Matrix ignored; |
907 tmp = cs.get_auto_fcn_var (octave::stack_frame::IGNORED); | 906 tmp = tw.get_auto_fcn_var (octave::stack_frame::IGNORED); |
908 if (tmp.is_defined ()) | 907 if (tmp.is_defined ()) |
909 ignored = tmp.matrix_value (); | 908 ignored = tmp.matrix_value (); |
910 | 909 |
911 if (args(0).is_scalar_type ()) | 910 if (args(0).is_scalar_type ()) |
912 { | 911 { |