2008-05-02 Jürg Billeter <j@bitron.ch>
+ * vala/valacatchclause.vala:
+ * gobject/valaccodegenerator.vala:
+
+ Fix error handling in catch and finally clauses, fixes bug 530212
+
+2008-05-02 Jürg Billeter <j@bitron.ch>
+
* vapi/glib-2.0.vapi: fix g_rand*_int and g_rand*_double bindings,
patch Ondrej Jirman, fixes bug 530207
var cerror_block = new CCodeBlock ();
foreach (CatchClause clause in current_try.get_catch_clauses ()) {
// go to catch clause if error domain matches
- var cgoto_stmt = new CCodeGotoStatement ("__catch%d_%s".printf (current_try_id, clause.error_type.get_lower_case_cname ()));
+ var cgoto_stmt = new CCodeGotoStatement (clause.clabel_name);
if (clause.error_type.equals (gerror_type)) {
// general catch clause
}
public override void visit_try_statement (TryStatement stmt) {
+ int this_try_id = next_try_id++;
+
var old_try = current_try;
var old_try_id = current_try_id;
current_try = stmt;
- current_try_id = next_try_id++;
+ current_try_id = this_try_id;
- stmt.accept_children (this);
+ foreach (CatchClause clause in stmt.get_catch_clauses ()) {
+ clause.clabel_name = "__catch%d_%s".printf (this_try_id, clause.error_type.get_lower_case_cname ());
+ }
+
+ if (stmt.finally_body != null) {
+ stmt.finally_body.accept (this);
+ }
+
+ stmt.body.accept (this);
+
+ current_try = old_try;
+ current_try_id = old_try_id;
+
+ foreach (CatchClause clause in stmt.get_catch_clauses ()) {
+ clause.accept (this);
+ }
+
+ if (stmt.finally_body != null) {
+ stmt.finally_body.accept (this);
+ }
var cfrag = new CCodeFragment ();
cfrag.append (stmt.body.ccodenode);
foreach (CatchClause clause in stmt.get_catch_clauses ()) {
- cfrag.append (new CCodeGotoStatement ("__finally%d".printf (current_try_id)));
+ cfrag.append (new CCodeGotoStatement ("__finally%d".printf (this_try_id)));
cfrag.append (clause.ccodenode);
}
- cfrag.append (new CCodeLabel ("__finally%d".printf (current_try_id)));
+ cfrag.append (new CCodeLabel ("__finally%d".printf (this_try_id)));
if (stmt.finally_body != null) {
cfrag.append (stmt.finally_body.ccodenode);
} else {
}
stmt.ccodenode = cfrag;
-
- current_try = old_try;
- current_try_id = old_try_id;
}
public override void visit_catch_clause (CatchClause clause) {
clause.accept_children (this);
var cfrag = new CCodeFragment ();
- cfrag.append (new CCodeLabel ("__catch%d_%s".printf (current_try_id, clause.error_type.get_lower_case_cname ())));
+ cfrag.append (new CCodeLabel (clause.clabel_name));
var cblock = new CCodeBlock ();