1
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
1
|
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 |
1315
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
1
|
20 |
|
21 */ |
|
22 |
240
|
23 #ifdef HAVE_CONFIG_H |
1192
|
24 #include <config.h> |
1
|
25 #endif |
|
26 |
1468
|
27 #include <cstdio> |
1343
|
28 #include <cstring> |
605
|
29 |
1728
|
30 #include <string> |
|
31 |
2926
|
32 #include "file-stat.h" |
|
33 #include "oct-env.h" |
|
34 #include "glob-match.h" |
1755
|
35 #include "str-vec.h" |
|
36 |
2492
|
37 #include <defaults.h> |
1352
|
38 #include "defun.h" |
|
39 #include "dirfns.h" |
|
40 #include "error.h" |
2205
|
41 #include "gripes.h" |
1352
|
42 #include "help.h" |
3165
|
43 #include "input.h" |
1352
|
44 #include "lex.h" |
2926
|
45 #include "oct-map.h" |
|
46 #include "oct-obj.h" |
|
47 #include "ov.h" |
605
|
48 #include "pager.h" |
1352
|
49 #include "parse.h" |
2926
|
50 #include "symtab.h" |
2205
|
51 #include "toplev.h" |
1352
|
52 #include "unwind-prot.h" |
1
|
53 #include "utils.h" |
1352
|
54 #include "variables.h" |
2205
|
55 |
|
56 // Should Octave always check to see if function files have changed |
|
57 // since they were last compiled? |
2806
|
58 static int Vignore_function_time_stamp; |
2205
|
59 |
1
|
60 // Symbol table for symbols at the top level. |
581
|
61 symbol_table *top_level_sym_tab = 0; |
1
|
62 |
|
63 // Symbol table for the current scope. |
581
|
64 symbol_table *curr_sym_tab = 0; |
1
|
65 |
|
66 // Symbol table for global symbols. |
581
|
67 symbol_table *global_sym_tab = 0; |
1
|
68 |
593
|
69 // Initialization. |
|
70 |
|
71 // Create the initial symbol tables and set the current scope at the |
|
72 // top level. |
|
73 |
195
|
74 void |
|
75 initialize_symbol_tables (void) |
|
76 { |
581
|
77 if (! global_sym_tab) |
3005
|
78 global_sym_tab = new symbol_table (2048); |
195
|
79 |
581
|
80 if (! top_level_sym_tab) |
3005
|
81 top_level_sym_tab = new symbol_table (4096); |
195
|
82 |
|
83 curr_sym_tab = top_level_sym_tab; |
|
84 } |
|
85 |
593
|
86 // Attributes of variables and functions. |
|
87 |
|
88 // Is this variable a builtin? |
|
89 |
1827
|
90 bool |
1755
|
91 is_builtin_variable (const string& name) |
593
|
92 { |
2856
|
93 symbol_record *sr = global_sym_tab->lookup (name); |
593
|
94 return (sr && sr->is_builtin_variable ()); |
|
95 } |
|
96 |
|
97 // Is this a text-style function? |
|
98 |
1827
|
99 bool |
1755
|
100 is_text_function_name (const string& s) |
593
|
101 { |
|
102 symbol_record *sr = global_sym_tab->lookup (s); |
|
103 return (sr && sr->is_text_function ()); |
|
104 } |
|
105 |
3355
|
106 // Is this a built-in function? |
2294
|
107 |
|
108 bool |
|
109 is_builtin_function_name (const string& s) |
|
110 { |
|
111 symbol_record *sr = global_sym_tab->lookup (s); |
|
112 return (sr && sr->is_builtin_function ()); |
|
113 } |
|
114 |
|
115 // Is this a mapper function? |
|
116 |
|
117 bool |
|
118 is_mapper_function_name (const string& s) |
|
119 { |
|
120 symbol_record *sr = global_sym_tab->lookup (s); |
|
121 return (sr && sr->is_mapper_function ()); |
|
122 } |
|
123 |
593
|
124 // Is this function globally in this scope? |
|
125 |
1827
|
126 bool |
1755
|
127 is_globally_visible (const string& name) |
593
|
128 { |
2856
|
129 symbol_record *sr = curr_sym_tab->lookup (name); |
593
|
130 return (sr && sr->is_linked_to_global ()); |
|
131 } |
|
132 |
2086
|
133 // Is this octave_value a valid function? |
593
|
134 |
2975
|
135 octave_function * |
3178
|
136 is_valid_function (const string& fcn_name, const string& warn_for, bool warn) |
593
|
137 { |
2975
|
138 octave_function *ans = 0; |
593
|
139 |
|
140 symbol_record *sr = 0; |
1755
|
141 |
|
142 if (! fcn_name.empty ()) |
593
|
143 sr = lookup_by_name (fcn_name); |
|
144 |
|
145 if (sr) |
2975
|
146 { |
|
147 octave_value tmp = sr->def (); |
|
148 ans = tmp.function_value (true); |
|
149 } |
593
|
150 |
|
151 if (! sr || ! ans || ! sr->is_function ()) |
|
152 { |
|
153 if (warn) |
|
154 error ("%s: the symbol `%s' is not valid as a function", |
1755
|
155 warn_for.c_str (), fcn_name.c_str ()); |
593
|
156 ans = 0; |
|
157 } |
|
158 |
|
159 return ans; |
|
160 } |
|
161 |
2975
|
162 octave_function * |
3178
|
163 is_valid_function (const octave_value& arg, const string& warn_for, bool warn) |
|
164 { |
|
165 octave_function *ans = 0; |
|
166 |
|
167 string fcn_name; |
|
168 |
|
169 if (arg.is_string ()) |
|
170 fcn_name = arg.string_value (); |
|
171 |
|
172 if (! error_state) |
|
173 ans = is_valid_function (fcn_name, warn_for, warn); |
|
174 else if (warn) |
|
175 error ("%s: expecting function name as argument", warn_for.c_str ()); |
|
176 |
|
177 return ans; |
|
178 } |
|
179 |
|
180 octave_function * |
2796
|
181 extract_function (const octave_value& arg, const string& warn_for, |
|
182 const string& fname, const string& header, |
|
183 const string& trailer) |
|
184 { |
2975
|
185 octave_function *retval = 0; |
2796
|
186 |
|
187 retval = is_valid_function (arg, warn_for, 0); |
|
188 |
|
189 if (! retval) |
|
190 { |
|
191 string s = arg.string_value (); |
|
192 |
|
193 string cmd = header; |
|
194 cmd.append (s); |
|
195 cmd.append (trailer); |
|
196 |
|
197 if (! error_state) |
|
198 { |
|
199 int parse_status; |
|
200 |
2898
|
201 eval_string (cmd, true, parse_status); |
2796
|
202 |
|
203 if (parse_status == 0) |
|
204 { |
|
205 retval = is_valid_function (fname, warn_for, 0); |
|
206 |
|
207 if (! retval) |
|
208 { |
|
209 error ("%s: `%s' is not valid as a function", |
|
210 warn_for.c_str (), fname.c_str ()); |
|
211 return retval; |
|
212 } |
|
213 } |
|
214 else |
|
215 error ("%s: `%s' is not valid as a function", |
|
216 warn_for.c_str (), fname.c_str ()); |
|
217 } |
|
218 else |
|
219 error ("%s: expecting first argument to be a string", |
|
220 warn_for.c_str ()); |
|
221 } |
|
222 |
|
223 return retval; |
|
224 } |
|
225 |
2921
|
226 string_vector |
|
227 get_struct_elts (const string& text) |
|
228 { |
|
229 int n = 1; |
|
230 |
|
231 size_t pos = 0; |
|
232 |
|
233 size_t len = text.length (); |
|
234 |
|
235 while ((pos = text.find ('.', pos)) != NPOS) |
|
236 { |
|
237 if (++pos == len) |
|
238 break; |
|
239 |
|
240 n++; |
|
241 } |
|
242 |
|
243 string_vector retval (n); |
|
244 |
|
245 pos = 0; |
|
246 |
|
247 for (int i = 0; i < n; i++) |
|
248 { |
|
249 size_t len = text.find ('.', pos); |
|
250 |
|
251 if (len != NPOS) |
|
252 len -= pos; |
|
253 |
|
254 retval[i] = text.substr (pos, len); |
|
255 |
|
256 if (len != NPOS) |
|
257 pos += len + 1; |
|
258 } |
|
259 |
|
260 return retval; |
|
261 } |
|
262 |
|
263 string_vector |
|
264 generate_struct_completions (const string& text, string& prefix, string& hint) |
|
265 { |
|
266 string_vector names; |
|
267 |
|
268 size_t pos = text.rfind ('.'); |
|
269 |
|
270 string id; |
|
271 string_vector elts; |
|
272 |
|
273 if (pos == NPOS) |
|
274 { |
|
275 hint = text; |
|
276 prefix = text; |
|
277 elts.resize (1, text); |
|
278 } |
|
279 else |
|
280 { |
|
281 if (pos == text.length ()) |
|
282 hint = ""; |
|
283 else |
|
284 hint = text.substr (pos+1); |
|
285 |
|
286 prefix = text.substr (0, pos); |
|
287 |
|
288 elts = get_struct_elts (prefix); |
|
289 } |
|
290 |
|
291 id = elts[0]; |
|
292 |
|
293 symbol_record *sr = curr_sym_tab->lookup (id); |
|
294 |
|
295 if (! sr) |
|
296 sr = global_sym_tab->lookup (id); |
|
297 |
|
298 if (sr && sr->is_defined ()) |
|
299 { |
2975
|
300 octave_value tmp = sr->def (); |
2921
|
301 |
2963
|
302 // XXX FIXME XXX -- make this work for all types that can do |
|
303 // structure reference operations. |
2975
|
304 if (tmp.is_map ()) |
2921
|
305 { |
|
306 for (int i = 1; i < elts.length (); i++) |
|
307 { |
2975
|
308 tmp = tmp.do_struct_elt_index_op (elts[i], true); |
2921
|
309 |
2975
|
310 if (! tmp.is_map ()) |
2921
|
311 break; |
|
312 } |
|
313 |
2975
|
314 if (tmp.is_map ()) |
2921
|
315 { |
2975
|
316 Octave_map m = tmp.map_value (); |
2921
|
317 |
|
318 names = m.make_name_list (); |
|
319 } |
|
320 } |
|
321 } |
|
322 |
|
323 return names; |
|
324 } |
|
325 |
|
326 bool |
|
327 looks_like_struct (const string& text) |
|
328 { |
|
329 bool retval = true; |
|
330 |
|
331 string_vector elts = get_struct_elts (text); |
|
332 |
|
333 string id = elts[0]; |
|
334 |
|
335 symbol_record *sr = curr_sym_tab->lookup (id); |
|
336 |
|
337 if (! sr) |
|
338 sr = global_sym_tab->lookup (id); |
|
339 |
|
340 if (sr && sr->is_defined ()) |
|
341 { |
2975
|
342 octave_value tmp = sr->def (); |
2921
|
343 |
2963
|
344 // XXX FIXME XXX -- should this work for all types that can do |
|
345 // structure reference operations? |
|
346 |
2975
|
347 if (tmp.is_map ()) |
2921
|
348 { |
|
349 for (int i = 1; i < elts.length (); i++) |
|
350 { |
2975
|
351 tmp = tmp.do_struct_elt_index_op (elts[i], true); |
2921
|
352 |
2975
|
353 if (! tmp.is_map ()) |
2921
|
354 { |
|
355 retval = false; |
|
356 break; |
|
357 } |
|
358 } |
|
359 } |
|
360 else |
|
361 retval = false; |
|
362 } |
|
363 else |
|
364 retval = false; |
|
365 |
|
366 return retval; |
|
367 } |
2796
|
368 |
1957
|
369 DEFUN (is_global, args, , |
3361
|
370 "-*- texinfo -*-\n\ |
|
371 @deftypefn {Built-in Function} {} is_global (@var{name})\n\ |
|
372 Return 1 if @var{name} is globally visible. Otherwise, return 0. For\n\ |
|
373 example,\n\ |
|
374 \n\ |
|
375 @example\n\ |
|
376 @group\n\ |
|
377 global x\n\ |
|
378 is_global (\"x\")\n\ |
|
379 @result{} 1\n\ |
|
380 @end group\n\ |
|
381 @end example\n\ |
|
382 @end deftypefn") |
593
|
383 { |
2086
|
384 octave_value_list retval = 0.0; |
593
|
385 |
712
|
386 int nargin = args.length (); |
|
387 |
|
388 if (nargin != 1) |
593
|
389 { |
|
390 print_usage ("is_global"); |
|
391 return retval; |
|
392 } |
|
393 |
1755
|
394 string name = args(0).string_value (); |
593
|
395 |
636
|
396 if (error_state) |
|
397 { |
|
398 error ("is_global: expecting string argument"); |
|
399 return retval; |
|
400 } |
|
401 |
2856
|
402 symbol_record *sr = curr_sym_tab->lookup (name); |
593
|
403 |
2800
|
404 retval = static_cast<double> (sr && sr->is_linked_to_global ()); |
593
|
405 |
|
406 return retval; |
|
407 } |
|
408 |
1957
|
409 DEFUN (exist, args, , |
3361
|
410 "-*- texinfo -*-\n\ |
|
411 @deftypefn {Built-in Function} {} exist (@var{name})\n\ |
|
412 Return 1 if the name exists as a variable, 2 if the name (after\n\ |
|
413 appending @samp{.m}) is a function file in the path, 3 if the name is a\n\ |
|
414 @samp{.oct} file in the path, or 5 if the name is a built-in function.\n\ |
|
415 Otherwise, return 0.\n\ |
1564
|
416 \n\ |
3361
|
417 This function also returns 2 if a regular file called @var{name}\n\ |
|
418 exists in Octave's @code{LOADPATH}. If you want information about\n\ |
|
419 other types of files, you should use some combination of the functions\n\ |
|
420 @code{file_in_path} and @code{stat} instead.\n\ |
|
421 @end deftypefn") |
593
|
422 { |
2086
|
423 octave_value_list retval; |
593
|
424 |
712
|
425 int nargin = args.length (); |
|
426 |
|
427 if (nargin != 1) |
593
|
428 { |
|
429 print_usage ("exist"); |
|
430 return retval; |
|
431 } |
|
432 |
1755
|
433 string name = args(0).string_value (); |
593
|
434 |
636
|
435 if (error_state) |
|
436 { |
|
437 error ("exist: expecting string argument"); |
|
438 return retval; |
|
439 } |
|
440 |
1755
|
441 string struct_elts; |
2790
|
442 string symbol_name = name; |
1755
|
443 |
|
444 size_t pos = name.find ('.'); |
|
445 |
2790
|
446 if (pos != NPOS && pos > 0) |
1277
|
447 { |
1755
|
448 struct_elts = name.substr (pos+1); |
2790
|
449 symbol_name = name.substr (0, pos); |
1277
|
450 } |
|
451 |
2856
|
452 symbol_record *sr = curr_sym_tab->lookup (symbol_name); |
3238
|
453 if (! (sr && (sr->is_defined () |
|
454 || (curr_sym_tab != top_level_sym_tab)))) |
2856
|
455 sr = global_sym_tab->lookup (symbol_name); |
593
|
456 |
|
457 retval = 0.0; |
|
458 |
|
459 if (sr && sr->is_variable () && sr->is_defined ()) |
1277
|
460 { |
2390
|
461 if (struct_elts.empty () || sr->is_map_element (struct_elts)) |
|
462 retval = 1.0; |
1277
|
463 } |
1421
|
464 else if (sr && sr->is_builtin_function ()) |
|
465 { |
|
466 retval = 5.0; |
|
467 } |
|
468 else if (sr && sr->is_user_function ()) |
|
469 { |
|
470 retval = 2.0; |
|
471 } |
593
|
472 else |
|
473 { |
1755
|
474 string path = fcn_file_in_path (name); |
|
475 |
|
476 if (path.length () > 0) |
593
|
477 { |
|
478 retval = 2.0; |
|
479 } |
|
480 else |
|
481 { |
1421
|
482 path = oct_file_in_path (name); |
1755
|
483 |
|
484 if (path.length () > 0) |
1421
|
485 { |
|
486 retval = 3.0; |
|
487 } |
|
488 else |
|
489 { |
3096
|
490 string file_name = file_in_path (name, ""); |
1766
|
491 |
3096
|
492 if (! file_name.empty ()) |
|
493 { |
|
494 file_stat fs (file_name); |
|
495 |
|
496 if (fs && fs.is_reg ()) |
|
497 retval = 2.0; |
|
498 } |
1421
|
499 } |
593
|
500 } |
|
501 } |
|
502 |
|
503 return retval; |
|
504 } |
|
505 |
581
|
506 // Is there a corresponding function file that is newer than the |
|
507 // symbol definition? |
|
508 |
2926
|
509 static bool |
1
|
510 symbol_out_of_date (symbol_record *sr) |
|
511 { |
2926
|
512 bool retval = false; |
195
|
513 |
2926
|
514 if (Vignore_function_time_stamp != 2 && sr) |
1
|
515 { |
2975
|
516 octave_value ans = sr->def (); |
|
517 |
3022
|
518 octave_function *tmp = ans.function_value (true); |
2975
|
519 |
3022
|
520 if (tmp) |
|
521 { |
|
522 string ff = tmp->fcn_file_name (); |
1755
|
523 |
3022
|
524 if (! (ff.empty () |
|
525 || (Vignore_function_time_stamp |
|
526 && tmp->is_system_fcn_file ()))) |
|
527 { |
3165
|
528 if (tmp->time_checked () < Vlast_prompt_time) |
|
529 { |
|
530 time_t tp = tmp->time_parsed (); |
2975
|
531 |
3325
|
532 string fname; |
|
533 |
|
534 if (tmp->is_dld_function ()) |
|
535 fname = ff; |
|
536 else |
|
537 fname = fcn_file_in_path (ff); |
1755
|
538 |
3255
|
539 tmp->mark_fcn_file_up_to_date (octave_time ()); |
3165
|
540 |
|
541 file_stat fs (fname); |
3022
|
542 |
3165
|
543 if (fs && fs.is_newer (tp)) |
|
544 retval = true; |
|
545 } |
1
|
546 } |
|
547 } |
|
548 } |
2926
|
549 |
|
550 return retval; |
1
|
551 } |
|
552 |
1827
|
553 bool |
2856
|
554 lookup (symbol_record *sym_rec, bool exec_script) |
581
|
555 { |
1827
|
556 bool script_executed = false; |
581
|
557 |
|
558 if (! sym_rec->is_linked_to_global ()) |
|
559 { |
|
560 if (sym_rec->is_defined ()) |
|
561 { |
|
562 if (sym_rec->is_function () && symbol_out_of_date (sym_rec)) |
1271
|
563 script_executed = load_fcn_from_file (sym_rec, exec_script); |
581
|
564 } |
|
565 else if (! sym_rec->is_formal_parameter ()) |
|
566 { |
|
567 link_to_builtin_or_function (sym_rec); |
1271
|
568 |
581
|
569 if (! sym_rec->is_defined ()) |
1271
|
570 script_executed = load_fcn_from_file (sym_rec, exec_script); |
581
|
571 else if (sym_rec->is_function () && symbol_out_of_date (sym_rec)) |
1271
|
572 script_executed = load_fcn_from_file (sym_rec, exec_script); |
581
|
573 } |
|
574 } |
|
575 |
1271
|
576 return script_executed; |
581
|
577 } |
|
578 |
|
579 // Get the symbol record for the given name that is visible in the |
|
580 // current scope. Reread any function definitions that appear to be |
|
581 // out of date. If a function is available in a file but is not |
|
582 // currently loaded, this will load it and insert the name in the |
|
583 // current symbol table. |
|
584 |
|
585 symbol_record * |
2856
|
586 lookup_by_name (const string& nm, bool exec_script) |
581
|
587 { |
2856
|
588 symbol_record *sym_rec = curr_sym_tab->lookup (nm, true); |
581
|
589 |
|
590 lookup (sym_rec, exec_script); |
|
591 |
|
592 return sym_rec; |
|
593 } |
|
594 |
2849
|
595 octave_value |
|
596 get_global_value (const string& nm) |
|
597 { |
|
598 octave_value retval; |
|
599 |
|
600 symbol_record *sr = global_sym_tab->lookup (nm); |
|
601 |
|
602 if (sr) |
|
603 { |
2975
|
604 octave_value sr_def = sr->def (); |
2849
|
605 |
2975
|
606 if (sr_def.is_undefined ()) |
2849
|
607 error ("get_global_by_name: undefined symbol `%s'", nm.c_str ()); |
3088
|
608 else |
|
609 retval = sr_def; |
2849
|
610 } |
|
611 else |
|
612 error ("get_global_by_name: unknown symbol `%s'", nm.c_str ()); |
|
613 |
|
614 return retval; |
|
615 } |
|
616 |
|
617 void |
|
618 set_global_value (const string& nm, const octave_value& val) |
|
619 { |
2856
|
620 symbol_record *sr = global_sym_tab->lookup (nm, true); |
2849
|
621 |
|
622 if (sr) |
|
623 sr->define (val); |
|
624 else |
|
625 panic_impossible (); |
|
626 } |
|
627 |
593
|
628 // Variable values. |
195
|
629 |
581
|
630 // Look for the given name in the global symbol table. If it refers |
|
631 // to a string, return a new copy. If not, return 0; |
|
632 |
1755
|
633 string |
|
634 builtin_string_variable (const string& name) |
1
|
635 { |
2856
|
636 symbol_record *sr = global_sym_tab->lookup (name); |
195
|
637 |
1271
|
638 // It is a prorgramming error to look for builtins that aren't. |
195
|
639 |
529
|
640 assert (sr); |
195
|
641 |
1755
|
642 string retval; |
1
|
643 |
2975
|
644 octave_value val = sr->def (); |
195
|
645 |
2975
|
646 if (! error_state && val.is_string ()) |
|
647 retval = val.string_value (); |
1
|
648 |
|
649 return retval; |
|
650 } |
|
651 |
581
|
652 // Look for the given name in the global symbol table. If it refers |
1504
|
653 // to a real scalar, place the value in d and return 1. Otherwise, |
|
654 // return 0. |
581
|
655 |
1
|
656 int |
1755
|
657 builtin_real_scalar_variable (const string& name, double& d) |
1
|
658 { |
1504
|
659 int status = 0; |
2856
|
660 symbol_record *sr = global_sym_tab->lookup (name); |
195
|
661 |
1271
|
662 // It is a prorgramming error to look for builtins that aren't. |
195
|
663 |
529
|
664 assert (sr); |
1
|
665 |
2975
|
666 octave_value val = sr->def (); |
195
|
667 |
2975
|
668 if (! error_state && val.is_scalar_type ()) |
|
669 { |
|
670 d = val.double_value (); |
|
671 status = 1; |
1
|
672 } |
|
673 |
|
674 return status; |
|
675 } |
|
676 |
1093
|
677 // Look for the given name in the global symbol table. |
|
678 |
2086
|
679 octave_value |
1755
|
680 builtin_any_variable (const string& name) |
1093
|
681 { |
2856
|
682 symbol_record *sr = global_sym_tab->lookup (name); |
1093
|
683 |
1271
|
684 // It is a prorgramming error to look for builtins that aren't. |
1093
|
685 |
|
686 assert (sr); |
|
687 |
2975
|
688 return sr->def (); |
1093
|
689 } |
|
690 |
593
|
691 // Global stuff and links to builtin variables and functions. |
|
692 |
581
|
693 // Make the definition of the symbol record sr be the same as the |
|
694 // definition of the global variable of the same name, creating it if |
1418
|
695 // it doesn't already exist. |
581
|
696 |
195
|
697 void |
|
698 link_to_global_variable (symbol_record *sr) |
|
699 { |
2975
|
700 if (! sr->is_linked_to_global ()) |
195
|
701 { |
2975
|
702 sr->mark_as_linked_to_global (); |
195
|
703 |
2975
|
704 if (! error_state) |
|
705 { |
|
706 string nm = sr->name (); |
2846
|
707 |
2975
|
708 symbol_record *gsr = global_sym_tab->lookup (nm, true); |
|
709 |
|
710 // There must be a better way to do this. XXX FIXME XXX |
195
|
711 |
2975
|
712 if (sr->is_variable ()) |
|
713 gsr->define (sr->def ()); |
|
714 else |
|
715 sr->clear (); |
1271
|
716 |
2975
|
717 // Make sure this symbol is a variable. |
2900
|
718 |
2975
|
719 if (! gsr->is_variable ()) |
|
720 gsr->define (octave_value ()); |
2900
|
721 |
2975
|
722 sr->alias (gsr, 1); |
|
723 } |
195
|
724 } |
|
725 } |
|
726 |
581
|
727 // Make the definition of the symbol record sr be the same as the |
|
728 // definition of the builtin variable of the same name. |
|
729 |
|
730 // Make the definition of the symbol record sr be the same as the |
3258
|
731 // definition of the builtin variable, constant, or function, or user |
|
732 // function of the same name, provided that the name has not been used |
|
733 // as a formal parameter. |
581
|
734 |
195
|
735 void |
|
736 link_to_builtin_or_function (symbol_record *sr) |
|
737 { |
2856
|
738 symbol_record *tmp_sym = global_sym_tab->lookup (sr->name ()); |
195
|
739 |
529
|
740 if (tmp_sym |
3258
|
741 && (tmp_sym->is_builtin_variable () |
|
742 || tmp_sym->is_builtin_constant () |
|
743 || tmp_sym->is_function ()) |
529
|
744 && ! tmp_sym->is_formal_parameter ()) |
|
745 sr->alias (tmp_sym); |
195
|
746 } |
|
747 |
581
|
748 // Force a link to a function in the current symbol table. This is |
|
749 // used just after defining a function to avoid different behavior |
|
750 // depending on whether or not the function has been evaluated after |
|
751 // being defined. |
|
752 // |
|
753 // Return without doing anything if there isn't a function with the |
|
754 // given name defined in the global symbol table. |
|
755 |
195
|
756 void |
1755
|
757 force_link_to_function (const string& id_name) |
195
|
758 { |
2856
|
759 symbol_record *gsr = global_sym_tab->lookup (id_name, true); |
195
|
760 if (gsr->is_function ()) |
|
761 { |
|
762 curr_sym_tab->clear (id_name); |
2856
|
763 symbol_record *csr = curr_sym_tab->lookup (id_name, true); |
195
|
764 csr->alias (gsr); |
|
765 } |
|
766 } |
|
767 |
2294
|
768 DEFUN (document, args, , |
3361
|
769 "-*- texinfo -*-\n\ |
|
770 @deftypefn {Built-in Function} {} document (@var{symbol}, @var{text})\n\ |
|
771 Set the documentation string for @var{symbol} to @var{text}.\n\ |
|
772 @end deftypefn") |
593
|
773 { |
2294
|
774 octave_value retval; |
1755
|
775 |
2294
|
776 int nargin = args.length (); |
1755
|
777 |
2294
|
778 if (nargin == 2) |
593
|
779 { |
2294
|
780 string name = args(0).string_value (); |
593
|
781 |
2294
|
782 if (! error_state) |
593
|
783 { |
2294
|
784 string help = args(1).string_value (); |
593
|
785 |
2294
|
786 if (! error_state) |
|
787 { |
|
788 if (is_builtin_variable (name) |
|
789 || is_text_function_name (name) |
|
790 || is_mapper_function_name (name) |
|
791 || is_builtin_function_name (name)) |
|
792 error ("document: can't redefine help for built-in variables and functions"); |
|
793 else |
|
794 { |
2856
|
795 symbol_record *sym_rec = curr_sym_tab->lookup (name); |
2294
|
796 |
|
797 if (sym_rec) |
|
798 sym_rec->document (help); |
|
799 else |
|
800 error ("document: no such symbol `%s'", name.c_str ()); |
|
801 } |
|
802 } |
593
|
803 } |
|
804 } |
|
805 else |
|
806 print_usage ("document"); |
|
807 |
|
808 return retval; |
|
809 } |
|
810 |
2086
|
811 static octave_value_list |
1755
|
812 do_who (int argc, const string_vector& argv) |
529
|
813 { |
2086
|
814 octave_value_list retval; |
529
|
815 |
2856
|
816 bool show_builtins = false; |
3248
|
817 bool show_functions = false; |
|
818 bool show_variables = false; |
2856
|
819 bool show_verbose = false; |
529
|
820 |
1755
|
821 string my_name = argv[0]; |
584
|
822 |
1857
|
823 int i; |
|
824 for (i = 1; i < argc; i++) |
529
|
825 { |
1755
|
826 if (argv[i] == "-all" || argv[i] == "-a") |
529
|
827 { |
2856
|
828 show_builtins = true; |
|
829 show_functions = true; |
|
830 show_variables = true; |
529
|
831 } |
1755
|
832 else if (argv[i] == "-builtins" || argv[i] == "-b") |
2856
|
833 show_builtins = true; |
1755
|
834 else if (argv[i] == "-functions" || argv[i] == "-f") |
2856
|
835 show_functions = true; |
1755
|
836 else if (argv[i] == "-long" || argv[i] == "-l") |
2856
|
837 show_verbose = true; |
1755
|
838 else if (argv[i] == "-variables" || argv[i] == "-v") |
2856
|
839 show_variables = true; |
1755
|
840 else if (argv[i][0] == '-') |
|
841 warning ("%s: unrecognized option `%s'", my_name.c_str (), |
|
842 argv[i].c_str ()); |
529
|
843 else |
867
|
844 break; |
529
|
845 } |
|
846 |
3248
|
847 // If no options were specified to select the type of symbol to |
|
848 // display, then set defaults. |
|
849 |
|
850 if (! (show_builtins || show_functions || show_variables)) |
|
851 { |
|
852 show_functions = (curr_sym_tab == top_level_sym_tab); |
|
853 show_variables = true; |
|
854 } |
|
855 |
1857
|
856 int npats = argc - i; |
|
857 string_vector pats (npats); |
|
858 for (int j = 0; j < npats; j++) |
|
859 pats[j] = argv[i+j]; |
|
860 |
1271
|
861 // If the user specified -l and nothing else, show variables. If |
|
862 // evaluating this at the top level, also show functions. |
529
|
863 |
|
864 if (show_verbose && ! (show_builtins || show_functions || show_variables)) |
|
865 { |
|
866 show_functions = (curr_sym_tab == top_level_sym_tab); |
|
867 show_variables = 1; |
|
868 } |
|
869 |
|
870 int pad_after = 0; |
|
871 |
|
872 if (show_builtins) |
|
873 { |
3011
|
874 pad_after += global_sym_tab->maybe_list |
3259
|
875 ("*** built-in constants:", pats, octave_stdout, |
|
876 show_verbose, symbol_record::BUILTIN_CONSTANT, SYMTAB_ALL_SCOPES); |
|
877 |
|
878 pad_after += global_sym_tab->maybe_list |
3013
|
879 ("*** built-in variables:", pats, octave_stdout, |
3011
|
880 show_verbose, symbol_record::BUILTIN_VARIABLE, SYMTAB_ALL_SCOPES); |
529
|
881 |
3011
|
882 pad_after += global_sym_tab->maybe_list |
3013
|
883 ("*** built-in functions:", pats, octave_stdout, |
3011
|
884 show_verbose, symbol_record::BUILTIN_FUNCTION, SYMTAB_ALL_SCOPES); |
529
|
885 } |
|
886 |
|
887 if (show_functions) |
|
888 { |
3011
|
889 pad_after += global_sym_tab->maybe_list |
3013
|
890 ("*** currently compiled functions:", pats, |
3011
|
891 octave_stdout, show_verbose, symbol_record::USER_FUNCTION, |
|
892 SYMTAB_ALL_SCOPES); |
529
|
893 } |
|
894 |
|
895 if (show_variables) |
|
896 { |
3011
|
897 pad_after += curr_sym_tab->maybe_list |
3013
|
898 ("*** local user variables:", pats, octave_stdout, |
3011
|
899 show_verbose, symbol_record::USER_VARIABLE, SYMTAB_LOCAL_SCOPE); |
529
|
900 |
3011
|
901 pad_after += curr_sym_tab->maybe_list |
3013
|
902 ("*** globally visible user variables:", pats, |
3011
|
903 octave_stdout, show_verbose, symbol_record::USER_VARIABLE, |
|
904 SYMTAB_GLOBAL_SCOPE); |
529
|
905 } |
|
906 |
|
907 if (pad_after) |
2095
|
908 octave_stdout << "\n"; |
529
|
909 |
581
|
910 return retval; |
|
911 } |
|
912 |
1957
|
913 DEFUN_TEXT (who, args, , |
3361
|
914 "-*- texinfo -*-\n\ |
|
915 @deffn {Command} who options pattern @dots{}\n\ |
|
916 @deffnx {Command} whos options pattern @dots{}\n\ |
|
917 List currently defined symbols matching the given patterns. The\n\ |
|
918 following are valid options. They may be shortened to one character but\n\ |
|
919 may not be combined.\n\ |
|
920 \n\ |
|
921 @table @code\n\ |
|
922 @item -all\n\ |
|
923 List all currently defined symbols.\n\ |
|
924 \n\ |
|
925 @item -builtins\n\ |
|
926 List built-in variables and functions. This includes all currently\n\ |
|
927 compiled function files, but does not include all function files that\n\ |
|
928 are in the @code{LOADPATH}.\n\ |
581
|
929 \n\ |
3361
|
930 @item -functions\n\ |
|
931 List user-defined functions.\n\ |
|
932 \n\ |
|
933 @item -long\n\ |
|
934 Print a long listing including the type and dimensions of any symbols.\n\ |
|
935 The symbols in the first column of output indicate whether it is\n\ |
|
936 possible to redefine the symbol, and whether it is possible for it to be\n\ |
|
937 cleared.\n\ |
|
938 \n\ |
|
939 @item -variables\n\ |
|
940 List user-defined variables.\n\ |
|
941 @end table\n\ |
|
942 \n\ |
|
943 Valid patterns are the same as described for the @code{clear} command\n\ |
|
944 above. If no patterns are supplied, all symbols from the given category\n\ |
|
945 are listed. By default, only user defined functions and variables\n\ |
|
946 visible in the local scope are displayed.\n\ |
|
947 \n\ |
|
948 The command @kbd{whos} is equivalent to @kbd{who -long}.\n\ |
|
949 @end deffn") |
581
|
950 { |
2086
|
951 octave_value_list retval; |
581
|
952 |
1755
|
953 int argc = args.length () + 1; |
|
954 |
1968
|
955 string_vector argv = args.make_argv ("who"); |
1755
|
956 |
|
957 if (error_state) |
|
958 return retval; |
581
|
959 |
1488
|
960 retval = do_who (argc, argv); |
581
|
961 |
529
|
962 return retval; |
|
963 } |
|
964 |
1957
|
965 DEFUN_TEXT (whos, args, , |
581
|
966 "whos [-all] [-builtins] [-functions] [-long] [-variables]\n\ |
|
967 \n\ |
|
968 List currently defined symbol(s). Options may be shortened to one\n\ |
|
969 character, but may not be combined.") |
|
970 { |
2086
|
971 octave_value_list retval; |
581
|
972 |
712
|
973 int nargin = args.length (); |
|
974 |
2086
|
975 octave_value_list tmp_args; |
742
|
976 for (int i = nargin; i > 0; i--) |
|
977 tmp_args(i) = args(i-1); |
|
978 tmp_args(0) = "-long"; |
581
|
979 |
742
|
980 int argc = tmp_args.length () + 1; |
1755
|
981 |
1980
|
982 string_vector argv = tmp_args.make_argv ("whos"); |
581
|
983 |
|
984 if (error_state) |
|
985 return retval; |
|
986 |
1488
|
987 retval = do_who (argc, argv); |
581
|
988 |
|
989 return retval; |
|
990 } |
|
991 |
593
|
992 // Defining variables. |
|
993 |
1162
|
994 void |
2856
|
995 bind_ans (const octave_value& val, bool print) |
1162
|
996 { |
2856
|
997 static symbol_record *sr = global_sym_tab->lookup ("ans", true); |
1162
|
998 |
2978
|
999 if (val.is_defined ()) |
|
1000 { |
|
1001 sr->define (val); |
1162
|
1002 |
2978
|
1003 if (print) |
|
1004 val.print_with_name (octave_stdout, "ans"); |
|
1005 } |
1162
|
1006 } |
|
1007 |
3259
|
1008 // Give a global constant a definition. This will insert the symbol |
|
1009 // in the global table if necessary. |
|
1010 |
|
1011 // How is this different than install_builtin_constant? Are both |
|
1012 // functions needed? |
|
1013 |
|
1014 void |
|
1015 bind_builtin_constant (const string& name, const octave_value& val, |
|
1016 bool protect, bool eternal, const string& help) |
|
1017 { |
|
1018 symbol_record *sym_rec = global_sym_tab->lookup (name, true); |
|
1019 sym_rec->unprotect (); |
|
1020 |
|
1021 string tmp_help = help.empty () ? sym_rec->help () : help; |
|
1022 |
|
1023 sym_rec->define_builtin_const (val); |
|
1024 |
|
1025 sym_rec->document (tmp_help); |
|
1026 |
|
1027 if (protect) |
|
1028 sym_rec->protect (); |
|
1029 |
|
1030 if (eternal) |
|
1031 sym_rec->make_eternal (); |
|
1032 } |
|
1033 |
593
|
1034 // Give a global variable a definition. This will insert the symbol |
|
1035 // in the global table if necessary. |
|
1036 |
|
1037 // How is this different than install_builtin_variable? Are both |
|
1038 // functions needed? |
|
1039 |
|
1040 void |
2390
|
1041 bind_builtin_variable (const string& varname, const octave_value& val, |
2953
|
1042 bool protect, bool eternal, |
3005
|
1043 symbol_record::change_function chg_fcn, |
1755
|
1044 const string& help) |
593
|
1045 { |
2856
|
1046 symbol_record *sr = global_sym_tab->lookup (varname, true); |
593
|
1047 |
1271
|
1048 // It is a programming error for a builtin symbol to be missing. |
|
1049 // Besides, we just inserted it, so it must be there. |
593
|
1050 |
|
1051 assert (sr); |
|
1052 |
|
1053 sr->unprotect (); |
|
1054 |
1271
|
1055 // Must do this before define, since define will call the special |
|
1056 // variable function only if it knows about it, and it needs to, so |
|
1057 // that user prefs can be properly initialized. |
593
|
1058 |
3005
|
1059 if (chg_fcn) |
|
1060 sr->set_change_function (chg_fcn); |
593
|
1061 |
|
1062 sr->define_builtin_var (val); |
|
1063 |
|
1064 if (protect) |
|
1065 sr->protect (); |
|
1066 |
|
1067 if (eternal) |
|
1068 sr->make_eternal (); |
|
1069 |
1755
|
1070 sr->document (help); |
529
|
1071 } |
|
1072 |
593
|
1073 // Deleting names from the symbol tables. |
|
1074 |
1957
|
1075 DEFUN_TEXT (clear, args, , |
3361
|
1076 "-*- texinfo -*-\n\ |
|
1077 @deffn {Command} clear [-x] pattern @dots{}\n\ |
|
1078 Delete the names matching the given patterns from the symbol table. The\n\ |
|
1079 pattern may contain the following special characters:\n\ |
|
1080 @table @code\n\ |
|
1081 @item ?\n\ |
|
1082 Match any single character.\n\ |
668
|
1083 \n\ |
3361
|
1084 @item *\n\ |
|
1085 Match zero or more characters.\n\ |
|
1086 \n\ |
|
1087 @item [ @var{list} ]\n\ |
|
1088 Match the list of characters specified by @var{list}. If the first\n\ |
|
1089 character is @code{!} or @code{^}, match all characters except those\n\ |
|
1090 specified by @var{list}. For example, the pattern @samp{[a-zA-Z]} will\n\ |
|
1091 match all lower and upper case alphabetic characters.\n\ |
|
1092 @end table\n\ |
|
1093 \n\ |
|
1094 For example, the command\n\ |
593
|
1095 \n\ |
3361
|
1096 @example\n\ |
|
1097 clear foo b*r\n\ |
|
1098 @end example\n\ |
|
1099 \n\ |
|
1100 @noindent\n\ |
|
1101 clears the name @code{foo} and all names that begin with the letter\n\ |
|
1102 @code{b} and end with the letter @code{r}.\n\ |
668
|
1103 \n\ |
3361
|
1104 If @code{clear} is called without any arguments, all user-defined\n\ |
|
1105 variables (local and global) are cleared from the symbol table. If\n\ |
|
1106 @code{clear} is called with at least one argument, only the visible\n\ |
|
1107 names matching the arguments are cleared. For example, suppose you have\n\ |
|
1108 defined a function @code{foo}, and then hidden it by performing the\n\ |
|
1109 assignment @code{foo = 2}. Executing the command @kbd{clear foo} once\n\ |
|
1110 will clear the variable definition and restore the definition of\n\ |
|
1111 @code{foo} as a function. Executing @kbd{clear foo} a second time will\n\ |
|
1112 clear the function definition.\n\ |
|
1113 \n\ |
|
1114 With -x, clear the variables that don't match the patterns.\n\ |
|
1115 \n\ |
|
1116 This command may not be used within a function body.\n\ |
|
1117 @end deffn") |
529
|
1118 { |
2086
|
1119 octave_value_list retval; |
593
|
1120 |
1755
|
1121 int argc = args.length () + 1; |
593
|
1122 |
1968
|
1123 string_vector argv = args.make_argv ("clear"); |
1755
|
1124 |
|
1125 if (error_state) |
|
1126 return retval; |
668
|
1127 |
1271
|
1128 // Always clear the local table, but don't clear currently compiled |
|
1129 // functions unless we are at the top level. (Allowing that to |
|
1130 // happen inside functions would result in pretty odd behavior...) |
593
|
1131 |
2856
|
1132 bool clear_user_functions = (curr_sym_tab == top_level_sym_tab); |
593
|
1133 |
1755
|
1134 if (argc == 1) |
593
|
1135 { |
|
1136 curr_sym_tab->clear (); |
|
1137 global_sym_tab->clear (clear_user_functions); |
|
1138 } |
529
|
1139 else |
|
1140 { |
668
|
1141 int exclusive = 0; |
|
1142 |
1755
|
1143 int idx = 1; |
|
1144 |
|
1145 if (argc > 1) |
668
|
1146 { |
1755
|
1147 if (argv[idx] == "-x") |
3125
|
1148 { |
|
1149 idx++; |
|
1150 exclusive = 1; |
|
1151 } |
668
|
1152 } |
|
1153 |
1755
|
1154 string_vector lvars; |
|
1155 string_vector gvars; |
|
1156 string_vector fcns; |
668
|
1157 |
|
1158 if (argc > 0) |
593
|
1159 { |
3013
|
1160 string_vector tmp; |
|
1161 |
3325
|
1162 lvars = curr_sym_tab->name_list |
3355
|
1163 (tmp, false, SYMTAB_VARIABLES, SYMTAB_LOCAL_SCOPE); |
668
|
1164 |
3325
|
1165 gvars = curr_sym_tab->name_list |
3355
|
1166 (tmp, false, SYMTAB_VARIABLES, SYMTAB_GLOBAL_SCOPE); |
668
|
1167 |
3325
|
1168 fcns = global_sym_tab->name_list |
3355
|
1169 (tmp, false, |
3325
|
1170 symbol_record::USER_FUNCTION|symbol_record::DLD_FUNCTION, |
|
1171 SYMTAB_ALL_SCOPES); |
668
|
1172 } |
|
1173 |
2438
|
1174 // XXX FIXME XXX -- this needs to be optimized to avoid the |
|
1175 // pattern matching code if the string doesn't contain any |
|
1176 // globbing patterns. |
|
1177 |
1970
|
1178 for (int k = idx; k < argc; k++) |
668
|
1179 { |
1755
|
1180 string patstr = argv[k]; |
668
|
1181 |
1755
|
1182 if (! patstr.empty ()) |
593
|
1183 { |
1792
|
1184 glob_match pattern (patstr); |
1755
|
1185 |
3355
|
1186 int lcount = lvars.length (); |
|
1187 |
|
1188 for (int i = 0; i < lcount; i++) |
593
|
1189 { |
1755
|
1190 string nm = lvars[i]; |
1792
|
1191 int match = pattern.match (nm); |
668
|
1192 if ((exclusive && ! match) || (! exclusive && match)) |
|
1193 curr_sym_tab->clear (nm); |
593
|
1194 } |
529
|
1195 |
3355
|
1196 int gcount = gvars.length (); |
|
1197 for (int i = 0; i < gcount; i++) |
593
|
1198 { |
1755
|
1199 string nm = gvars[i]; |
1792
|
1200 int match = pattern.match (nm); |
668
|
1201 if ((exclusive && ! match) || (! exclusive && match)) |
593
|
1202 { |
3355
|
1203 int count = curr_sym_tab->clear (nm); |
593
|
1204 if (count > 0) |
668
|
1205 global_sym_tab->clear (nm, clear_user_functions); |
593
|
1206 } |
|
1207 } |
529
|
1208 |
3355
|
1209 int fcount = fcns.length (); |
|
1210 for (int i = 0; i < fcount; i++) |
593
|
1211 { |
1755
|
1212 string nm = fcns[i]; |
1792
|
1213 int match = pattern.match (nm); |
668
|
1214 if ((exclusive && ! match) || (! exclusive && match)) |
593
|
1215 { |
3355
|
1216 curr_sym_tab->clear (nm); |
864
|
1217 global_sym_tab->clear (nm, clear_user_functions); |
593
|
1218 } |
|
1219 } |
|
1220 } |
|
1221 } |
|
1222 } |
|
1223 |
|
1224 return retval; |
529
|
1225 } |
|
1226 |
3005
|
1227 DEFUN (__dump_symtab_info__, args, , |
|
1228 "__dump_symtab_info__ (): print raw symbol table statistices") |
|
1229 { |
|
1230 octave_value_list retval; |
|
1231 |
|
1232 int nargin = args.length (); |
|
1233 |
|
1234 if (nargin == 1) |
|
1235 { |
|
1236 string arg = args(0).string_value (); |
|
1237 |
|
1238 if (arg == "global") |
|
1239 global_sym_tab->print_stats (); |
|
1240 else |
|
1241 print_usage ("__dump_symtab_info__"); |
|
1242 } |
|
1243 else if (nargin == 0) |
|
1244 curr_sym_tab->print_stats (); |
|
1245 else |
|
1246 print_usage ("__dump_symtab_info__"); |
|
1247 |
|
1248 return retval; |
|
1249 } |
|
1250 |
3239
|
1251 DEFUN (__dump_symbol_info__, args, , |
|
1252 "__dump_symbol_info__ (NAME)") |
|
1253 { |
|
1254 octave_value_list retval; |
|
1255 |
|
1256 int nargin = args.length (); |
|
1257 |
|
1258 if (nargin == 1) |
|
1259 { |
|
1260 string symbol_name = args(0).string_value (); |
|
1261 |
|
1262 if (! error_state) |
|
1263 { |
|
1264 symbol_record *sr = curr_sym_tab->lookup (symbol_name); |
|
1265 |
|
1266 if (sr) |
|
1267 sr->dump_symbol_info (); |
|
1268 else |
|
1269 error ("__dymp_symbol_info__: symbol %s not found", |
|
1270 symbol_name.c_str ()); |
|
1271 } |
|
1272 else |
|
1273 print_usage ("__dump_symbol_info__"); |
|
1274 } |
|
1275 else |
|
1276 print_usage ("__dump_symbol_info__"); |
|
1277 |
|
1278 return retval; |
|
1279 } |
|
1280 |
3016
|
1281 // XXX FIXME XXX -- some of these should do their own checking to be |
|
1282 // able to provide more meaningful warning or error messages. |
|
1283 |
|
1284 static int |
|
1285 ignore_function_time_stamp (void) |
|
1286 { |
|
1287 int pref = 0; |
|
1288 |
|
1289 string val = builtin_string_variable ("ignore_function_time_stamp"); |
|
1290 |
|
1291 if (! val.empty ()) |
|
1292 { |
|
1293 if (val.compare ("all", 0, 3) == 0) |
|
1294 pref = 2; |
|
1295 if (val.compare ("system", 0, 6) == 0) |
|
1296 pref = 1; |
|
1297 } |
|
1298 |
|
1299 Vignore_function_time_stamp = pref; |
|
1300 |
|
1301 return 0; |
|
1302 } |
|
1303 |
|
1304 // XXX FIXME XXX -- there still may be better places for some of these |
|
1305 // to be defined. |
|
1306 |
|
1307 void |
|
1308 symbols_of_variables (void) |
|
1309 { |
3258
|
1310 DEFVAR (ans, , 0, |
3372
|
1311 "-*- texinfo -*-\n\ |
|
1312 @defvr {Built-in Variable} ans\n\ |
|
1313 This variable holds the most recently computed result that was not\n\ |
|
1314 explicitly assigned to a variable. For example, after the expression\n\ |
|
1315 \n\ |
|
1316 @example\n\ |
|
1317 3^2 + 4^2\n\ |
|
1318 @end example\n\ |
|
1319 \n\ |
|
1320 @noindent\n\ |
|
1321 is evaluated, the value of @code{ans} is 25.\n\ |
|
1322 @end defvr"); |
3016
|
1323 |
3258
|
1324 DEFVAR (ignore_function_time_stamp, "system", ignore_function_time_stamp, |
3371
|
1325 "-*- texinfo -*-\n\ |
|
1326 @defvr {Built-in Variable} ignore_function_time_stamp\n\ |
|
1327 This variable can be used to prevent Octave from making the system call\n\ |
|
1328 @code{stat} each time it looks up functions defined in function files.\n\ |
|
1329 If @code{ignore_function_time_stamp} to @code{\"system\"}, Octave will not\n\ |
|
1330 automatically recompile function files in subdirectories of\n\ |
|
1331 @file{@var{octave-home}/lib/@var{version}} if they have changed since\n\ |
|
1332 they were last compiled, but will recompile other function files in the\n\ |
|
1333 @code{LOADPATH} if they change. If set to @code{\"all\"}, Octave will not\n\ |
|
1334 recompile any function files unless their definitions are removed with\n\ |
|
1335 @code{clear}. For any other value of @code{ignore_function_time_stamp},\n\ |
|
1336 Octave will always check to see if functions defined in function files\n\ |
|
1337 need to recompiled. The default value of @code{ignore_function_time_stamp} is\n\ |
|
1338 @code{\"system\"}.\n\ |
|
1339 @end defvr"); |
|
1340 |
3016
|
1341 } |
|
1342 |
1
|
1343 /* |
|
1344 ;;; Local Variables: *** |
|
1345 ;;; mode: C++ *** |
|
1346 ;;; End: *** |
|
1347 */ |