Mercurial > octave
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 |
rev | line source |
---|---|
15035 | 1 /* |
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 | 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 | |
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 | 24 #define octave_tree_funcall_h 1 |
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 | 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 | 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 | |
39 tree_funcall : public tree_expression | |
40 { | |
41 public: | |
42 | |
43 tree_funcall (const octave_value& f, const octave_value_list& a, | |
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 | |
61 tree_funcall *dup (symbol_table::scope_id, | |
62 symbol_table::context_id context) const; | |
63 | |
64 octave_value rvalue1 (int nargout) | |
65 { | |
66 octave_value retval; | |
67 | |
68 const octave_value_list tmp = rvalue (nargout); | |
69 | |
70 if (! tmp.empty ()) | |
71 retval = tmp(0); | |
72 | |
73 return retval; | |
74 } | |
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 | 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. | |
88 octave_value fcn; | |
89 | |
90 // Argument list. | |
91 octave_value_list args; | |
92 | |
93 // No copying! | |
94 | |
95 tree_funcall (const tree_funcall&); | |
96 | |
97 tree_funcall& operator = (const tree_funcall&); | |
98 }; | |
99 | |
100 #endif |