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 octave::comment_list leading_comments ()
const;
89 OCTINTERP_API octave::comment_list trailing_comments ()
const;
91 OCTINTERP_API std::string get_code_line (std::size_t line);
93 OCTINTERP_API std::deque<std::string>
94 get_code_lines (std::size_t line, std::size_t num_lines);
97 cache_function_text (
const std::string& text,
98 const octave::sys::time& timestamp);
100 octave::symbol_scope
scope () {
return m_scope; }
112 mark_fcn_file_up_to_date (t);
126 virtual std::map<std::string, octave_value> subfunctions ()
const;
128 octave::tree_statement_list *
body () {
return m_cmd_list; }
134 OCTINTERP_API
void get_file_info ();
167 const octave::symbol_scope& scope = octave::symbol_scope::anonymous (),
168 octave::tree_statement_list *cmds =
nullptr,
169 const std::string& ds =
"");
173 const octave::symbol_scope& scope = octave::symbol_scope::anonymous (),
174 const std::string& ds =
"");
197 call (octave::tree_evaluator& tw,
int nargout = 0,
201 execute (octave::tree_evaluator& tw,
int nargout = 0,
204 OCTINTERP_API
void accept (octave::tree_walker& tw);
219 octave::tree_identifier *
id =
nullptr,
220 octave::tree_parameter_list *pl =
nullptr,
221 octave::tree_parameter_list *rl =
nullptr,
222 octave::tree_statement_list *cl =
nullptr);
229 OCTINTERP_API std::string signature ()
const;
241 define_ret_list (octave::tree_parameter_list *t);
243 void set_fcn_tok (
const octave::token& fcn_tok) { m_fcn_tok = fcn_tok; }
244 void set_eq_tok (
const octave::token& eq_tok) { m_eq_tok = eq_tok; }
247 attach_trailing_comments (
const octave::comment_list& lst);
249 octave::filepos
beg_pos ()
const {
return m_fcn_tok.beg_pos(); }
253 {
return m_fcn_tok.leading_comments (); }
256 OCTINTERP_API
void maybe_relocate_end ();
258 OCTINTERP_API
void stash_parent_fcn_scope (
const octave::symbol_scope& ps);
260 OCTINTERP_API std::string profiler_name ()
const;
264 octave::symbol_scope pscope = parent_fcn_scope ();
266 return pscope.fcn_name ();
271 return m_scope.parent_scope ();
276 return m_scope.parent_fcn_names ();
279 OCTINTERP_API
void mark_as_system_fcn_file ();
285 OCTINTERP_API
void erase_subfunctions ();
287 OCTINTERP_API
bool takes_varargs ()
const;
289 OCTINTERP_API
bool takes_var_return ()
const;
291 OCTINTERP_API
void mark_as_private_function (
const std::string& cname =
"");
293 OCTINTERP_API
void lock_subfunctions ();
295 OCTINTERP_API
void unlock_subfunctions ();
297 OCTINTERP_API std::map<std::string, octave_value> subfunctions ()
const;
300 find_subfunction (
const std::string& subfuns)
const;
302 OCTINTERP_API
bool has_subfunctions ()
const;
305 stash_subfunction_names (
const std::list<std::string>& names);
307 OCTINTERP_API std::list<std::string> subfunction_names ()
const;
326 (
const std::string& cname =
"")
const
328 return m_anonymous_function
330 ? (! dispatch_class ().empty ())
331 : cname == dispatch_class ())
340 return is_inline_function () || is_anonymous_function ();
353 return (m_class_constructor == legacy
354 ? (cname.empty () ?
true : cname == dispatch_class ()) :
false);
361 return (m_class_constructor == classdef
362 ? (cname.empty () ?
true : cname == dispatch_class ()) :
false);
369 return (m_class_method == legacy
370 ? (cname.empty () ?
true : cname == dispatch_class ()) :
false);
377 return (m_class_method == classdef
378 ? (cname.empty () ?
true : cname == dispatch_class ()) :
false);
387 call (octave::tree_evaluator& tw,
int nargout = 0,
391 execute (octave::tree_evaluator& tw,
int nargout = 0,
396 octave::tree_parameter_list *
return_list () {
return m_ret_list; }
400 OCTINTERP_API octave::tree_expression * special_expr ();
402 OCTINTERP_API
bool subsasgn_optimization_ok ();
404 OCTINTERP_API
void accept (octave::tree_walker& tw);
410 enum class_method_type
417 OCTINTERP_API std::string ctor_type_str ()
const;
418 OCTINTERP_API std::string method_type_str ()
const;
421 octave::tree_identifier *m_id;
424 octave::tree_parameter_list *m_param_list;
428 octave::tree_parameter_list *m_ret_list;
434 octave::token m_fcn_tok;
435 octave::token m_eq_tok;
440 bool m_system_fcn_file {
false};
443 int m_num_named_args;
446 bool m_subfunction {
false};
449 bool m_inline_function {
false};
452 bool m_anonymous_function {
false};
455 bool m_nested_function {
false};
458 class_method_type m_class_constructor {none};
461 class_method_type m_class_method {none};
463 OCTINTERP_API
void maybe_relocate_end_internal ();
465 OCTINTERP_API
void print_code_function_header (
const std::string& prefix);
467 OCTINTERP_API
void print_code_function_trailer (
const std::string& prefix);
472 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)