Mercurial > hg > octave-terminal
changeset 4872:fe71c458f438
[project @ 2004-04-21 20:09:32 by jwe]
author | jwe |
---|---|
date | Wed, 21 Apr 2004 20:09:32 +0000 |
parents | 9c89c1408c32 |
children | 0358ed4394f5 |
files | src/ChangeLog src/parse.y |
diffstat | 2 files changed, 22 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2004-04-21 John W. Eaton <jwe@octave.org> + + * parse.y (function2): Pass id name to frob_function. Delete id. + (frob_function): Accept function name instead of identifier. + Don't try to rename symbol table entry. Lookup symbol record for + function name here. Insert name in symbol table if needed. + Operate on symbol record instead of identifier. + 2004-04-21 David Bateman <dbateman@free.fr> * DLD_FUNCTIONS/fft.cc(do_fft): Correctly initialize the variable dim
--- a/src/parse.y +++ b/src/parse.y @@ -278,7 +278,7 @@ // Do most of the work for defining a function. static octave_user_function * -frob_function (tree_identifier *id, octave_user_function *fcn); +frob_function (const std::string& fname, octave_user_function *fcn); // Finish defining a function. static octave_user_function * @@ -1308,7 +1308,11 @@ function2 : fcn_name function3 { - if (! ($$ = frob_function ($1, $2))) + std::string fname = $1->name (); + + delete $1; + + if (! ($$ = frob_function (fname, $2))) ABORT_PARSE; } ; @@ -2584,17 +2588,15 @@ // Do most of the work for defining a function. static octave_user_function * -frob_function (tree_identifier *id, octave_user_function *fcn) +frob_function (const std::string& fname, octave_user_function *fcn) { - std::string id_name = id->name (); + std::string id_name = fname; // If input is coming from a file, issue a warning if the name of // the file does not match the name of the function stated in the // file. Matlab doesn't provide a diagnostic (it ignores the stated // name). - fcn->stash_function_name (id_name); - if (reading_fcn_file) { if (! lexer_flags.parsing_nested_function @@ -2604,17 +2606,11 @@ warning ("function name `%s' does not agree with function\ file name `%s'", id_name.c_str (), curr_fcn_file_full_name.c_str ()); - fbi_sym_tab->rename (id_name, curr_fcn_file_name); - - if (error_state) - return 0; - - id_name = id->name (); + id_name = curr_fcn_file_name; } octave_time now; - fcn->stash_function_name (id_name); fcn->stash_fcn_file_name (curr_fcn_file_full_name); fcn->stash_fcn_file_time (now); fcn->mark_as_system_fcn_file (); @@ -2637,9 +2633,11 @@ id_name.c_str (), curr_fcn_file_full_name.c_str ()); } + fcn->stash_function_name (id_name); + top_level_sym_tab->clear (id_name); - symbol_record *sr = fbi_sym_tab->lookup (id_name); + symbol_record *sr = fbi_sym_tab->lookup (id_name, true); if (sr) { @@ -2651,11 +2649,11 @@ else panic_impossible (); - id->define (fcn, symbol_record::USER_FUNCTION); + sr->define (fcn, symbol_record::USER_FUNCTION); if (! help_buf.empty ()) { - id->document (help_buf.top ()); + sr->document (help_buf.top ()); help_buf.pop (); }