Mercurial > octave
comparison libinterp/parse-tree/pt-eval.h @ 27234:279074d7a3b9
eliminate unused tree_evaluator::reset function
* pt-eval.h, pt-eval.cc (tree_evaluator::reset): Delete unused function.
(tree_evaluator::evaluate_internal): New function. Use unwind_protect
to ensure nargout_stack is properly restored.
(tree_evaluator::evaluate): Use new evaluate_internal function.
Reset m_result_type before returning.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 11 Jul 2019 14:21:37 -0400 |
parents | f84c5528e932 |
children | 49c60d16866f |
comparison
equal
deleted
inserted
replaced
27233:fc668ac9ce7c | 27234:279074d7a3b9 |
---|---|
154 | 154 |
155 ~tree_evaluator (void) = default; | 155 ~tree_evaluator (void) = default; |
156 | 156 |
157 bool at_top_level (void) const; | 157 bool at_top_level (void) const; |
158 | 158 |
159 void reset (void); | |
160 | |
161 int repl (bool interactive); | 159 int repl (bool interactive); |
162 | 160 |
163 std::string mfilename (const std::string& opt = "") const; | 161 std::string mfilename (const std::string& opt = "") const; |
164 | 162 |
165 octave_value_list eval_string (const std::string& eval_str, bool silent, | 163 octave_value_list eval_string (const std::string& eval_str, bool silent, |
332 | 330 |
333 octave_value evaluate (tree_expression *expr, int nargout = 1) | 331 octave_value evaluate (tree_expression *expr, int nargout = 1) |
334 { | 332 { |
335 octave_value retval; | 333 octave_value retval; |
336 | 334 |
337 m_nargout_stack.push (nargout); | 335 evaluate_internal (expr, nargout); |
338 | |
339 expr->accept (*this); | |
340 | |
341 m_nargout_stack.pop (); | |
342 | 336 |
343 switch (m_result_type) | 337 switch (m_result_type) |
344 { | 338 { |
345 case RT_UNDEFINED: | 339 case RT_UNDEFINED: |
346 panic_impossible (); | 340 panic_impossible (); |
356 ? octave_value () : m_expr_result_value_list(0)); | 350 ? octave_value () : m_expr_result_value_list(0)); |
357 m_expr_result_value_list = octave_value_list (); | 351 m_expr_result_value_list = octave_value_list (); |
358 break; | 352 break; |
359 } | 353 } |
360 | 354 |
355 m_result_type = RT_UNDEFINED; | |
356 | |
361 return retval; | 357 return retval; |
362 } | 358 } |
363 | 359 |
364 octave_value_list evaluate_n (tree_expression *expr, int nargout = 1) | 360 octave_value_list evaluate_n (tree_expression *expr, int nargout = 1) |
365 { | 361 { |
366 octave_value_list retval; | 362 octave_value_list retval; |
367 | 363 |
368 m_nargout_stack.push (nargout); | 364 evaluate_internal (expr, nargout); |
369 | |
370 expr->accept (*this); | |
371 | |
372 m_nargout_stack.pop (); | |
373 | 365 |
374 switch (m_result_type) | 366 switch (m_result_type) |
375 { | 367 { |
376 case RT_UNDEFINED: | 368 case RT_UNDEFINED: |
377 panic_impossible (); | 369 panic_impossible (); |
385 case RT_VALUE_LIST: | 377 case RT_VALUE_LIST: |
386 retval = m_expr_result_value_list; | 378 retval = m_expr_result_value_list; |
387 m_expr_result_value_list = octave_value_list (); | 379 m_expr_result_value_list = octave_value_list (); |
388 break; | 380 break; |
389 } | 381 } |
382 | |
383 m_result_type = RT_UNDEFINED; | |
390 | 384 |
391 return retval; | 385 return retval; |
392 } | 386 } |
393 | 387 |
394 octave_value evaluate (tree_decl_elt *); | 388 octave_value evaluate (tree_decl_elt *); |
795 | 789 |
796 void push_echo_state_cleanup (unwind_protect& frame); | 790 void push_echo_state_cleanup (unwind_protect& frame); |
797 | 791 |
798 bool maybe_push_echo_state_cleanup (void); | 792 bool maybe_push_echo_state_cleanup (void); |
799 | 793 |
794 void evaluate_internal (tree_expression *expr, int nargout); | |
795 | |
800 void do_breakpoint (tree_statement& stmt); | 796 void do_breakpoint (tree_statement& stmt); |
801 | 797 |
802 void do_breakpoint (bool is_breakpoint, | 798 void do_breakpoint (bool is_breakpoint, |
803 bool is_end_of_fcn_or_script = false); | 799 bool is_end_of_fcn_or_script = false); |
804 | 800 |