Mercurial > hg > octave-nkf
changeset 1162:c210c5a25a48
[project @ 1995-02-27 17:36:16 by jwe]
author | jwe |
---|---|
date | Mon, 27 Feb 1995 17:38:57 +0000 |
parents | 0326a802cd5c |
children | f963aa9821b5 |
files | src/parse.y src/pt-exp-base.cc src/variables.cc src/variables.h |
diffstat | 4 files changed, 23 insertions(+), 46 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parse.y +++ b/src/parse.y @@ -1339,13 +1339,10 @@ } else { - symbol_record *sr = global_sym_tab->lookup ("ans", 1, 0); + static symbol_record *sr = global_sym_tab->lookup ("ans", 1, 0); + static tree_identifier ans_id (sr); - assert (sr); - - tree_identifier *ans = new tree_identifier (sr); - - return new tree_simple_assignment_expression (ans, expr, 0, 1); + return new tree_simple_assignment_expression (&ans_id, expr, 1, 1); } }
--- a/src/pt-exp-base.cc +++ b/src/pt-exp-base.cc @@ -963,29 +963,11 @@ if (! error_state && retval.is_defined ()) { if (maybe_do_ans_assign && ! object_to_eval->is_constant ()) - { - -// XXX FIXME XXX -- need a procedure to do this, probably in -// variables.cc, to isolate the code that does lookups... - - symbol_record *sr = global_sym_tab->lookup ("ans", 1, 0); - - assert (sr); - - tree_identifier *ans_id = new tree_identifier (sr); - - tree_constant *tmp = new tree_constant (retval); - - tree_simple_assignment_expression tmp_ass (ans_id, tmp, 0, 1); - - tmp_ass.eval (print); - } - else - { - if (print) - print_constant (retval, name ()); - } + bind_ans (retval, print); + else if (print) + print_constant (retval, name ()); } + return retval; } @@ -1015,24 +997,7 @@ retval = object_to_eval->eval (0, nargout, args); if (retval.length () > 0 && retval(0).is_defined ()) - { - -// XXX FIXME XXX -- need a procedure to do this, probably in -// variables.cc, to isolate the code that does lookups... - - symbol_record *sr = global_sym_tab->lookup ("ans", 1, 0); - - assert (sr); - - tree_identifier *ans_id = new tree_identifier (sr); - - tree_constant *tmp = new tree_constant (retval(0)); - - tree_simple_assignment_expression tmp_ass (ans_id, - tmp, 0, 1); - - tmp_ass.eval (print); - } + bind_ans (retval(0), print); } else retval = object_to_eval->eval (print, nargout, args);
--- a/src/variables.cc +++ b/src/variables.cc @@ -1405,6 +1405,19 @@ } #endif +void +bind_ans (const tree_constant& val, int print) +{ + static symbol_record *sr = global_sym_tab->lookup ("ans", 1, 0); + static tree_identifier ans_id (sr); + + tree_constant *tmp = new tree_constant (val); + + tree_simple_assignment_expression tmp_ass (&ans_id, tmp, 1, 1); + + tmp_ass.eval (print); +} + // Give a global variable a definition. This will insert the symbol // in the global table if necessary.