annotate libinterp/parse-tree/pt-funcall.h @ 22323:bac0d6f07a3e

maint: Update copyright notices for 2016.
author John W. Eaton <jwe@octave.org>
date Wed, 17 Aug 2016 01:05:19 -0400
parents 1473547f50f5
children 34ce5be04942
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15035
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 /*
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2
22323
bac0d6f07a3e maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
3 Copyright (C) 2012-2016 John W. Eaton
15035
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
5 This file is part of Octave.
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
10 option) any later version.
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 for more details.
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, see
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 <http://www.gnu.org/licenses/>.
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21 */
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22
20791
f7084eae3318 maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents: 19697
diff changeset
23 #if ! defined (octave_tree_funcall_h)
15035
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24 #define octave_tree_funcall_h 1
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25
21244
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
26 #include "octave-config.h"
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
27
15035
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 #include "ov.h"
20940
48b2ad5ee801 maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents: 20791
diff changeset
29 #include "ovl.h"
15035
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 #include "parse.h"
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 #include "pt-exp.h"
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 // Function call. This class only represents function calls that have
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 // known functions (most useful for calls to built-in functions that
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 // are generated by the parser) and fixed argument lists, known at
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 // compile time.
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 class
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 tree_funcall : public tree_expression
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 {
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 public:
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 tree_funcall (const octave_value& f, const octave_value_list& a,
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44 int l = -1, int c = -1)
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45 : tree_expression (l, c), fcn (f), args (a)
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46 {
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
47 if (! fcn.is_function ())
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48 error ("tree_funcall: invalid function");
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49 }
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51 ~tree_funcall (void) { }
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53 bool has_magic_end (void) const { return false; }
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
54
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55 void print (std::ostream& os, bool pr_as_read_syntax = false,
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56 bool pr_orig_txt = true);
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58 void print_raw (std::ostream& os, bool pr_as_read_syntax = false,
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59 bool pr_orig_txt = true);
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61 tree_funcall *dup (symbol_table::scope_id,
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62 symbol_table::context_id context) const;
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
63
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64 octave_value rvalue1 (int nargout)
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65 {
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66 octave_value retval;
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
67
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
68 const octave_value_list tmp = rvalue (nargout);
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
69
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
70 if (! tmp.empty ())
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71 retval = tmp(0);
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73 return retval;
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74 }
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
75
18355
9ca314e79956 Allow to call superclass constructor without arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17746
diff changeset
76 octave_value_list rvalue (int nargout);
15035
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
78 octave_value function (void) const { return fcn; }
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
79
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
80 octave_value_list arguments (void) const { return args; }
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
81
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
82 void accept (tree_walker& tw);
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
83
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
84 private:
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
85
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
86 // Function to call. Error if not a valid function at time of
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
87 // construction.
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
88 octave_value fcn;
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
89
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
90 // Argument list.
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
91 octave_value_list args;
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
92
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
93 // No copying!
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
94
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
95 tree_funcall (const tree_funcall&);
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
96
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
97 tree_funcall& operator = (const tree_funcall&);
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
98 };
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
99
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
100 #endif