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