Mercurial > octave
diff libinterp/octave-value/ov-usr-fcn.h @ 25400:d423ce60f5c8
evaluate script and function code in tree_evaluator methods
* ov-usr-fcn.cc (octave_user_code::m_call_depth): Rename from
call_depth. Change all uses.
(octave_user_script::call): Call tree_evaluator::execute_user_script.
(octave_user_function::call): Call tree_evaluator::execute_user_function.
(octave_user_code::call_depth, octave_user_code::set_call_depth,
octave_user_code::increment_call_depth): New functions.
(octave_user_script::set_call_depth,
octave_user_function::set_call_depth):
Forward to octave_user_code::set_call_depth.
(octave_user_function::bind_automatic_vars): Make public.
* pt-eval.h, pt-eval.cc (tree_evaluator::execute_user_script,
tree_evaluator::execute_user_function): New functions, moved here and
adapted from octave_user_script::call and octave_user_function:call,
respectively.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 21 May 2018 22:06:20 -0400 |
parents | 6ca2c0d76d84 |
children | d2aae3570c81 |
line wrap: on
line diff
--- a/libinterp/octave-value/ov-usr-fcn.h Mon May 21 19:32:57 2018 -0400 +++ b/libinterp/octave-value/ov-usr-fcn.h Mon May 21 22:06:20 2018 -0400 @@ -67,7 +67,7 @@ : octave_function (nm, ds), m_scope (scope), file_name (fnm), t_parsed (static_cast<time_t> (0)), t_checked (static_cast<time_t> (0)), - call_depth (-1), m_file_info (nullptr), + m_call_depth (-1), m_file_info (nullptr), cmd_list (cmds) { } @@ -108,6 +108,13 @@ octave::sys::time time_checked (void) const { return t_checked; } + // XXX FIXME + int call_depth (void) const { return m_call_depth; } + + void set_call_depth (int val) { m_call_depth = val; } + + void increment_call_depth (void) { ++m_call_depth; } + virtual std::map<std::string, octave_value> subfunctions (void) const; octave::tree_statement_list * body (void) { return cmd_list; } @@ -132,7 +139,7 @@ octave::sys::time t_checked; // Used to keep track of recursion depth. - int call_depth; + int m_call_depth; // Cached text of function or script code with line offsets // calculated. @@ -185,6 +192,9 @@ void accept (octave::tree_walker& tw); + // XXX FIXME + void set_call_depth (int val) { octave_user_code::set_call_depth (val); } + private: DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA @@ -213,7 +223,7 @@ octave::symbol_record::context_id active_context () const { return is_anonymous_function () - ? 0 : static_cast<octave::symbol_record::context_id>(call_depth); + ? 0 : static_cast<octave::symbol_record::context_id>(m_call_depth); } octave_function * function_value (bool = false) { return this; } @@ -379,6 +389,9 @@ octave_value dump (void) const; + // XXX FIXME + void set_call_depth (int val) { octave_user_code::set_call_depth (val); } + private: enum class_ctor_type @@ -448,6 +461,9 @@ void print_code_function_trailer (const std::string& prefix); + // XXX FIXME (public) +public: + void bind_automatic_vars (octave::tree_evaluator& tw, const string_vector& arg_names, int nargin, int nargout,