[vala/0.46] vala: Handle all ctors and dtors in CodeWriter



commit 3969f5e3462df539dd064d2b7b0c6a2e4a67e18d
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sun Mar 29 14:30:49 2020 +0200

    vala: Handle all ctors and dtors in CodeWriter

 vala/valacodewriter.vala | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)
---
diff --git a/vala/valacodewriter.vala b/vala/valacodewriter.vala
index 238a74c36..da6103033 100644
--- a/vala/valacodewriter.vala
+++ b/vala/valacodewriter.vala
@@ -283,6 +283,26 @@ public class Vala.CodeWriter : CodeVisitor {
                        cl.constructor.accept (this);
                }
 
+               if (cl.class_constructor != null) {
+                       cl.class_constructor.accept (this);
+               }
+
+               if (cl.static_constructor != null) {
+                       cl.static_constructor.accept (this);
+               }
+
+               if (cl.destructor != null) {
+                       cl.destructor.accept (this);
+               }
+
+               if (cl.static_destructor != null) {
+                       cl.static_destructor.accept (this);
+               }
+
+               if (cl.class_destructor != null) {
+                       cl.class_destructor.accept (this);
+               }
+
                current_scope = current_scope.parent_scope;
 
                write_end_block ();
@@ -725,11 +745,39 @@ public class Vala.CodeWriter : CodeVisitor {
                }
 
                write_indent ();
+               if (c.binding == MemberBinding.STATIC) {
+                       write_string ("static ");
+               } else if (c.binding == MemberBinding.CLASS) {
+                       write_string ("class ");
+               }
                write_string ("construct");
                write_code_block (c.body);
                write_newline ();
        }
 
+       public override void visit_destructor (Destructor d) {
+               if (type != CodeWriterType.DUMP) {
+                       return;
+               }
+
+               if (context.vapi_comments && d.comment != null) {
+                       write_comment (d.comment);
+               }
+
+               write_indent ();
+               if (d.binding == MemberBinding.STATIC) {
+                       write_string ("static ");
+               } else if (d.binding == MemberBinding.CLASS) {
+                       write_string ("class ");
+               }
+               write_string ("~");
+               var datatype = (TypeSymbol) d.parent_symbol;
+               write_identifier (datatype.name);
+               write_string (" () ");
+               write_code_block (d.body);
+               write_newline ();
+       }
+
        public override void visit_method (Method m) {
                if (m.external_package) {
                        return;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]