26#if ! defined (octave_ov_usr_fcn_h)
27#define octave_ov_usr_fcn_h 1
29#include "octave-config.h"
58OCTAVE_END_NAMESPACE(octave)
65 const octave::symbol_scope& scope = octave::symbol_scope::anonymous (),
66 octave::tree_statement_list *cmds =
nullptr,
67 const std::string& ds =
"")
69 m_t_parsed (static_cast<OCTAVE_TIME_T> (0)),
70 m_t_checked (static_cast<OCTAVE_TIME_T> (0)),
71 m_file_info (nullptr), m_cmd_list (cmds)
74 m_scope.set_user_code (
this);
85 OCTINTERP_API octave::filepos beg_pos ()
const;
86 OCTINTERP_API octave::filepos end_pos ()
const;
88 OCTINTERP_API std::string get_code_line (std::size_t line);
90 OCTINTERP_API std::deque<std::string>
91 get_code_lines (std::size_t line, std::size_t num_lines);
94 cache_function_text (
const std::string& text,
95 const octave::sys::time& timestamp);
97 octave::symbol_scope
scope () {
return m_scope; }
109 mark_fcn_file_up_to_date (t);
123 virtual std::map<std::string, octave_value> subfunctions ()
const;
125 octave::tree_statement_list *
body () {
return m_cmd_list; }
131 OCTINTERP_API
void get_file_info ();
164 const octave::symbol_scope& scope = octave::symbol_scope::anonymous (),
165 octave::tree_statement_list *cmds =
nullptr,
166 const std::string& ds =
"");
170 const octave::symbol_scope& scope = octave::symbol_scope::anonymous (),
171 const std::string& ds =
"");
194 call (octave::tree_evaluator& tw,
int nargout = 0,
198 execute (octave::tree_evaluator& tw,
int nargout = 0,
201 OCTINTERP_API
void accept (octave::tree_walker& tw);
216 octave::tree_identifier *
id =
nullptr,
217 octave::tree_parameter_list *pl =
nullptr,
218 octave::tree_parameter_list *rl =
nullptr,
219 octave::tree_statement_list *cl =
nullptr);
226 OCTINTERP_API std::string signature ()
const;
238 define_ret_list (octave::tree_parameter_list *t);
240 void set_fcn_tok (
const octave::token& fcn_tok) { m_fcn_tok = fcn_tok; }
241 void set_eq_tok (
const octave::token& eq_tok) { m_eq_tok = eq_tok; }
244 attach_trailing_comments (
const octave::comment_list& lst);
246 octave::filepos
beg_pos ()
const {
return m_fcn_tok.beg_pos(); }
249 OCTINTERP_API
void maybe_relocate_end ();
251 OCTINTERP_API
void stash_parent_fcn_scope (
const octave::symbol_scope& ps);
253 OCTINTERP_API std::string profiler_name ()
const;
257 octave::symbol_scope pscope = parent_fcn_scope ();
259 return pscope.fcn_name ();
264 return m_scope.parent_scope ();
269 return m_scope.parent_fcn_names ();
272 OCTINTERP_API
void mark_as_system_fcn_file ();
278 OCTINTERP_API
void erase_subfunctions ();
280 OCTINTERP_API
bool takes_varargs ()
const;
282 OCTINTERP_API
bool takes_var_return ()
const;
284 OCTINTERP_API
void mark_as_private_function (
const std::string& cname =
"");
286 OCTINTERP_API
void lock_subfunctions ();
288 OCTINTERP_API
void unlock_subfunctions ();
290 OCTINTERP_API std::map<std::string, octave_value> subfunctions ()
const;
293 find_subfunction (
const std::string& subfuns)
const;
295 OCTINTERP_API
bool has_subfunctions ()
const;
298 stash_subfunction_names (
const std::list<std::string>& names);
300 OCTINTERP_API std::list<std::string> subfunction_names ()
const;
319 (
const std::string& cname =
"")
const
321 return m_anonymous_function
323 ? (! dispatch_class ().empty ())
324 : cname == dispatch_class ())
333 return is_inline_function () || is_anonymous_function ();
346 return (m_class_constructor == legacy
347 ? (cname.empty () ?
true : cname == dispatch_class ()) :
false);
354 return (m_class_constructor == classdef
355 ? (cname.empty () ?
true : cname == dispatch_class ()) :
false);
362 return (m_class_method == legacy
363 ? (cname.empty () ?
true : cname == dispatch_class ()) :
false);
370 return (m_class_method == classdef
371 ? (cname.empty () ?
true : cname == dispatch_class ()) :
false);
380 call (octave::tree_evaluator& tw,
int nargout = 0,
384 execute (octave::tree_evaluator& tw,
int nargout = 0,
389 octave::tree_parameter_list *
return_list () {
return m_ret_list; }
392 OCTINTERP_API octave::comment_list trailing_comments ()
const;
396 OCTINTERP_API octave::tree_expression * special_expr ();
398 OCTINTERP_API
bool subsasgn_optimization_ok ();
400 OCTINTERP_API
void accept (octave::tree_walker& tw);
406 enum class_method_type
413 OCTINTERP_API std::string ctor_type_str ()
const;
414 OCTINTERP_API std::string method_type_str ()
const;
417 octave::tree_identifier *m_id;
420 octave::tree_parameter_list *m_param_list;
424 octave::tree_parameter_list *m_ret_list;
430 octave::token m_fcn_tok;
431 octave::token m_eq_tok;
436 bool m_system_fcn_file {
false};
439 int m_num_named_args;
442 bool m_subfunction {
false};
445 bool m_inline_function {
false};
448 bool m_anonymous_function {
false};
451 bool m_nested_function {
false};
454 class_method_type m_class_constructor {none};
457 class_method_type m_class_method {none};
459 OCTINTERP_API
void maybe_relocate_end_internal ();
461 OCTINTERP_API
void print_code_function_header (
const std::string& prefix);
463 OCTINTERP_API
void print_code_function_trailer (
const std::string& prefix);
468 OCTINTERP_API
void restore_warning_states ();
void stash_fcn_file_name(const std::string &nm)
octave_user_code(const std::string &fnm="", const std::string &nm="", const octave::symbol_scope &scope=octave::symbol_scope::anonymous(), octave::tree_statement_list *cmds=nullptr, const std::string &ds="")
bool is_user_code() const
octave::symbol_scope scope()
void mark_fcn_file_up_to_date(const octave::sys::time &t)
octave::sys::time m_t_checked
std::string fcn_file_name() const
octave::tree_statement_list * m_cmd_list
virtual octave_value find_subfunction(const std::string &) const
octave::sys::time m_t_parsed
octave::file_info * m_file_info
void stash_fcn_file_time(const octave::sys::time &t)
octave::symbol_scope m_scope
std::size_t scope_num_symbols()
octave::sys::time time_parsed() const
octave::sys::time time_checked() const
octave::tree_statement_list * body()
void mark_as_inline_function()
bool is_legacy_method(const std::string &cname="") const
std::list< std::string > parent_fcn_names() const
void stash_function_name(const std::string &s)
void set_fcn_tok(const octave::token &fcn_tok)
bool is_nested_function() const
octave_user_code * user_code_value(bool=false)
bool is_inline_function() const
octave::tree_parameter_list * parameter_list()
bool is_special_expr() const
octave::comment_list leading_comments() const
bool is_classdef_constructor(const std::string &cname="") const
bool is_system_fcn_file() const
octave::symbol_scope parent_fcn_scope() const
void mark_as_classdef_method()
bool is_legacy_constructor(const std::string &cname="") const
bool is_classdef_method(const std::string &cname="") const
octave::tree_parameter_list * return_list()
void set_eq_tok(const octave::token &eq_tok)
std::string parent_fcn_name() const
octave_user_function * user_function_value(bool=false)
bool is_anonymous_function() const
octave_function * function_value(bool=false)
bool is_anonymous_function_of_class(const std::string &cname="") const
void mark_as_legacy_constructor()
void mark_as_legacy_method()
bool is_subfunction() const
void mark_as_subfunction()
octave_user_function * define_param_list(octave::tree_parameter_list *t)
void mark_as_anonymous_function()
bool is_parent_function() const
octave::filepos beg_pos() const
void mark_as_classdef_constructor()
bool is_user_function() const
void mark_as_nested_function()
octave_user_code * user_code_value(bool=false)
~octave_user_script()=default
bool is_user_script() const
octave_user_script * user_script_value(bool=false)
octave_function * function_value(bool=false)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_API(API)