comparison src/pt-except.cc @ 3490:fc5eac74640d

[project @ 2000-01-28 10:13:25 by jwe]
author jwe
date Fri, 28 Jan 2000 10:13:26 +0000
parents 7c96e85c76db
children 2c7524ffdbf5
comparison
equal deleted inserted replaced
3489:cbee5fbb696d 3490:fc5eac74640d
51 static void 51 static void
52 do_catch_code (void *ptr) 52 do_catch_code (void *ptr)
53 { 53 {
54 tree_statement_list *list = static_cast<tree_statement_list *> (ptr); 54 tree_statement_list *list = static_cast<tree_statement_list *> (ptr);
55 55
56 unwind_protect::begin_frame ("do_catch_code");
57
56 // Set up for letting the user print any messages from errors that 58 // Set up for letting the user print any messages from errors that
57 // occurred in the body of the try_catch statement. 59 // occurred in the body of the try_catch statement.
58 60
61 unwind_protect_bool (buffer_error_messages);
59 buffer_error_messages = false; 62 buffer_error_messages = false;
63
60 bind_global_error_variable (); 64 bind_global_error_variable ();
65
61 unwind_protect::add (clear_global_error_variable, 0); 66 unwind_protect::add (clear_global_error_variable, 0);
62 67
63 // Similarly, if we have seen a return or break statement, allow all 68 // Similarly, if we have seen a return or break statement, allow all
64 // the catch code to run before returning or handling the break. 69 // the catch code to run before returning or handling the break.
65 // We don't have to worry about continue statements because they can 70 // We don't have to worry about continue statements because they can
90 if (tree_return_command::returning) 95 if (tree_return_command::returning)
91 unwind_protect::discard (); 96 unwind_protect::discard ();
92 else 97 else
93 unwind_protect::run (); 98 unwind_protect::run ();
94 99
95 unwind_protect::run (); 100 unwind_protect::run_frame ("do_catch_code");
96 } 101 }
97 102
98 void 103 void
99 tree_try_catch_command::eval (void) 104 tree_try_catch_command::eval (void)
100 { 105 {
101 unwind_protect::begin_frame ("tree_try_catch::eval"); 106 unwind_protect::begin_frame ("tree_try_catch::eval");
102
103 unwind_protect::add (do_catch_code, catch_code);
104
105 bool old_buffer_error_messages = buffer_error_messages;
106 107
107 if (catch_code) 108 if (catch_code)
108 { 109 {
109 unwind_protect_bool (buffer_error_messages); 110 unwind_protect_bool (buffer_error_messages);
110 buffer_error_messages = true; 111 buffer_error_messages = true;
111 } 112 }
112 113
114 unwind_protect::add (do_catch_code, catch_code);
115
113 if (try_code) 116 if (try_code)
114 try_code->eval (); 117 try_code->eval ();
115 118
116 if (catch_code && error_state) 119 if (catch_code && error_state)
117 { 120 {
119 unwind_protect::run_frame ("tree_try_catch::eval"); 122 unwind_protect::run_frame ("tree_try_catch::eval");
120 } 123 }
121 else 124 else
122 { 125 {
123 error_state = 0; 126 error_state = 0;
124 buffer_error_messages = old_buffer_error_messages; 127
125 unwind_protect::discard_frame ("tree_try_catch::eval"); 128 // For clearing the do_catch_code cleanup function.
129 unwind_protect::discard ();
130
131 // For restoring buffer_error_messages.
132 unwind_protect::run ();
126 } 133 }
127 } 134 }
128 135
129 void 136 void
130 tree_try_catch_command::accept (tree_walker& tw) 137 tree_try_catch_command::accept (tree_walker& tw)