GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
pt-funcall.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2012-2018 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
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License 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 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if ! defined (octave_tree_funcall_h)
24 #define octave_tree_funcall_h 1
25 
26 #include "octave-config.h"
27 
28 #include "ov.h"
29 #include "ovl.h"
30 #include "parse.h"
31 #include "pt-exp.h"
32 #include "pt-walk.h"
33 
34 namespace octave
35 {
36  // Function call. This class only represents function calls that have
37  // known functions (most useful for calls to built-in functions that
38  // are generated by the parser) and fixed argument lists, known at
39  // compile time.
40 
42  {
43  public:
44 
46  int l = -1, int c = -1)
47  : tree_expression (l, c), m_fcn (f), m_args (a)
48  {
49  if (! m_fcn.is_function ())
50  error ("tree_funcall: invalid function");
51  }
52 
53  // No copying!
54 
55  tree_funcall (const tree_funcall&) = delete;
56 
57  tree_funcall& operator = (const tree_funcall&) = delete;
58 
59  ~tree_funcall (void) = default;
60 
61  bool has_magic_end (void) const { return false; }
62 
63  void print (std::ostream& os, bool pr_as_read_syntax = false,
64  bool pr_orig_txt = true);
65 
66  void print_raw (std::ostream& os, bool pr_as_read_syntax = false,
67  bool pr_orig_txt = true);
68 
69  tree_funcall * dup (symbol_scope& scope) const;
70 
71  octave_value function (void) const { return m_fcn; }
72 
73  octave_value_list arguments (void) const { return m_args; }
74 
75  void accept (tree_walker& tw)
76  {
77  tw.visit_funcall (*this);
78  }
79 
80  private:
81 
82  // Function to call. Error if not a valid function at time of
83  // construction.
85 
86  // Argument list.
88  };
89 }
90 
91 #if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS)
92 
93 OCTAVE_DEPRECATED (4.4, "use 'octave::tree_funcall' instead")
94 typedef octave::tree_funcall tree_funcall;
95 
96 #endif
97 
98 #endif
tree_funcall(const octave_value &f, const octave_value_list &a, int l=-1, int c=-1)
Definition: pt-funcall.h:45
void print(std::ostream &os, bool pr_as_read_syntax=false, bool pr_orig_txt=true)
Definition: pt-funcall.cc:36
octave_value_list arguments(void) const
Definition: pt-funcall.h:73
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 const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE * f
void error(const char *fmt,...)
Definition: error.cc:578
nd example oindent opens the file binary numeric values will be read assuming they are stored in IEEE format with the least significant bit and then converted to the native representation Opening a file that is already open simply opens it again and returns a separate file id It is not an error to open a file several though writing to the same file through several different file ids may produce unexpected results The possible values of text mode reading and writing automatically converts linefeeds to the appropriate line end character for the you may append a you must also open the file in binary mode The parameter conversions are currently only supported for and permissions will be set to and then everything is written in a single operation This is very efficient and improves performance c
Definition: file-io.cc:587
~tree_funcall(void)=default
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
Definition: cellfun.cc:400
octave_value_list m_args
Definition: pt-funcall.h:87
void print_raw(std::ostream &os, bool pr_as_read_syntax=false, bool pr_orig_txt=true)
Definition: pt-funcall.cc:43
tree_funcall & operator=(const tree_funcall &)=delete
virtual void visit_funcall(tree_funcall &)=0
octave_value m_fcn
Definition: pt-funcall.h:84
tree_funcall * dup(symbol_scope &scope) const
Definition: pt-funcall.cc:71
bool is_function(void) const
Definition: ov.h:758
bool has_magic_end(void) const
Definition: pt-funcall.h:61
void accept(tree_walker &tw)
Definition: pt-funcall.h:75
octave::stream os
Definition: file-io.cc:627