}
}
+ if (is_in_constructor () || is_in_destructor ()) {
+ return void_type;
+ }
+
return null;
}
}
+ bool is_in_constructor () {
+ var sym = current_symbol;
+ while (sym != null) {
+ if (sym is Constructor) {
+ return true;
+ }
+ sym = sym.parent_symbol;
+ }
+ return false;
+ }
+
+ bool is_in_destructor () {
+ var sym = current_symbol;
+ while (sym != null) {
+ if (sym is Destructor) {
+ return true;
+ }
+ sym = sym.parent_symbol;
+ }
+ return false;
+ }
+
public Block? current_closure_block {
get {
return next_closure_block (current_symbol);
}
}
- if (current_method is CreationMethod) {
+ if (is_in_constructor ()) {
+ ccode.add_return (new CCodeIdentifier ("obj"));
+ } else if (is_in_destructor ()) {
+ // do not call return as member cleanup and chain up to base finalizer
+ // stil need to be executed
+ ccode.add_goto ("_return");
+ } else if (current_method is CreationMethod) {
ccode.add_return (new CCodeIdentifier ("self"));
} else if (current_method != null && current_method.coroutine) {
} else if (current_return_type is VoidType || current_return_type.is_real_non_null_struct_type ()) {
if (current_method_inner_error) {
ccode.add_declaration ("GError *", new CCodeVariableDeclarator.zero ("_inner_error_", new CCodeConstant ("NULL")));
}
+
+ // support return statements in destructors
+ ccode.add_label ("_return");
}
pop_context ();
}
}
+ if (is_in_constructor () || is_in_destructor ()) {
+ return void_type;
+ }
+
return null;
}
}
}
return false;
}
+
+ public bool is_in_destructor () {
+ var sym = current_symbol;
+ while (sym != null) {
+ if (sym is Destructor) {
+ return true;
+ }
+ sym = sym.parent_symbol;
+ }
+ return false;
+ }
}