comparison src/pt-fcn.h @ 2124:97a566037a75

[project @ 1996-05-12 07:16:36 by jwe]
author jwe
date Sun, 12 May 1996 07:16:36 +0000
parents bfb775fb6fe8
children 0a2e2e64f813
comparison
equal deleted inserted replaced
2123:ee55d81f585a 2124:97a566037a75
35 35
36 class tree_parameter_list; 36 class tree_parameter_list;
37 class tree_statement_list; 37 class tree_statement_list;
38 class tree_va_return_list; 38 class tree_va_return_list;
39 39
40 class tree_walker;
41
40 #include "oct-obj.h" 42 #include "oct-obj.h"
41 #include "symtab.h" 43 #include "symtab.h"
42 #include "pt-fvc.h" 44 #include "pt-fvc.h"
43 45
44 // User defined functions. 46 // User defined functions.
45 47
46 class 48 class
47 tree_function : public tree_fvc 49 tree_function : public tree_fvc
48 { 50 {
51 public:
52
53 tree_function (int l = -1, int c = -1) : tree_fvc (l, c)
54 { init (); }
55
56 tree_function (tree_statement_list *cl, symbol_table *st,
57 int l = -1, int c = -1)
58 : tree_fvc (l, c)
59 {
60 init ();
61 sym_tab = st;
62 cmd_list = cl;
63 install_nargin_and_nargout ();
64 }
65
66 ~tree_function (void);
67
68 // tree_function *define (tree_statement_list *t);
69 tree_function *define_param_list (tree_parameter_list *t);
70 tree_function *define_ret_list (tree_parameter_list *t);
71
72 void stash_fcn_file_name (void);
73
74 void stash_fcn_file_time (time_t t)
75 { t_parsed = t; }
76
77 string fcn_file_name (void)
78 { return file_name; }
79
80 time_t time_parsed (void)
81 { return t_parsed; }
82
83 void mark_as_system_fcn_file (void);
84
85 bool is_system_fcn_file (void) const
86 { return system_fcn_file; }
87
88 bool takes_varargs (void) const;
89
90 void octave_va_start (void)
91 { curr_va_arg_number = num_named_args; }
92
93 octave_value octave_va_arg (void);
94
95 octave_value_list octave_all_va_args (void);
96
97 bool takes_var_return (void) const;
98
99 void octave_vr_val (const octave_value& val);
100
101 void stash_function_name (const string& s);
102
103 string function_name (void)
104 { return fcn_name; }
105
106 octave_value eval (bool print);
107
108 octave_value_list eval (bool print, int nargout, const octave_value_list& args);
109
110 void traceback_error (void);
111
112 tree_parameter_list *parameter_list (void) { return param_list; }
113
114 tree_parameter_list *return_list (void) { return ret_list; }
115
116 tree_statement_list *body (void) { return cmd_list; }
117
118 void accept (tree_walker& tw);
119
49 private: 120 private:
121
122 // List of arguments for this function. These are local variables.
123 tree_parameter_list *param_list;
124
125 // List of parameters we return. These are also local variables in
126 // this function.
127 tree_parameter_list *ret_list;
128
129 // The list of commands that make up the body of this function.
130 tree_statement_list *cmd_list;
131
132 // The local symbol table for this function.
133 symbol_table *sym_tab;
134
135 // Used to keep track of recursion depth.
136 int call_depth;
137
138 // The name of the file we parsed
139 string file_name;
140
141 // The name of the function.
142 string fcn_name;
143
144 // The time the file was parsed.
145 time_t t_parsed;
146
147 // True if this function came from a file that is considered to be a
148 // system function. This affects whether we check the time stamp
149 // on the file to see if it has changed.
150 bool system_fcn_file;
151
152 // The number of arguments that have names.
153 int num_named_args;
154
155 // The values that were passed as arguments.
156 octave_value_list args_passed;
157
158 // The number of arguments passed in.
159 int num_args_passed;
160
161 // Used to keep track of the current offset into the list of va_args.
162 int curr_va_arg_number;
163
164 // The list of return values when an unspecified number can be
165 // returned.
166 tree_va_return_list *vr_list;
167
168 // The symbol record for nargin in the local symbol table.
169 symbol_record *nargin_sr;
170
171 // The symbol record for nargout in the local symbol table.
172 symbol_record *nargout_sr;
173
174 void print_code_function_header (void);
175 void print_code_function_trailer (void);
176
50 void install_nargin_and_nargout (void); 177 void install_nargin_and_nargout (void);
51 178
52 void bind_nargin_and_nargout (int nargin, int nargout); 179 void bind_nargin_and_nargout (int nargin, int nargout);
53 180
54 void init (void) 181 void init (void)
63 num_named_args = 0; 190 num_named_args = 0;
64 num_args_passed = 0; 191 num_args_passed = 0;
65 curr_va_arg_number = 0; 192 curr_va_arg_number = 0;
66 vr_list = 0; 193 vr_list = 0;
67 } 194 }
68
69 public:
70 tree_function (int l = -1, int c = -1) : tree_fvc (l, c)
71 { init (); }
72
73 tree_function (tree_statement_list *cl, symbol_table *st,
74 int l = -1, int c = -1)
75 : tree_fvc (l, c)
76 {
77 init ();
78 sym_tab = st;
79 cmd_list = cl;
80 install_nargin_and_nargout ();
81 }
82
83 ~tree_function (void);
84
85 // tree_function *define (tree_statement_list *t);
86 tree_function *define_param_list (tree_parameter_list *t);
87 tree_function *define_ret_list (tree_parameter_list *t);
88
89 void stash_fcn_file_name (void);
90
91 void stash_fcn_file_time (time_t t)
92 { t_parsed = t; }
93
94 string fcn_file_name (void)
95 { return file_name; }
96
97 time_t time_parsed (void)
98 { return t_parsed; }
99
100 void mark_as_system_fcn_file (void);
101
102 bool is_system_fcn_file (void) const
103 { return system_fcn_file; }
104
105 bool takes_varargs (void) const;
106
107 void octave_va_start (void)
108 { curr_va_arg_number = num_named_args; }
109
110 octave_value octave_va_arg (void);
111
112 octave_value_list octave_all_va_args (void);
113
114 bool takes_var_return (void) const;
115
116 void octave_vr_val (const octave_value& val);
117
118 void stash_function_name (const string& s);
119
120 string function_name (void)
121 { return fcn_name; }
122
123 octave_value eval (bool print);
124
125 octave_value_list eval (bool print, int nargout, const octave_value_list& args);
126
127 void traceback_error (void);
128
129 void print_code (ostream& os);
130
131 private:
132 int call_depth;
133 tree_parameter_list *param_list;
134 tree_parameter_list *ret_list;
135 symbol_table *sym_tab;
136 tree_statement_list *cmd_list;
137 string file_name;
138 string fcn_name;
139 time_t t_parsed;
140 bool system_fcn_file;
141 int num_named_args;
142 octave_value_list args_passed;
143 int num_args_passed;
144 int curr_va_arg_number;
145 tree_va_return_list *vr_list;
146 symbol_record *nargin_sr;
147 symbol_record *nargout_sr;
148
149 void print_code_function_header (void);
150 void print_code_function_header (ostream& os);
151
152 void print_code_function_trailer (void);
153 void print_code_function_trailer (ostream& os);
154 }; 195 };
155 196
156 #endif 197 #endif
157 198
158 /* 199 /*