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
pt-fcn-handle.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2003-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_pt_fcn_handle_h)
24 #define octave_pt_fcn_handle_h 1
25 
26 #include "octave-config.h"
27 
28 #include <iosfwd>
29 #include <string>
30 
31 #include "pt-bp.h"
32 #include "pt-exp.h"
33 #include "pt-misc.h"
34 #include "pt-stmt.h"
35 #include "symtab.h"
36 
37 class octave_value_list;
38 
39 class tree_walker;
40 
41 #include "ov.h"
42 #include "ov-usr-fcn.h"
43 #include "symtab.h"
44 
45 class
47 {
48 public:
49 
50  tree_fcn_handle (int l = -1, int c = -1)
51  : tree_expression (l, c), nm () { }
52 
53  tree_fcn_handle (const std::string& n, int l = -1, int c = -1)
54  : tree_expression (l, c), nm (n) { }
55 
56  ~tree_fcn_handle (void) { }
57 
58  bool has_magic_end (void) const { return false; }
59 
60  void print (std::ostream& os, bool pr_as_read_syntax = false,
61  bool pr_orig_txt = true);
62 
63  void print_raw (std::ostream& os, bool pr_as_read_syntax = false,
64  bool pr_orig_txt = true);
65 
66  std::string name (void) const { return nm; }
67 
68  bool rvalue_ok (void) const { return true; }
69 
70  octave_value rvalue1 (int nargout = 1);
71 
72  octave_value_list rvalue (int nargout);
73 
76 
77  void accept (tree_walker& tw);
78 
79 private:
80 
81  // The name of this function handle.
83 
84  // No copying!
85 
87 
89 };
90 
91 class
93 {
94 public:
95 
96  tree_anon_fcn_handle (int l = -1, int c = -1)
97  : tree_expression (l, c), fcn (0), file_name () { }
98 
101  int l = -1, int c = -1)
102  : tree_expression (l, c),
103  fcn (new octave_user_function (sid, pl, rl, cl)),
104  file_name () { }
105 
106  ~tree_anon_fcn_handle (void) { delete fcn; }
107 
108  bool has_magic_end (void) const { return false; }
109 
110  bool rvalue_ok (void) const { return true; }
111 
112  octave_value rvalue1 (int nargout = 1);
113 
114  octave_value_list rvalue (int nargout);
115 
117  {
118  return fcn ? fcn->parameter_list () : 0;
119  }
120 
122  {
123  return fcn ? fcn->return_list () : 0;
124  }
125 
126  tree_statement_list *body (void) const
127  {
128  return fcn ? fcn->body () : 0;
129  }
130 
132  {
133  return fcn ? fcn->scope () : -1;
134  }
135 
138 
139  void accept (tree_walker& tw);
140 
141  void stash_file_name (const std::string& file) { file_name = file; }
142 
143 private:
144 
145  // The function.
147 
148  // Filename where the handle was defined.
150 
151  // No copying!
152 
154 
156 };
157 
158 #endif
octave_user_function * fcn
tree_anon_fcn_handle(tree_parameter_list *pl, tree_parameter_list *rl, tree_statement_list *cl, symbol_table::scope_id sid, int l=-1, int c=-1)
Definition: pt-fcn-handle.h:99
~tree_fcn_handle(void)
Definition: pt-fcn-handle.h:56
For example cd octave end example noindent changes the current working directory to file
Definition: dirfns.cc:120
bool rvalue_ok(void) const
Definition: pt-fcn-handle.h:68
bool has_magic_end(void) const
Definition: pt-fcn-handle.h:58
tree_fcn_handle(int l=-1, int c=-1)
Definition: pt-fcn-handle.h:50
octave_function * fcn
Definition: ov-class.cc:1743
virtual symbol_table::scope_id scope(void)
Definition: ov-fcn.h:77
tree_parameter_list * return_list(void) const
OCTAVE_EXPORT octave_value_list isdir nd deftypefn *std::string nm
Definition: utils.cc:941
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function xample nargout(@histc)
Definition: ov-usr-fcn.cc:935
static llvm::LLVMContext & context
Definition: jit-typeinfo.cc:76
void stash_file_name(const std::string &file)
the sparsity preserving column transformation such that that defines the pivoting threshold can be given in which case it defines the c
Definition: lu.cc:138
std::string name(void) const
Definition: pt-fcn-handle.h:66
symbol_table::scope_id scope(void) const
tree_statement_list * body(void) const
bool has_magic_end(void) const
tree_anon_fcn_handle(int l=-1, int c=-1)
Definition: pt-fcn-handle.h:96
tree_parameter_list * parameter_list(void) const
bool rvalue_ok(void) const
tree_fcn_handle(const std::string &n, int l=-1, int c=-1)
Definition: pt-fcn-handle.h:53
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 &)
std::string nm
Definition: pt-fcn-handle.h:82