Mercurial > hg > octave-lyh
annotate src/pt-except.h @ 8551:906f976d35a8
further improve struct&cell indexing & indexed assignment
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Wed, 21 Jan 2009 13:02:49 +0100 |
parents | 71f068b22fcc |
children | 73c4516fae10 |
rev | line source |
---|---|
2982 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1996, 1997, 2000, 2002, 2004, 2005, 2006, 2007 |
4 John W. Eaton | |
2982 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
2982 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
2982 | 21 |
22 */ | |
23 | |
24 #if !defined (octave_tree_except_h) | |
25 #define octave_tree_except_h 1 | |
26 | |
27 class tree_statement_list; | |
28 | |
29 class tree_walker; | |
30 | |
3665 | 31 #include "comment-list.h" |
2982 | 32 #include "pt-cmd.h" |
7336 | 33 #include "symtab.h" |
2982 | 34 |
35 // Simple exception handling. | |
36 | |
37 class | |
38 tree_try_catch_command : public tree_command | |
39 { | |
40 public: | |
41 | |
42 tree_try_catch_command (int l = -1, int c = -1) | |
3665 | 43 : tree_command (l, c), try_code (0), catch_code (0), lead_comm (0), |
44 mid_comm (0), trail_comm (0) { } | |
2982 | 45 |
46 tree_try_catch_command (tree_statement_list *tc, tree_statement_list *cc, | |
3665 | 47 octave_comment_list *cl = 0, |
48 octave_comment_list *cm = 0, | |
49 octave_comment_list *ct = 0, | |
2982 | 50 int l = -1, int c = -1) |
3665 | 51 : tree_command (l, c), try_code (tc), catch_code (cc), |
52 lead_comm (cl), mid_comm (cm), trail_comm (ct) { } | |
2982 | 53 |
54 ~tree_try_catch_command (void); | |
55 | |
56 void eval (void); | |
57 | |
58 tree_statement_list *body (void) { return try_code; } | |
59 | |
60 tree_statement_list *cleanup (void) { return catch_code; } | |
61 | |
3665 | 62 octave_comment_list *leading_comment (void) { return lead_comm; } |
63 | |
64 octave_comment_list *middle_comment (void) { return mid_comm; } | |
65 | |
66 octave_comment_list *trailing_comment (void) { return trail_comm; } | |
67 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
68 tree_command *dup (symbol_table::scope_id scope, |
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
69 symbol_table::context_id context); |
5861 | 70 |
2982 | 71 void accept (tree_walker& tw); |
72 | |
73 private: | |
74 | |
75 // The first block of code to attempt to execute. | |
76 tree_statement_list *try_code; | |
77 | |
78 // The code to execute if an error occurs in the first block. | |
79 tree_statement_list *catch_code; | |
2988 | 80 |
3665 | 81 // Comment preceding TRY token. |
82 octave_comment_list *lead_comm; | |
83 | |
84 // Comment preceding CATCH token. | |
85 octave_comment_list *mid_comm; | |
86 | |
87 // Comment preceding END_TRY_CATCH token. | |
88 octave_comment_list *trail_comm; | |
89 | |
2988 | 90 // No copying! |
91 | |
92 tree_try_catch_command (const tree_try_catch_command&); | |
93 | |
94 tree_try_catch_command& operator = (const tree_try_catch_command&); | |
2982 | 95 }; |
96 | |
97 // Simple exception handling. | |
98 | |
99 class | |
100 tree_unwind_protect_command : public tree_command | |
101 { | |
102 public: | |
103 | |
104 tree_unwind_protect_command (int l = -1, int c = -1) | |
3665 | 105 : tree_command (l, c), unwind_protect_code (0), cleanup_code (0), |
106 lead_comm (0), mid_comm (0), trail_comm (0) { } | |
2982 | 107 |
108 tree_unwind_protect_command (tree_statement_list *tc, | |
109 tree_statement_list *cc, | |
3665 | 110 octave_comment_list *cl = 0, |
111 octave_comment_list *cm = 0, | |
112 octave_comment_list *ct = 0, | |
2982 | 113 int l = -1, int c = -1) |
3665 | 114 : tree_command (l, c), unwind_protect_code (tc), cleanup_code (cc), |
115 lead_comm (cl), mid_comm (cm), trail_comm (ct) { } | |
2982 | 116 |
117 ~tree_unwind_protect_command (void); | |
118 | |
119 void eval (void); | |
120 | |
121 tree_statement_list *body (void) { return unwind_protect_code; } | |
122 | |
123 tree_statement_list *cleanup (void) { return cleanup_code; } | |
124 | |
3665 | 125 octave_comment_list *leading_comment (void) { return lead_comm; } |
126 | |
127 octave_comment_list *middle_comment (void) { return mid_comm; } | |
128 | |
129 octave_comment_list *trailing_comment (void) { return trail_comm; } | |
130 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
131 tree_command *dup (symbol_table::scope_id scope, |
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
132 symbol_table::context_id context); |
5861 | 133 |
2982 | 134 void accept (tree_walker& tw); |
135 | |
136 private: | |
137 | |
138 // The first body of code to attempt to execute. | |
139 tree_statement_list *unwind_protect_code; | |
140 | |
141 // The body of code to execute no matter what happens in the first | |
142 // body of code. | |
143 tree_statement_list *cleanup_code; | |
2988 | 144 |
3665 | 145 // Comment preceding TRY token. |
146 octave_comment_list *lead_comm; | |
147 | |
148 // Comment preceding CATCH token. | |
149 octave_comment_list *mid_comm; | |
150 | |
151 // Comment preceding END_TRY_CATCH token. | |
152 octave_comment_list *trail_comm; | |
153 | |
2988 | 154 // No copying! |
155 | |
156 tree_unwind_protect_command (const tree_unwind_protect_command&); | |
157 | |
158 tree_unwind_protect_command& operator = (const tree_unwind_protect_command&); | |
2982 | 159 }; |
160 | |
161 #endif | |
162 | |
163 /* | |
164 ;;; Local Variables: *** | |
165 ;;; mode: C++ *** | |
166 ;;; End: *** | |
167 */ |