Mercurial > hg > octave-avbm
comparison src/pt-fcn.cc @ 1755:3a9462b655f1
[project @ 1996-01-22 04:47:22 by jwe]
author | jwe |
---|---|
date | Mon, 22 Jan 1996 04:47:22 +0000 |
parents | a02f140ed897 |
children | effa9400766f |
comparison
equal
deleted
inserted
replaced
1754:5f1938919fdc | 1755:3a9462b655f1 |
---|---|
79 { | 79 { |
80 delete param_list; | 80 delete param_list; |
81 delete ret_list; | 81 delete ret_list; |
82 delete sym_tab; | 82 delete sym_tab; |
83 delete cmd_list; | 83 delete cmd_list; |
84 delete [] file_name; | |
85 delete [] fcn_name; | |
86 delete vr_list; | 84 delete vr_list; |
87 } | 85 } |
88 | 86 |
89 #if 0 | 87 #if 0 |
90 tree_function * | 88 tree_function * |
121 } | 119 } |
122 | 120 |
123 void | 121 void |
124 tree_function::stash_fcn_file_name (void) | 122 tree_function::stash_fcn_file_name (void) |
125 { | 123 { |
126 delete [] file_name; | 124 if (fcn_name.empty ()) |
127 file_name = fcn_name ? fcn_file_in_path (fcn_name) : 0; | 125 file_name = ""; |
126 else | |
127 file_name = fcn_file_in_path (fcn_name); | |
128 } | 128 } |
129 | 129 |
130 void | 130 void |
131 tree_function::mark_as_system_fcn_file (void) | 131 tree_function::mark_as_system_fcn_file (void) |
132 { | 132 { |
133 if (file_name) | 133 if (! file_name.empty ()) |
134 { | 134 { |
135 // We really should stash the whole path to the file we found, | 135 // We really should stash the whole path to the file we found, |
136 // when we looked it up, to avoid possible race conditions... | 136 // when we looked it up, to avoid possible race conditions... |
137 // XXX FIXME XXX | 137 // XXX FIXME XXX |
138 // | 138 // |
139 // We probably also don't need to get the library directory | 139 // We probably also don't need to get the library directory |
140 // every time, but since this function is only called when the | 140 // every time, but since this function is only called when the |
141 // function file is parsed, it probably doesn't matter that | 141 // function file is parsed, it probably doesn't matter that |
142 // much. | 142 // much. |
143 | 143 |
144 char *ff_name = fcn_file_in_path (file_name); | 144 string ff_name = fcn_file_in_path (file_name); |
145 | 145 |
146 char *system_dir = octave_fcn_file_dir (); | 146 string system_dir = octave_fcn_file_dir (); |
147 int len = strlen (system_dir); | 147 |
148 | 148 if (system_dir.compare (ff_name, 0, system_dir.length ()) == 0) |
149 if (strncmp (system_dir, ff_name, len) == 0) | |
150 system_fcn_file = 1; | 149 system_fcn_file = 1; |
151 | |
152 delete [] ff_name; | |
153 } | 150 } |
154 else | 151 else |
155 system_fcn_file = 0; | 152 system_fcn_file = 0; |
156 } | 153 } |
157 | 154 |
202 | 199 |
203 vr_list->append (val); | 200 vr_list->append (val); |
204 } | 201 } |
205 | 202 |
206 void | 203 void |
207 tree_function::stash_function_name (char *s) | 204 tree_function::stash_function_name (const string& s) |
208 { | 205 { |
209 delete [] fcn_name; | 206 fcn_name = s; |
210 fcn_name = strsave (s); | |
211 } | 207 } |
212 | 208 |
213 tree_constant | 209 tree_constant |
214 tree_function::eval (int print) | 210 tree_function::eval (int print) |
215 { | 211 { |
302 curr_sym_tab = sym_tab; | 298 curr_sym_tab = sym_tab; |
303 | 299 |
304 unwind_protect_ptr (curr_function); | 300 unwind_protect_ptr (curr_function); |
305 curr_function = this; | 301 curr_function = this; |
306 | 302 |
307 // unwind_protect_ptr (args_passed); | 303 // XXX FIXME XXX -- ??? |
304 // unwind_protect_ptr (args_passed); | |
308 | 305 |
309 args_passed = args; | 306 args_passed = args; |
310 | 307 |
311 unwind_protect_int (num_args_passed); | 308 unwind_protect_int (num_args_passed); |
312 num_args_passed = nargin; | 309 num_args_passed = nargin; |
381 tree_function::traceback_error (void) | 378 tree_function::traceback_error (void) |
382 { | 379 { |
383 if (error_state >= 0) | 380 if (error_state >= 0) |
384 error_state = -1; | 381 error_state = -1; |
385 | 382 |
386 if (fcn_name) | 383 if (fcn_name.empty ()) |
387 { | 384 { |
388 if (file_name) | 385 if (file_name.empty ()) |
389 ::error ("called from `%s' in file `%s'", fcn_name, file_name); | 386 ::error ("called from `?unknown?'"); |
387 else | |
388 ::error ("called from file `%s'", file_name.c_str ()); | |
389 } | |
390 else | |
391 { | |
392 if (file_name.empty ()) | |
393 ::error ("called from `%s'", fcn_name.c_str ()); | |
390 else | 394 else |
391 ::error ("called from `%s'", fcn_name); | 395 ::error ("called from `%s' in file `%s'", |
392 } | 396 fcn_name.c_str (), file_name.c_str ()); |
393 else | |
394 { | |
395 if (file_name) | |
396 ::error ("called from file `%s'", file_name); | |
397 else | |
398 ::error ("called from `?unknown?'"); | |
399 } | 397 } |
400 } | 398 } |
401 | 399 |
402 void | 400 void |
403 tree_function::print_code (ostream& os) | 401 tree_function::print_code (ostream& os) |
445 os << "]"; | 443 os << "]"; |
446 | 444 |
447 os << " = "; | 445 os << " = "; |
448 } | 446 } |
449 | 447 |
450 os << (fcn_name ? fcn_name : "(null)") << " "; | 448 os << (fcn_name.empty () ? string ("(empty)") : fcn_name) << " "; |
451 | 449 |
452 if (param_list) | 450 if (param_list) |
453 { | 451 { |
454 int len = param_list->length (); | 452 int len = param_list->length (); |
455 if (len > 0) | 453 if (len > 0) |