GNU Octave  4.0.0
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-2015 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 "ov.h"
27 #include "oct-obj.h"
28 #include "parse.h"
29 #include "pt-exp.h"
30 
31 // Function call. This class only represents function calls that have
32 // known functions (most useful for calls to built-in functions that
33 // are generated by the parser) and fixed argument lists, known at
34 // compile time.
35 
36 class
38 {
39 public:
40 
42  int l = -1, int c = -1)
43  : tree_expression (l, c), fcn (f), args (a)
44  {
45  if (! fcn.is_function ())
46  error ("tree_funcall: invalid function");
47  }
48 
49  ~tree_funcall (void) { }
50 
51  bool has_magic_end (void) const { return false; }
52 
53  void print (std::ostream& os, bool pr_as_read_syntax = false,
54  bool pr_orig_txt = true);
55 
56  void print_raw (std::ostream& os, bool pr_as_read_syntax = false,
57  bool pr_orig_txt = true);
58 
61 
62  octave_value rvalue1 (int nargout)
63  {
64  octave_value retval;
65 
66  const octave_value_list tmp = rvalue (nargout);
67 
68  if (! tmp.empty ())
69  retval = tmp(0);
70 
71  return retval;
72  }
73 
74  octave_value_list rvalue (int nargout);
75 
76  octave_value function (void) const { return fcn; }
77 
78  octave_value_list arguments (void) const { return args; }
79 
80  void accept (tree_walker& tw);
81 
82 private:
83 
84  // Function to call. Error if not a valid function at time of
85  // construction.
87 
88  // Argument list.
90 
91  // No copying!
92 
93  tree_funcall (const tree_funcall&);
94 
96 };
97 
98 #endif
octave_value rvalue1(int nargout)
Definition: pt-funcall.h:62
void error(const char *fmt,...)
Definition: error.cc:476
octave_value_list args
Definition: pt-funcall.h:89
~tree_funcall(void)
Definition: pt-funcall.h:49
tree_funcall(const octave_value &f, const octave_value_list &a, int l=-1, int c=-1)
Definition: pt-funcall.h:41
F77_RET_T const double const double * f
octave_value fcn
Definition: pt-funcall.h:86
static llvm::LLVMContext & context
Definition: jit-typeinfo.cc:76
bool has_magic_end(void) const
Definition: pt-funcall.h:51
bool empty(void) const
Definition: oct-obj.h:91
size_t context_id
Definition: symtab.h:51
tree_walker & operator=(const tree_walker &)
octave_value_list arguments(void) const
Definition: pt-funcall.h:78