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-funcall.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2012-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_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 
33 // Function call. This class only represents function calls that have
34 // known functions (most useful for calls to built-in functions that
35 // are generated by the parser) and fixed argument lists, known at
36 // compile time.
37 
38 class
40 {
41 public:
42 
44  int l = -1, int c = -1)
45  : tree_expression (l, c), fcn (f), args (a)
46  {
47  if (! fcn.is_function ())
48  error ("tree_funcall: invalid function");
49  }
50 
51  ~tree_funcall (void) { }
52 
53  bool has_magic_end (void) const { return false; }
54 
55  void print (std::ostream& os, bool pr_as_read_syntax = false,
56  bool pr_orig_txt = true);
57 
58  void print_raw (std::ostream& os, bool pr_as_read_syntax = false,
59  bool pr_orig_txt = true);
60 
63 
65  {
67 
68  const octave_value_list tmp = rvalue (nargout);
69 
70  if (! tmp.empty ())
71  retval = tmp(0);
72 
73  return retval;
74  }
75 
76  octave_value_list rvalue (int nargout);
77 
78  octave_value function (void) const { return fcn; }
79 
80  octave_value_list arguments (void) const { return args; }
81 
82  void accept (tree_walker& tw);
83 
84 private:
85 
86  // Function to call. Error if not a valid function at time of
87  // construction.
89 
90  // Argument list.
92 
93  // No copying!
94 
95  tree_funcall (const tree_funcall&);
96 
98 };
99 
100 #endif
octave_value rvalue1(int nargout)
Definition: pt-funcall.h:64
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
void error(const char *fmt,...)
Definition: error.cc:570
octave_value_list args
Definition: pt-funcall.h:91
octave_function * fcn
Definition: ov-class.cc:1743
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:398
~tree_funcall(void)
Definition: pt-funcall.h:51
tree_funcall(const octave_value &f, const octave_value_list &a, int l=-1, int c=-1)
Definition: pt-funcall.h:43
JNIEnv void * args
Definition: ov-java.cc:67
bool is_function(void) const
Definition: ov-fcn.h:60
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
octave_value fcn
Definition: pt-funcall.h:88
static llvm::LLVMContext & context
Definition: jit-typeinfo.cc:76
double tmp
Definition: data.cc:6300
octave_value retval
Definition: data.cc:6294
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
bool has_magic_end(void) const
Definition: pt-funcall.h:53
bool empty(void) const
Definition: ovl.h:98
tree_walker & operator=(const tree_walker &)
octave_value_list arguments(void) const
Definition: pt-funcall.h:80