[vala] Fix error handling in catch clauses
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Subject: [vala] Fix error handling in catch clauses
- Date: Tue, 28 Jul 2009 21:22:04 +0000 (UTC)
commit 5177233e8e57476c158eb0c35f30130f7634697f
Author: JiÅ?à Zárevúcky <zarevucky jiri gmail com>
Date: Tue Jul 28 23:17:34 2009 +0200
Fix error handling in catch clauses
codegen/valagerrormodule.vala | 56 +++++++++++++++++++++-------------------
1 files changed, 29 insertions(+), 27 deletions(-)
---
diff --git a/codegen/valagerrormodule.vala b/codegen/valagerrormodule.vala
index 649f6dd..cadaf8c 100644
--- a/codegen/valagerrormodule.vala
+++ b/codegen/valagerrormodule.vala
@@ -170,7 +170,7 @@ internal class Vala.GErrorModule : CCodeDelegateModule {
CCodeStatement cerror_handler = null;
- if (current_try != null && !is_in_catch) {
+ if (current_try != null) {
// surrounding try found
var cerror_block = new CCodeBlock ();
@@ -179,34 +179,36 @@ internal class Vala.GErrorModule : CCodeDelegateModule {
append_error_free (current_symbol, free_frag, current_try);
cerror_block.add_statement (free_frag);
- foreach (CatchClause clause in current_try.get_catch_clauses ()) {
- // go to catch clause if error domain matches
- var cgoto_stmt = new CCodeGotoStatement (clause.clabel_name);
+ if (!is_in_catch) {
+ foreach (CatchClause clause in current_try.get_catch_clauses ()) {
+ // go to catch clause if error domain matches
+ var cgoto_stmt = new CCodeGotoStatement (clause.clabel_name);
- if (clause.error_type.equals (gerror_type)) {
- // general catch clause, this should be the last one
- cerror_block.add_statement (cgoto_stmt);
- break;
- } else {
- var catch_type = clause.error_type as ErrorType;
- var cgoto_block = new CCodeBlock ();
- cgoto_block.add_statement (cgoto_stmt);
-
- if (catch_type.error_code != null) {
- /* catch clause specifies a specific error code */
- var error_match = new CCodeFunctionCall (new CCodeIdentifier ("g_error_matches"));
- error_match.add_argument (inner_error);
- error_match.add_argument (new CCodeIdentifier (catch_type.data_type.get_upper_case_cname ()));
- error_match.add_argument (new CCodeIdentifier (catch_type.error_code.get_cname ()));
-
- cerror_block.add_statement (new CCodeIfStatement (error_match, cgoto_block));
+ if (clause.error_type.equals (gerror_type)) {
+ // general catch clause, this should be the last one
+ cerror_block.add_statement (cgoto_stmt);
+ break;
} else {
- /* catch clause specifies a full error domain */
- var ccond = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY,
- new CCodeMemberAccess.pointer (inner_error, "domain"), new CCodeIdentifier
- (clause.error_type.data_type.get_upper_case_cname ()));
-
- cerror_block.add_statement (new CCodeIfStatement (ccond, cgoto_block));
+ var catch_type = clause.error_type as ErrorType;
+ var cgoto_block = new CCodeBlock ();
+ cgoto_block.add_statement (cgoto_stmt);
+
+ if (catch_type.error_code != null) {
+ /* catch clause specifies a specific error code */
+ var error_match = new CCodeFunctionCall (new CCodeIdentifier ("g_error_matches"));
+ error_match.add_argument (inner_error);
+ error_match.add_argument (new CCodeIdentifier (catch_type.data_type.get_upper_case_cname ()));
+ error_match.add_argument (new CCodeIdentifier (catch_type.error_code.get_cname ()));
+
+ cerror_block.add_statement (new CCodeIfStatement (error_match, cgoto_block));
+ } else {
+ /* catch clause specifies a full error domain */
+ var ccond = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY,
+ new CCodeMemberAccess.pointer (inner_error, "domain"), new CCodeIdentifier
+ (clause.error_type.data_type.get_upper_case_cname ()));
+
+ cerror_block.add_statement (new CCodeIfStatement (ccond, cgoto_block));
+ }
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]