]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Use CatchClause.error_variable instead of variable_name
authorLuca Bruno <lucabru@src.gnome.org>
Fri, 22 Apr 2011 20:05:31 +0000 (22:05 +0200)
committerLuca Bruno <lucabru@src.gnome.org>
Wed, 27 Apr 2011 19:43:58 +0000 (21:43 +0200)
codegen/valagerrormodule.vala
vala/valacatchclause.vala

index 70d335d56340211d70a18536061d627928c54274..75e9a78fb8deec4f164ca330ab25558427427d2f 100644 (file)
@@ -345,20 +345,9 @@ public class Vala.GErrorModule : CCodeDelegateModule {
 
                ccode.open_block ();
 
-               string variable_name;
-               if (clause.variable_name != null) {
-                       variable_name = get_variable_cname (clause.variable_name);
-               } else {
-                       variable_name = "__err";
-               }
-
-               if (clause.variable_name != null) {
-                       if (is_in_coroutine ()) {
-                               closure_struct.add_field ("GError *", variable_name);
-                       } else {
-                               ccode.add_declaration ("GError *", new CCodeVariableDeclarator (variable_name));
-                       }
-                       ccode.add_assignment (get_variable_cexpression (variable_name), get_variable_cexpression ("_inner_error_"));
+               if (clause.error_variable != null) {
+                       visit_local_variable (clause.error_variable);
+                       ccode.add_assignment (get_variable_cexpression (clause.error_variable.name), get_variable_cexpression ("_inner_error_"));
                } else {
                        // error object is not used within catch statement, clear it
                        var cclear = new CCodeFunctionCall (new CCodeIdentifier ("g_clear_error"));
index 72c9d84682025d2bf40160765687b6b6b65fad0a..46b4e0fa2fd2d74535f4da6ae4feda003659af0f 100644 (file)
@@ -117,12 +117,14 @@ public class Vala.CatchClause : CodeNode {
                checked = true;
 
                if (error_type != null) {
-                       error_variable = new LocalVariable (error_type.copy (), variable_name);
+                       if (variable_name != null) {
+                               error_variable = new LocalVariable (error_type.copy (), variable_name);
 
-                       body.scope.add (variable_name, error_variable);
-                       body.add_local_variable (error_variable);
+                               body.scope.add (variable_name, error_variable);
+                               body.add_local_variable (error_variable);
 
-                       error_variable.checked = true;
+                               error_variable.checked = true;
+                       }
                } else {
                        // generic catch clause
                        if (context.profile == Profile.GOBJECT) {