GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ov-fcn.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2017 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if ! defined (octave_ov_fcn_h)
24 #define octave_ov_fcn_h 1
25 
26 #include "octave-config.h"
27 
28 #include <string>
29 
30 #include "oct-time.h"
31 #include "str-vec.h"
32 
33 #include "ovl.h"
34 #include "ov-base.h"
35 #include "ov-typeinfo.h"
36 #include "symtab.h"
37 
38 class tree_walker;
39 
40 // Functions.
41 
42 class
45 {
46 public:
47 
49  : relative (false), locked (false), private_function (false),
50  xdispatch_class (), xpackage_name (), my_name (), my_dir_name (),
51  doc () { }
52 
53  ~octave_function (void) { }
54 
55  octave_base_value *clone (void) const;
56  octave_base_value *empty_clone (void) const;
57 
58  bool is_defined (void) const { return true; }
59 
60  bool is_function (void) const { return true; }
61 
62  virtual bool is_system_fcn_file (void) const { return false; }
63 
64  virtual std::string fcn_file_name (void) const { return ""; }
65 
66  virtual std::string src_file_name (void) const { return ""; }
67 
68  // The name to show in the profiler (also used as map-key).
69  virtual std::string profiler_name (void) const { return name (); }
70 
71  virtual std::string parent_fcn_name (void) const { return ""; }
72 
73  virtual symbol_table::scope_id parent_fcn_scope (void) const { return -1; }
74 
75  virtual void mark_fcn_file_up_to_date (const octave::sys::time&) { }
76 
77  virtual symbol_table::scope_id scope (void) { return -1; }
78 
79  virtual octave::sys::time time_parsed (void) const
80  { return octave::sys::time (static_cast<time_t> (0)); }
81 
82  virtual octave::sys::time time_checked (void) const
83  { return octave::sys::time (static_cast<time_t> (0)); }
84 
85  virtual bool is_subfunction (void) const { return false; }
86 
87  virtual bool is_class_constructor (const std::string& = "") const
88  { return false; }
89 
90  virtual bool
92  { return false; }
93 
94  virtual bool is_class_method (const std::string& = "") const
95  { return false; }
96 
97  virtual bool takes_varargs (void) const { return false; }
98 
99  virtual bool takes_var_return (void) const { return false; }
100 
101  void stash_dispatch_class (const std::string& nm) { xdispatch_class = nm; }
102 
103  std::string dispatch_class (void) const { return xdispatch_class; }
104 
105  void stash_package_name (const std::string& pack) { xpackage_name = pack; }
106 
107  std::string package_name (void) const { return xpackage_name; }
108 
109  virtual void
111  {
112  private_function = true;
113  xdispatch_class = cname;
114  }
115 
116  bool is_private_function (void) const { return private_function; }
117 
119  { return private_function && xdispatch_class == nm; }
120 
121  virtual bool
123  { return false; }
124 
125  std::string dir_name (void) const { return my_dir_name; }
126 
127  void stash_dir_name (const std::string& dir) { my_dir_name = dir; }
128 
129  void lock (void)
130  {
131  this->lock_subfunctions ();
132  locked = true;
133  }
134 
135  void unlock (void)
136  {
137  this->unlock_subfunctions ();
138  locked = false;
139  }
140 
141  bool islocked (void) const { return locked; }
142 
143  virtual void lock_subfunctions (void) { }
144 
145  virtual void unlock_subfunctions (void) { }
146 
147  virtual void maybe_relocate_end (void) { }
148 
149  // Not valid until after the function is completley parsed.
150  virtual bool has_subfunctions (void) const { return false; }
151 
152  virtual void stash_subfunction_names (const std::list<std::string>&) { }
153 
154  virtual std::list<std::string> subfunction_names (void) const
155  {
156  return std::list<std::string> ();
157  }
158 
159  void mark_relative (void) { relative = true; }
160 
161  bool is_relative (void) const { return relative; }
162 
163  std::string name (void) const { return my_name; }
164 
166  {
167  if (xpackage_name.empty ())
168  return my_name;
169  else
170  return xpackage_name + "." + my_name;
171  }
172 
173  void document (const std::string& ds) { doc = ds; }
174 
175  std::string doc_string (void) const { return doc; }
176 
177  virtual void unload (void) { }
178 
179  virtual void accept (tree_walker&) { }
180 
181  virtual bool is_postfix_index_handled (char type) const
182  { return (type == '(' || type == '{'); }
183 
184 protected:
185 
187  const std::string& ds = "")
188  : relative (false), locked (false), private_function (false),
189  xdispatch_class (), my_name (nm), my_dir_name (), doc (ds) { }
190 
191  // TRUE if this function was found from a relative path element.
192  bool relative;
193 
194  // TRUE if this function is tagged so that it can't be cleared.
195  bool locked;
196 
197  // TRUE means this is a private function.
199 
200  // If this object is a class method or constructor, or a private
201  // function inside a class directory, this is the name of the class
202  // to which the method belongs.
204 
205  // If this function is part of a package, this is the full name
206  // of the package to which the function belongs.
208 
209  // The name of this function.
211 
212  // The name of the directory in the path where we found this
213  // function. May be relative.
215 
216  // The help text for this function.
218 
219 private:
220 
221  // No copying!
222 
224 
226 
227 };
228 
229 #endif
virtual bool is_classdef_constructor(const std::string &="") const
Definition: ov-fcn.h:91
std::string my_name
Definition: ov-fcn.h:210
bool is_relative(void) const
Definition: ov-fcn.h:161
void document(const std::string &ds)
Definition: ov-fcn.h:173
virtual bool is_postfix_index_handled(char type) const
Definition: ov-fcn.h:181
virtual void stash_subfunction_names(const std::list< std::string > &)
Definition: ov-fcn.h:152
void lock(void)
Definition: ov-fcn.h:129
virtual bool is_class_method(const std::string &="") const
Definition: ov-fcn.h:94
virtual void unlock_subfunctions(void)
Definition: ov-fcn.h:145
virtual void unload(void)
Definition: ov-fcn.h:177
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE const F77_DBLE * f
std::string doc
Definition: ov-fcn.h:217
std::string xdispatch_class
Definition: ov-fcn.h:203
std::string doc_string(void) const
Definition: ov-fcn.h:175
void mark_relative(void)
Definition: ov-fcn.h:159
std::string name(void) const
Definition: ov-fcn.h:163
virtual bool is_class_constructor(const std::string &="") const
Definition: ov-fcn.h:87
virtual octave::sys::time time_checked(void) const
Definition: ov-fcn.h:82
virtual std::string src_file_name(void) const
Definition: ov-fcn.h:66
void stash_dir_name(const std::string &dir)
Definition: ov-fcn.h:127
virtual bool takes_var_return(void) const
Definition: ov-fcn.h:99
bool relative
Definition: ov-fcn.h:192
virtual octave::sys::time time_parsed(void) const
Definition: ov-fcn.h:79
bool is_private_function_of_class(const std::string &nm) const
Definition: ov-fcn.h:118
std::string dispatch_class(void) const
Definition: ov-fcn.h:103
virtual symbol_table::scope_id scope(void)
Definition: ov-fcn.h:77
bool is_function(void) const
Definition: ov-fcn.h:60
bool private_function
Definition: ov-fcn.h:198
OCTAVE_EXPORT octave_value_list any number nd example oindent prints the prompt xample Pick a any number!nd example oindent and waits for the user to enter a value The string entered by the user is evaluated as an so it may be a literal a variable name
Definition: input.cc:871
OCTAVE_EXPORT octave_value_list isdir nd deftypefn *std::string nm
Definition: utils.cc:941
#define OCTINTERP_API
Definition: mexproto.h:69
virtual bool has_subfunctions(void) const
Definition: ov-fcn.h:150
std::string package_name(void) const
Definition: ov-fcn.h:107
virtual void mark_as_private_function(const std::string &cname="")
Definition: ov-fcn.h:110
is false
Definition: cellfun.cc:398
virtual symbol_table::scope_id parent_fcn_scope(void) const
Definition: ov-fcn.h:73
bool is_private_function(void) const
Definition: ov-fcn.h:116
virtual std::list< std::string > subfunction_names(void) const
Definition: ov-fcn.h:154
octave_function(void)
Definition: ov-fcn.h:48
idx type
Definition: ov.cc:3129
std::string my_dir_name
Definition: ov-fcn.h:214
virtual void maybe_relocate_end(void)
Definition: ov-fcn.h:147
std::string canonical_name(void) const
Definition: ov-fcn.h:165
octave_function(const std::string &nm, const std::string &ds="")
Definition: ov-fcn.h:186
void unlock(void)
Definition: ov-fcn.h:135
std::string dir_name(void) const
Definition: ov-fcn.h:125
virtual std::string parent_fcn_name(void) const
Definition: ov-fcn.h:71
virtual std::string profiler_name(void) const
Definition: ov-fcn.h:69
virtual void lock_subfunctions(void)
Definition: ov-fcn.h:143
virtual bool is_system_fcn_file(void) const
Definition: ov-fcn.h:62
virtual std::string fcn_file_name(void) const
Definition: ov-fcn.h:64
~octave_function(void)
Definition: ov-fcn.h:53
virtual void mark_fcn_file_up_to_date(const octave::sys::time &)
Definition: ov-fcn.h:75
virtual bool is_subfunction(void) const
Definition: ov-fcn.h:85
void stash_dispatch_class(const std::string &nm)
Definition: ov-fcn.h:101
virtual bool is_anonymous_function_of_class(const std::string &="") const
Definition: ov-fcn.h:122
virtual void accept(tree_walker &)
Definition: ov-fcn.h:179
std::string xpackage_name
Definition: ov-fcn.h:207
virtual bool takes_varargs(void) const
Definition: ov-fcn.h:97
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:854
tree_walker & operator=(const tree_walker &)
bool islocked(void) const
Definition: ov-fcn.h:141
void stash_package_name(const std::string &pack)
Definition: ov-fcn.h:105
bool is_defined(void) const
Definition: ov-fcn.h:58