Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #if !defined (octave_tree_fcn_handle_h)
00024 #define octave_fcn_handle_h 1
00025
00026 #include <iosfwd>
00027 #include <string>
00028
00029 #include "pt-bp.h"
00030 #include "pt-exp.h"
00031 #include "pt-misc.h"
00032 #include "pt-stmt.h"
00033 #include "symtab.h"
00034
00035 class octave_value_list;
00036
00037 class tree_walker;
00038
00039 #include "ov.h"
00040 #include "ov-usr-fcn.h"
00041 #include "symtab.h"
00042
00043 class
00044 tree_fcn_handle : public tree_expression
00045 {
00046 public:
00047
00048 tree_fcn_handle (int l = -1, int c = -1)
00049 : tree_expression (l, c), nm () { }
00050
00051 tree_fcn_handle (const std::string& n, int l = -1, int c = -1)
00052 : tree_expression (l, c), nm (n) { }
00053
00054 ~tree_fcn_handle (void) { }
00055
00056 bool has_magic_end (void) const { return false; }
00057
00058 void print (std::ostream& os, bool pr_as_read_syntax = false,
00059 bool pr_orig_txt = true);
00060
00061 void print_raw (std::ostream& os, bool pr_as_read_syntax = false,
00062 bool pr_orig_txt = true);
00063
00064 std::string name (void) const { return nm; }
00065
00066 bool rvalue_ok (void) const { return true; }
00067
00068 octave_value rvalue1 (int nargout = 1);
00069
00070 octave_value_list rvalue (int nargout);
00071
00072 tree_expression *dup (symbol_table::scope_id scope,
00073 symbol_table::context_id context) const;
00074
00075 void accept (tree_walker& tw);
00076
00077 private:
00078
00079
00080 std::string nm;
00081
00082
00083
00084 tree_fcn_handle (const tree_fcn_handle&);
00085
00086 tree_fcn_handle& operator = (const tree_fcn_handle&);
00087 };
00088
00089 class
00090 tree_anon_fcn_handle : public tree_expression
00091 {
00092 public:
00093
00094 tree_anon_fcn_handle (int l = -1, int c = -1)
00095 : tree_expression (l, c), fcn (0) { }
00096
00097 tree_anon_fcn_handle (tree_parameter_list *pl, tree_parameter_list *rl,
00098 tree_statement_list *cl, symbol_table::scope_id sid,
00099 int l = -1, int c = -1)
00100 : tree_expression (l, c),
00101 fcn (new octave_user_function (sid, pl, rl, cl)) { }
00102
00103 ~tree_anon_fcn_handle (void) { delete fcn; }
00104
00105 bool has_magic_end (void) const { return false; }
00106
00107 bool rvalue_ok (void) const { return true; }
00108
00109 octave_value rvalue1 (int nargout = 1);
00110
00111 octave_value_list rvalue (int nargout);
00112
00113 tree_parameter_list *parameter_list (void) const
00114 {
00115 return fcn ? fcn->parameter_list () : 0;
00116 }
00117
00118 tree_parameter_list *return_list (void) const
00119 {
00120 return fcn ? fcn->return_list () : 0;
00121 }
00122
00123 tree_statement_list *body (void) const
00124 {
00125 return fcn ? fcn->body () : 0;
00126 }
00127
00128 symbol_table::scope_id scope (void) const
00129 {
00130 return fcn ? fcn->scope () : -1;
00131 }
00132
00133 tree_expression *dup (symbol_table::scope_id scope,
00134 symbol_table::context_id context) const;
00135
00136 void accept (tree_walker& tw);
00137
00138 private:
00139
00140
00141 octave_user_function *fcn;
00142
00143
00144
00145 tree_anon_fcn_handle (const tree_anon_fcn_handle&);
00146
00147 tree_anon_fcn_handle& operator = (const tree_anon_fcn_handle&);
00148 };
00149
00150 #endif