4343
|
1 /* |
|
2 |
7017
|
3 Copyright (C) 2003, 2004, 2005, 2006, 2007 John W. Eaton |
4343
|
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 |
7016
|
9 Free Software Foundation; either version 3 of the License, or (at your |
|
10 option) any later version. |
4343
|
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 |
7016
|
18 along with Octave; see the file COPYING. If not, see |
|
19 <http://www.gnu.org/licenses/>. |
4343
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_tree_fcn_handle_h) |
|
24 #define octave_fcn_handle_h 1 |
|
25 |
|
26 #include <iostream> |
|
27 #include <string> |
|
28 |
|
29 #include "pt-bp.h" |
|
30 #include "pt-exp.h" |
5861
|
31 #include "pt-misc.h" |
|
32 #include "pt-stmt.h" |
4343
|
33 |
|
34 class octave_value_list; |
|
35 |
|
36 class tree_walker; |
|
37 |
|
38 #include "ov.h" |
6505
|
39 #include "ov-usr-fcn.h" |
4343
|
40 |
|
41 class |
|
42 tree_fcn_handle : public tree_expression |
|
43 { |
|
44 public: |
|
45 |
|
46 tree_fcn_handle (int l = -1, int c = -1) |
|
47 : tree_expression (l, c), nm () { } |
|
48 |
|
49 tree_fcn_handle (const std::string& n, int l = -1, int c = -1) |
|
50 : tree_expression (l, c), nm (n) { } |
|
51 |
|
52 ~tree_fcn_handle (void) { } |
|
53 |
|
54 bool has_magic_end (void) const { return false; } |
|
55 |
|
56 void print (std::ostream& os, bool pr_as_read_syntax = false, |
|
57 bool pr_orig_txt = true); |
|
58 |
|
59 void print_raw (std::ostream& os, bool pr_as_read_syntax = false, |
|
60 bool pr_orig_txt = true); |
|
61 |
5043
|
62 std::string name (void) const { return nm; } |
|
63 |
4343
|
64 bool rvalue_ok (void) const { return true; } |
|
65 |
|
66 octave_value rvalue (void); |
|
67 |
|
68 octave_value_list rvalue (int nargout); |
|
69 |
5861
|
70 tree_expression *dup (symbol_table *sym_tab); |
|
71 |
4343
|
72 void accept (tree_walker& tw); |
|
73 |
|
74 private: |
|
75 |
|
76 // The name of this function handle. |
|
77 std::string nm; |
|
78 |
|
79 // No copying! |
|
80 |
|
81 tree_fcn_handle (const tree_fcn_handle&); |
|
82 |
|
83 tree_fcn_handle& operator = (const tree_fcn_handle&); |
|
84 }; |
|
85 |
5861
|
86 class |
|
87 tree_anon_fcn_handle : public tree_expression |
|
88 { |
|
89 public: |
|
90 |
|
91 tree_anon_fcn_handle (int l = -1, int c = -1) |
6505
|
92 : tree_expression (l, c), fcn () { } |
5861
|
93 |
6505
|
94 tree_anon_fcn_handle (tree_parameter_list *pl, tree_parameter_list *rl, |
5861
|
95 tree_statement_list *cl, symbol_table *st, |
|
96 int l = -1, int c = -1) |
6505
|
97 : tree_expression (l, c), fcn (pl, rl, cl, st) { } |
5861
|
98 |
6505
|
99 ~tree_anon_fcn_handle (void) { } |
5861
|
100 |
|
101 bool has_magic_end (void) const { return false; } |
|
102 |
|
103 bool rvalue_ok (void) const { return true; } |
|
104 |
|
105 octave_value rvalue (void); |
|
106 |
|
107 octave_value_list rvalue (int nargout); |
|
108 |
6505
|
109 tree_parameter_list *parameter_list (void) { return fcn.parameter_list (); } |
5861
|
110 |
6505
|
111 tree_statement_list *body (void) { return fcn.body (); } |
5861
|
112 |
|
113 tree_expression *dup (symbol_table *sym_tab); |
|
114 |
|
115 void accept (tree_walker& tw); |
|
116 |
|
117 private: |
|
118 |
6505
|
119 // The function. |
|
120 octave_user_function fcn; |
5861
|
121 |
|
122 // No copying! |
|
123 |
|
124 tree_anon_fcn_handle (const tree_anon_fcn_handle&); |
|
125 |
|
126 tree_anon_fcn_handle& operator = (const tree_anon_fcn_handle&); |
|
127 }; |
|
128 |
4343
|
129 #endif |
|
130 |
|
131 /* |
|
132 ;;; Local Variables: *** |
|
133 ;;; mode: C++ *** |
|
134 ;;; End: *** |
|
135 */ |