comparison src/ov-usr-fcn.cc @ 9377:610bf90fce2a

update unwind_protect usage everywhere
author Jaroslav Hajek <highegg@gmail.com>
date Tue, 23 Jun 2009 08:22:13 +0200
parents c6463412aebb
children 17af7cce7d1b
comparison
equal deleted inserted replaced
9376:d58086453171 9377:610bf90fce2a
109 octave_user_script::do_multi_index_op (int nargout, 109 octave_user_script::do_multi_index_op (int nargout,
110 const octave_value_list& args) 110 const octave_value_list& args)
111 { 111 {
112 octave_value_list retval; 112 octave_value_list retval;
113 113
114 unwind_protect::begin_frame ("user_script_eval"); 114 unwind_protect::frame_id_t uwp_frame = unwind_protect::begin_frame ();
115 115
116 if (! error_state) 116 if (! error_state)
117 { 117 {
118 if (args.length () == 0 && nargout == 0) 118 if (args.length () == 0 && nargout == 0)
119 { 119 {
120 if (cmd_list) 120 if (cmd_list)
121 { 121 {
122 unwind_protect_int (call_depth); 122 unwind_protect::protect_var (call_depth);
123 call_depth++; 123 call_depth++;
124 124
125 if (call_depth < Vmax_recursion_depth) 125 if (call_depth < Vmax_recursion_depth)
126 { 126 {
127 octave_call_stack::push (this); 127 octave_call_stack::push (this);
128 128
129 unwind_protect::add (octave_call_stack::unwind_pop, 0); 129 unwind_protect::add (octave_call_stack::unwind_pop, 0);
130 130
131 unwind_protect_bool (tree_evaluator::in_fcn_or_script_body); 131 unwind_protect::protect_var (tree_evaluator::in_fcn_or_script_body);
132 tree_evaluator::in_fcn_or_script_body = true; 132 tree_evaluator::in_fcn_or_script_body = true;
133 133
134 cmd_list->accept (*current_evaluator); 134 cmd_list->accept (*current_evaluator);
135 135
136 if (tree_return_command::returning) 136 if (tree_return_command::returning)
148 } 148 }
149 else 149 else
150 error ("invalid call to script"); 150 error ("invalid call to script");
151 } 151 }
152 152
153 unwind_protect::run_frame ("user_script_eval"); 153 unwind_protect::run_frame (uwp_frame);
154 154
155 return retval; 155 return retval;
156 } 156 }
157 157
158 void 158 void
344 if (! cmd_list) 344 if (! cmd_list)
345 return retval; 345 return retval;
346 346
347 int nargin = args.length (); 347 int nargin = args.length ();
348 348
349 unwind_protect::begin_frame ("user_func_eval"); 349 unwind_protect::frame_id_t uwp_frame = unwind_protect::begin_frame ();
350 350
351 unwind_protect_int (call_depth); 351 unwind_protect::protect_var (call_depth);
352 call_depth++; 352 call_depth++;
353 353
354 if (call_depth >= Vmax_recursion_depth) 354 if (call_depth >= Vmax_recursion_depth)
355 { 355 {
356 ::error ("max_recursion_limit exceeded"); 356 ::error ("max_recursion_limit exceeded");
357 unwind_protect::run_frame ("user_func_eval"); 357 unwind_protect::run_frame (uwp_frame);
358 return retval; 358 return retval;
359 } 359 }
360 360
361 // Save old and set current symbol table context, for 361 // Save old and set current symbol table context, for
362 // eval_undefined_error(). 362 // eval_undefined_error().
377 377
378 unwind_protect::add (::restore_args_passed, this); 378 unwind_protect::add (::restore_args_passed, this);
379 379
380 string_vector arg_names = args.name_tags (); 380 string_vector arg_names = args.name_tags ();
381 381
382 unwind_protect_int (num_args_passed); 382 unwind_protect::protect_var (num_args_passed);
383 num_args_passed = nargin; 383 num_args_passed = nargin;
384 384
385 if (param_list && ! param_list->varargs_only ()) 385 if (param_list && ! param_list->varargs_only ())
386 { 386 {
387 param_list->define_from_arg_vector (args); 387 param_list->define_from_arg_vector (args);
428 if (echo_commands) 428 if (echo_commands)
429 print_code_function_header (); 429 print_code_function_header ();
430 430
431 // Evaluate the commands that make up the function. 431 // Evaluate the commands that make up the function.
432 432
433 unwind_protect_bool (tree_evaluator::in_fcn_or_script_body); 433 unwind_protect::protect_var (tree_evaluator::in_fcn_or_script_body);
434 tree_evaluator::in_fcn_or_script_body = true; 434 tree_evaluator::in_fcn_or_script_body = true;
435 435
436 bool special_expr = (is_inline_function () 436 bool special_expr = (is_inline_function ()
437 || cmd_list->is_anon_function_body ()); 437 || cmd_list->is_anon_function_body ());
438 438
493 retval = ret_list->convert_to_const_vector (varargout); 493 retval = ret_list->convert_to_const_vector (varargout);
494 } 494 }
495 } 495 }
496 496
497 abort: 497 abort:
498 unwind_protect::run_frame ("user_func_eval"); 498 unwind_protect::run_frame (uwp_frame);
499 499
500 return retval; 500 return retval;
501 } 501 }
502 502
503 void 503 void