GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
ov-builtin.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1996-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_ov_builtin_h)
27 #define octave_ov_builtin_h 1
28 
29 #include "octave-config.h"
30 
31 #include <list>
32 #include <set>
33 #include <string>
34 
35 #include "ov-fcn.h"
36 #include "ov-typeinfo.h"
37 
38 class octave_value;
39 class octave_value_list;
40 
41 namespace octave
42 {
43  class tree_evaluator;
44  class interpreter;
45  class jit_type;
46 }
47 
48 // Builtin functions.
49 
50 class
51 OCTINTERP_API
53 {
54 public:
55 
56  octave_builtin (void) : octave_function (), f (nullptr), m (nullptr),
57  file (), jtype (nullptr)
58  { }
59 
61  const octave_value_list&, int);
62 
63  typedef octave_value_list (*fcn) (const octave_value_list&, int);
64 
65  octave_builtin (fcn ff, const std::string& nm = "",
66  const std::string& ds = "")
67  : octave_function (nm, ds), f (ff), m (nullptr), file (), jtype (nullptr)
68  { }
69 
70  octave_builtin (meth mm, const std::string& nm = "",
71  const std::string& ds = "")
72  : octave_function (nm, ds), f (nullptr), m (mm), file (), jtype (nullptr)
73  { }
74 
75  octave_builtin (fcn ff, const std::string& nm, const std::string& fnm,
76  const std::string& ds)
77  : octave_function (nm, ds), f (ff), m (nullptr), file (fnm), jtype (nullptr)
78  { }
79 
80  octave_builtin (meth mm, const std::string& nm, const std::string& fnm,
81  const std::string& ds)
82  : octave_function (nm, ds), f (nullptr), m (mm), file (fnm), jtype (nullptr)
83  { }
84 
85  // No copying!
86 
87  octave_builtin (const octave_builtin& ob) = delete;
88 
89  octave_builtin& operator = (const octave_builtin& ob) = delete;
90 
91  ~octave_builtin (void) = default;
92 
93  std::string src_file_name (void) const { return file; }
94 
95  octave_function * function_value (bool = false) { return this; }
96 
97  bool is_builtin_function (void) const { return true; }
98 
100  execute (octave::tree_evaluator& tw, int nargout = 0,
101  const octave_value_list& args = octave_value_list ());
102 
103  octave::jit_type * to_jit (void) const;
104 
105  void stash_jit (octave::jit_type& type);
106 
107  fcn function (void) const;
108 
109  meth method (void) const;
110 
111  void push_dispatch_class (const std::string& dispatch_type);
112 
113  bool handles_dispatch_class (const std::string& dispatch_type) const;
114 
115 protected:
116 
117  // A pointer to the actual function.
118  fcn f;
119  meth m;
120 
121  // The name of the file where this function was defined.
122  std::string file;
123 
124  // The types this function has been declared to handle (if any).
125  std::set<std::string> dispatch_classes;
126 
127  // A pointer to the jit type that represents the function.
129 
130 private:
131 
133 };
134 
135 #endif
octave_builtin(fcn ff, const std::string &nm="", const std::string &ds="")
Definition: ov-builtin.h:65
octave_builtin(const octave_builtin &ob)=delete
octave_function * function_value(bool=false)
Definition: ov-builtin.h:95
std::string src_file_name(void) const
Definition: ov-builtin.h:93
octave_builtin(fcn ff, const std::string &nm, const std::string &fnm, const std::string &ds)
Definition: ov-builtin.h:75
octave_builtin(meth mm, const std::string &nm="", const std::string &ds="")
Definition: ov-builtin.h:70
std::string file
Definition: ov-builtin.h:122
octave::jit_type * jtype
Definition: ov-builtin.h:128
~octave_builtin(void)=default
octave_builtin(meth mm, const std::string &nm, const std::string &fnm, const std::string &ds)
Definition: ov-builtin.h:80
std::set< std::string > dispatch_classes
Definition: ov-builtin.h:125
bool is_builtin_function(void) const
Definition: ov-builtin.h:97
octave_builtin(void)
Definition: ov-builtin.h:56
F77_RET_T const F77_DBLE const F77_DBLE * f
T octave_idx_type m
Definition: mx-inlines.cc:773
#define DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
Definition: ov-base.h:158