+2007-07-12 Jürg Billeter <j@bitron.ch>
+
+ * vala/parser.y, vala/valasemanticanalyzer.vala,
+ gobject/valacodegenerator.vala: allow construction methods to throw
+ exceptions, fix issue with multiple catch clauses
+
2007-07-12 Jürg Billeter <j@bitron.ch>
* vala/parser.y, vala/valacodenode.vala, vala/valaenum.vala,
var cfrag = new CCodeFragment ();
cfrag.append (stmt.body.ccodenode);
- cfrag.append (new CCodeGotoStatement ("__finally%d".printf (next_try_id)));
-
foreach (CatchClause clause in stmt.get_catch_clauses ()) {
+ cfrag.append (new CCodeGotoStatement ("__finally%d".printf (next_try_id)));
+
cfrag.append (clause.ccodenode);
}
params_it = params_it.next;
}
+ if (expr.can_fail) {
+ // method can fail
+ current_method_inner_error = true;
+ ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("inner_error")));
+ }
+
if (ellipsis) {
// ensure variable argument list ends with NULL
ccall.add_argument (new CCodeConstant ("NULL"));
g_object_unref ($5);
g_free ($6);
}
- | comment opt_attributes opt_access_modifier opt_modifiers identifier opt_name_specifier OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS
+ | comment opt_attributes opt_access_modifier opt_modifiers identifier opt_name_specifier OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS opt_throws_declaration
{
GList *l;
}
g_list_free ($8);
}
+
+ for (l = $10; l != NULL; l = l->next) {
+ vala_method_add_error_domain ($$, l->data);
+ g_object_unref (l->data);
+ }
+ if ($10 != NULL) {
+ g_list_free ($10);
+ }
}
;
if (expr.symbol_reference != null && expr.symbol_reference.node is Method) {
var m = (Method) expr.symbol_reference.node;
check_arguments (expr, m.symbol, m.get_parameters (), expr.get_argument_list ());
+
+ expr.tree_can_fail = expr.can_fail = (m.get_error_domains ().length () > 0);
} else if (type is Enum) {
if (expr.get_argument_list ().length () == 0) {
expr.error = true;