Commit ab1d99cd authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

support exception handling in constructors, avoid error when not using

2007-07-12  Juerg Billeter  <j@bitron.ch>

	* gobject/valacodegenerator.vala: support exception handling in
	  constructors, avoid error when not using finally blocks

svn path=/trunk/; revision=351
parent f3438e1c
2007-07-12 Jürg Billeter <j@bitron.ch>
* gobject/valacodegenerator.vala: support exception handling in
constructors, avoid error when not using finally blocks
2007-07-12 Jürg Billeter <j@bitron.ch>
* vala/parser.y: allow delegates to throw exceptions
......
......@@ -584,6 +584,8 @@ public class Vala.CodeGenerator : CodeVisitor {
}
public override void visit_constructor (Constructor! c) {
current_method_inner_error = false;
c.accept_children (this);
var cl = (Class) c.symbol.parent_symbol.node;
......@@ -640,6 +642,15 @@ public class Vala.CodeGenerator : CodeVisitor {
cblock.add_statement (cdecl);
if (current_method_inner_error) {
/* always separate error parameter and inner_error local variable
* as error may be set to NULL but we're always interested in inner errors
*/
var cdecl = new CCodeDeclaration ("GError *");
cdecl.add_declarator (new CCodeVariableDeclarator.with_initializer ("inner_error", new CCodeConstant ("NULL")));
cblock.add_statement (cdecl);
}
cblock.add_statement (c.body.ccodenode);
......@@ -1577,6 +1588,9 @@ public class Vala.CodeGenerator : CodeVisitor {
cfrag.append (new CCodeLabel ("__finally%d".printf (next_try_id)));
if (stmt.finally_body != null) {
cfrag.append (stmt.finally_body.ccodenode);
} else {
// avoid gcc error: label at end of compound statement
cfrag.append (new CCodeEmptyStatement ());
}
stmt.ccodenode = cfrag;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment