Mercurial > octave-nkf
comparison src/pt-fcn-handle.h @ 7336:745a8299c2b5
[project @ 2007-12-28 20:56:55 by jwe]
author | jwe |
---|---|
date | Fri, 28 Dec 2007 20:56:58 +0000 |
parents | a1dbe9d80eee |
children | 71f068b22fcc |
comparison
equal
deleted
inserted
replaced
7335:58f5fab3ebe5 | 7336:745a8299c2b5 |
---|---|
28 | 28 |
29 #include "pt-bp.h" | 29 #include "pt-bp.h" |
30 #include "pt-exp.h" | 30 #include "pt-exp.h" |
31 #include "pt-misc.h" | 31 #include "pt-misc.h" |
32 #include "pt-stmt.h" | 32 #include "pt-stmt.h" |
33 #include "symtab.h" | |
33 | 34 |
34 class octave_value_list; | 35 class octave_value_list; |
35 | 36 |
36 class tree_walker; | 37 class tree_walker; |
37 | 38 |
38 #include "ov.h" | 39 #include "ov.h" |
39 #include "ov-usr-fcn.h" | 40 #include "ov-usr-fcn.h" |
41 #include "symtab.h" | |
40 | 42 |
41 class | 43 class |
42 tree_fcn_handle : public tree_expression | 44 tree_fcn_handle : public tree_expression |
43 { | 45 { |
44 public: | 46 public: |
65 | 67 |
66 octave_value rvalue (void); | 68 octave_value rvalue (void); |
67 | 69 |
68 octave_value_list rvalue (int nargout); | 70 octave_value_list rvalue (int nargout); |
69 | 71 |
70 tree_expression *dup (symbol_table *sym_tab); | 72 tree_expression *dup (symbol_table::scope_id scope); |
71 | 73 |
72 void accept (tree_walker& tw); | 74 void accept (tree_walker& tw); |
73 | 75 |
74 private: | 76 private: |
75 | 77 |
87 tree_anon_fcn_handle : public tree_expression | 89 tree_anon_fcn_handle : public tree_expression |
88 { | 90 { |
89 public: | 91 public: |
90 | 92 |
91 tree_anon_fcn_handle (int l = -1, int c = -1) | 93 tree_anon_fcn_handle (int l = -1, int c = -1) |
92 : tree_expression (l, c), fcn () { } | 94 : tree_expression (l, c), fcn (0) { } |
93 | 95 |
94 tree_anon_fcn_handle (tree_parameter_list *pl, tree_parameter_list *rl, | 96 tree_anon_fcn_handle (tree_parameter_list *pl, tree_parameter_list *rl, |
95 tree_statement_list *cl, symbol_table *st, | 97 tree_statement_list *cl, symbol_table::scope_id sid, |
96 int l = -1, int c = -1) | 98 int l = -1, int c = -1) |
97 : tree_expression (l, c), fcn (pl, rl, cl, st) { } | 99 : tree_expression (l, c), |
100 fcn (new octave_user_function (sid, pl, rl, cl)) { } | |
98 | 101 |
99 ~tree_anon_fcn_handle (void) { } | 102 ~tree_anon_fcn_handle (void) { delete fcn; } |
100 | 103 |
101 bool has_magic_end (void) const { return false; } | 104 bool has_magic_end (void) const { return false; } |
102 | 105 |
103 bool rvalue_ok (void) const { return true; } | 106 bool rvalue_ok (void) const { return true; } |
104 | 107 |
105 octave_value rvalue (void); | 108 octave_value rvalue (void); |
106 | 109 |
107 octave_value_list rvalue (int nargout); | 110 octave_value_list rvalue (int nargout); |
108 | 111 |
109 tree_parameter_list *parameter_list (void) { return fcn.parameter_list (); } | 112 tree_parameter_list *parameter_list (void) |
113 { | |
114 return fcn ? fcn->parameter_list () : 0; | |
115 } | |
110 | 116 |
111 tree_statement_list *body (void) { return fcn.body (); } | 117 tree_parameter_list *return_list (void) |
118 { | |
119 return fcn ? fcn->return_list () : 0; | |
120 } | |
112 | 121 |
113 tree_expression *dup (symbol_table *sym_tab); | 122 tree_statement_list *body (void) { return fcn ? fcn->body () : 0; } |
123 | |
124 symbol_table::scope_id scope (void) { return fcn ? fcn->scope () : -1; } | |
125 | |
126 tree_expression *dup (symbol_table::scope_id scope); | |
114 | 127 |
115 void accept (tree_walker& tw); | 128 void accept (tree_walker& tw); |
116 | 129 |
117 private: | 130 private: |
118 | 131 |
119 // The function. | 132 // The function. |
120 octave_user_function fcn; | 133 octave_user_function *fcn; |
121 | 134 |
122 // No copying! | 135 // No copying! |
123 | 136 |
124 tree_anon_fcn_handle (const tree_anon_fcn_handle&); | 137 tree_anon_fcn_handle (const tree_anon_fcn_handle&); |
125 | 138 |