comparison libinterp/parse-tree/pt-except.cc @ 17249:923ce8b42db2

improve try-catch-statement to save exception to a variable (bug #33217) * oct-parse.in.yy (except_command): Handle exception identifiers. * oct-parse.in.yy, parse.h (octave_base_parser::make_try_command): New arg, ID. * pt-except.cc, pt-except.h (tree_try_catch_command::expr_id): New data member. (tree_command::tree_command): Initialize it. (tree_command::~tree_command): Delete it. (tree_command::identifier): New function. * pt-check.cc (tree_checker::visit_try_catch_command): Check for valid expr_id. * pt-pr-code.cc (tree_print_code::visit_try_catch_command): Print expr_id. * pt-eval.cc (tree_evaluator::visit_try_catch_command): Assign message and identifier to variable. * try.tst: New test. * NEWS: Note change.
author Stefan Mahr <dac922@gmx.de>
date Tue, 13 Aug 2013 19:35:53 +0200
parents 2fc554ffbc28
children d63878346099
comparison
equal deleted inserted replaced
17248:0b2a0acd0315 17249:923ce8b42db2
31 #include "ov.h" 31 #include "ov.h"
32 #include "pt-bp.h" 32 #include "pt-bp.h"
33 #include "pt-cmd.h" 33 #include "pt-cmd.h"
34 #include "pt-except.h" 34 #include "pt-except.h"
35 #include "pt-exp.h" 35 #include "pt-exp.h"
36 #include "pt-id.h"
36 #include "pt-jump.h" 37 #include "pt-jump.h"
37 #include "pt-stmt.h" 38 #include "pt-stmt.h"
38 #include "pt-walk.h" 39 #include "pt-walk.h"
39 #include "unwind-prot.h" 40 #include "unwind-prot.h"
40 #include "variables.h" 41 #include "variables.h"
41 42
42 // Simple exception handling. 43 // Simple exception handling.
43 44
44 tree_try_catch_command::~tree_try_catch_command (void) 45 tree_try_catch_command::~tree_try_catch_command (void)
45 { 46 {
47 delete expr_id;
46 delete try_code; 48 delete try_code;
47 delete catch_code; 49 delete catch_code;
48 delete lead_comm; 50 delete lead_comm;
49 delete mid_comm; 51 delete mid_comm;
50 delete trail_comm; 52 delete trail_comm;
55 symbol_table::context_id context) const 57 symbol_table::context_id context) const
56 { 58 {
57 return new 59 return new
58 tree_try_catch_command (try_code ? try_code->dup (scope, context) : 0, 60 tree_try_catch_command (try_code ? try_code->dup (scope, context) : 0,
59 catch_code ? catch_code->dup (scope, context) : 0, 61 catch_code ? catch_code->dup (scope, context) : 0,
62 expr_id ? expr_id->dup (scope, context) : 0,
60 lead_comm ? lead_comm->dup () : 0, 63 lead_comm ? lead_comm->dup () : 0,
61 mid_comm ? mid_comm->dup () : 0, 64 mid_comm ? mid_comm->dup () : 0,
62 trail_comm ? trail_comm->dup () : 0, 65 trail_comm ? trail_comm->dup () : 0,
63 line (), column ()); 66 line (), column ());
64 } 67 }