26 #if ! defined (octave_ov_usr_fcn_h)
27 #define octave_ov_usr_fcn_h 1
29 #include "octave-config.h"
54 OCTAVE_END_NAMESPACE(
octave)
62 const octave::symbol_scope& scope = octave::symbol_scope::anonymous (),
63 octave::tree_statement_list *cmds =
nullptr,
64 const std::string& ds =
"")
66 m_t_parsed (static_cast<OCTAVE_TIME_T> (0)),
67 m_t_checked (static_cast<OCTAVE_TIME_T> (0)),
68 m_file_info (nullptr), m_cmd_list (cmds)
71 m_scope.set_user_code (
this);
82 std::string get_code_line (std::size_t
line);
84 std::deque<std::string> get_code_lines (std::size_t
line,
85 std::size_t num_lines);
87 void cache_function_text (
const std::string&
text,
88 const octave::sys::time& timestamp);
90 octave::symbol_scope
scope () {
return m_scope; }
102 mark_fcn_file_up_to_date (t);
116 virtual std::map<std::string, octave_value> subfunctions ()
const;
118 octave::tree_statement_list *
body () {
return m_cmd_list; }
124 void get_file_info ();
157 const octave::symbol_scope& scope = octave::symbol_scope::anonymous (),
158 octave::tree_statement_list *cmds =
nullptr,
159 const std::string& ds =
"");
162 const octave::symbol_scope& scope = octave::symbol_scope::anonymous (),
163 const std::string& ds =
"");
186 call (octave::tree_evaluator& tw,
int nargout = 0,
190 execute (octave::tree_evaluator& tw,
int nargout = 0,
193 void accept (octave::tree_walker& tw);
208 octave::tree_parameter_list *pl =
nullptr,
209 octave::tree_parameter_list *rl =
nullptr,
210 octave::tree_statement_list *cl =
nullptr);
228 m_location_line =
line;
229 m_location_column = col;
237 m_end_location_line =
line;
238 m_end_location_column = col;
244 void maybe_relocate_end ();
246 void stash_parent_fcn_scope (
const octave::symbol_scope& ps);
252 std::string profiler_name ()
const;
256 octave::symbol_scope pscope = parent_fcn_scope ();
258 return pscope.fcn_name ();
263 return m_scope.parent_scope ();
268 return m_scope.parent_fcn_names ();
271 void mark_as_system_fcn_file ();
277 void erase_subfunctions ();
279 bool takes_varargs ()
const;
281 bool takes_var_return ()
const;
283 void mark_as_private_function (
const std::string& cname =
"");
285 void lock_subfunctions ();
287 void unlock_subfunctions ();
289 std::map<std::string, octave_value> subfunctions ()
const;
291 octave_value find_subfunction (
const std::string& subfuns)
const;
293 bool has_subfunctions ()
const;
295 void stash_subfunction_names (
const std::list<std::string>& names);
297 std::list<std::string> subfunction_names ()
const;
316 (
const std::string& cname =
"")
const
318 return m_anonymous_function
320 ? (! dispatch_class ().empty ())
321 : cname == dispatch_class ())
330 return is_inline_function () || is_anonymous_function ();
343 return (m_class_constructor == legacy
344 ? (cname.empty () ?
true : cname == dispatch_class ()) :
false);
351 return (m_class_constructor == classdef
352 ? (cname.empty () ?
true : cname == dispatch_class ()) :
false);
359 return (m_class_method == legacy
360 ? (cname.empty () ?
true : cname == dispatch_class ()) :
false);
367 return (m_class_method == classdef
368 ? (cname.empty () ?
true : cname == dispatch_class ()) :
false);
377 call (octave::tree_evaluator& tw,
int nargout = 0,
381 execute (octave::tree_evaluator& tw,
int nargout = 0,
386 octave::tree_parameter_list *
return_list () {
return m_ret_list; }
394 octave::tree_expression * special_expr ();
396 bool subsasgn_optimization_ok ();
398 void accept (octave::tree_walker& tw);
404 enum class_method_type
411 std::string ctor_type_str ()
const;
412 std::string method_type_str ()
const;
415 octave::tree_parameter_list *m_param_list;
419 octave::tree_parameter_list *m_ret_list;
422 octave::comment_list *m_lead_comm;
425 octave::comment_list *m_trail_comm;
429 int m_location_column;
430 int m_end_location_line;
431 int m_end_location_column;
436 bool m_system_fcn_file;
439 int m_num_named_args;
445 bool m_inline_function;
448 bool m_anonymous_function;
451 bool m_nested_function;
454 class_method_type m_class_constructor;
457 class_method_type m_class_method;
459 void maybe_relocate_end_internal ();
461 void print_code_function_header (
const std::string& prefix);
463 void print_code_function_trailer (
const std::string& prefix);
468 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
octave::tree_statement_list * body()
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
void mark_as_inline_function()
bool is_legacy_method(const std::string &cname="") const
void stash_trailing_comment(octave::comment_list *tc)
void stash_function_name(const std::string &s)
bool is_nested_function() const
bool is_inline_function() const
bool is_special_expr() const
octave::comment_list * trailing_comment()
octave_function * function_value(bool=false)
bool is_classdef_constructor(const std::string &cname="") const
bool is_system_fcn_file() const
int ending_column() const
octave::comment_list * leading_comment()
octave::symbol_scope parent_fcn_scope() const
octave::tree_parameter_list * parameter_list()
octave_user_function * define_param_list(octave::tree_parameter_list *t)
void mark_as_classdef_method()
octave_user_function * user_function_value(bool=false)
bool is_legacy_constructor(const std::string &cname="") const
int beginning_column() const
bool is_classdef_method(const std::string &cname="") const
std::string parent_fcn_name() const
bool is_anonymous_function() const
bool is_anonymous_function_of_class(const std::string &cname="") const
void mark_as_legacy_constructor()
octave_user_code * user_code_value(bool=false)
void mark_as_legacy_method()
int beginning_line() const
void stash_leading_comment(octave::comment_list *lc)
bool is_subfunction() const
void stash_fcn_location(int line, int col)
std::list< std::string > parent_fcn_names() const
void mark_as_subfunction()
void stash_fcn_end_location(int line, int col)
octave::tree_parameter_list * return_list()
void mark_as_anonymous_function()
bool is_parent_function() const
void mark_as_classdef_constructor()
bool is_user_function() const
void mark_as_nested_function()
~octave_user_script()=default
bool is_user_script() const
octave_user_code * user_code_value(bool=false)
octave_function * function_value(bool=false)
octave_user_script * user_script_value(bool=false)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
#define DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA