2982
|
1 /* |
|
2 |
|
3 Copyright (C) 1996, 1997 John W. Eaton |
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_tree_except_h) |
|
24 #define octave_tree_except_h 1 |
|
25 |
|
26 #if defined (__GNUG__) |
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 class tree_statement_list; |
|
31 |
|
32 class tree_walker; |
|
33 |
|
34 #include "pt-cmd.h" |
|
35 |
|
36 // Simple exception handling. |
|
37 |
|
38 class |
|
39 tree_try_catch_command : public tree_command |
|
40 { |
|
41 public: |
|
42 |
|
43 tree_try_catch_command (int l = -1, int c = -1) |
|
44 : tree_command (l, c), try_code (0), catch_code (0) { } |
|
45 |
|
46 tree_try_catch_command (tree_statement_list *tc, tree_statement_list *cc, |
|
47 int l = -1, int c = -1) |
|
48 : tree_command (l, c), try_code (tc), catch_code (cc) { } |
|
49 |
|
50 ~tree_try_catch_command (void); |
|
51 |
|
52 void eval (void); |
|
53 |
|
54 tree_statement_list *body (void) { return try_code; } |
|
55 |
|
56 tree_statement_list *cleanup (void) { return catch_code; } |
|
57 |
|
58 void accept (tree_walker& tw); |
|
59 |
|
60 private: |
|
61 |
|
62 // The first block of code to attempt to execute. |
|
63 tree_statement_list *try_code; |
|
64 |
|
65 // The code to execute if an error occurs in the first block. |
|
66 tree_statement_list *catch_code; |
2988
|
67 |
|
68 // No copying! |
|
69 |
|
70 tree_try_catch_command (const tree_try_catch_command&); |
|
71 |
|
72 tree_try_catch_command& operator = (const tree_try_catch_command&); |
2982
|
73 }; |
|
74 |
|
75 // Simple exception handling. |
|
76 |
|
77 class |
|
78 tree_unwind_protect_command : public tree_command |
|
79 { |
|
80 public: |
|
81 |
|
82 tree_unwind_protect_command (int l = -1, int c = -1) |
|
83 : tree_command (l, c), unwind_protect_code (0), cleanup_code (0) { } |
|
84 |
|
85 tree_unwind_protect_command (tree_statement_list *tc, |
|
86 tree_statement_list *cc, |
|
87 int l = -1, int c = -1) |
|
88 : tree_command (l, c), unwind_protect_code (tc), cleanup_code (cc) { } |
|
89 |
|
90 ~tree_unwind_protect_command (void); |
|
91 |
|
92 void eval (void); |
|
93 |
|
94 tree_statement_list *body (void) { return unwind_protect_code; } |
|
95 |
|
96 tree_statement_list *cleanup (void) { return cleanup_code; } |
|
97 |
|
98 void accept (tree_walker& tw); |
|
99 |
|
100 private: |
|
101 |
|
102 // The first body of code to attempt to execute. |
|
103 tree_statement_list *unwind_protect_code; |
|
104 |
|
105 // The body of code to execute no matter what happens in the first |
|
106 // body of code. |
|
107 tree_statement_list *cleanup_code; |
2988
|
108 |
|
109 // No copying! |
|
110 |
|
111 tree_unwind_protect_command (const tree_unwind_protect_command&); |
|
112 |
|
113 tree_unwind_protect_command& operator = (const tree_unwind_protect_command&); |
2982
|
114 }; |
|
115 |
|
116 #endif |
|
117 |
|
118 /* |
|
119 ;;; Local Variables: *** |
|
120 ;;; mode: C++ *** |
|
121 ;;; End: *** |
|
122 */ |