[vala/wip/issue/1329: 2/4] codegen: Make sure to initialize static collections




commit b98d970f52c7094c70cd65c8c9624e6b7a85bfc3
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Tue Jun 14 15:31:17 2022 +0200

    codegen: Make sure to initialize static collections

 codegen/valaccode.vala           | 3 +++
 codegen/valaccodebasemodule.vala | 8 ++++++++
 2 files changed, 11 insertions(+)
---
diff --git a/codegen/valaccode.vala b/codegen/valaccode.vala
index 25a0d11af..30d196b9e 100644
--- a/codegen/valaccode.vala
+++ b/codegen/valaccode.vala
@@ -26,6 +26,9 @@ namespace Vala {
        static unowned CCodeAttribute get_ccode_attribute (CodeNode node) {
                if (ccode_attribute_cache_index == null) {
                        ccode_attribute_cache_index = CodeNode.get_attribute_cache_index ();
+
+                       // make sure static collections are initialized
+                       CCodeBaseModule.init ();
                }
 
                unowned AttributeCache? attr = node.get_attribute_cache (ccode_attribute_cache_index);
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 121344373..c30f0dae9 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -405,6 +405,14 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                predefined_marshal_set.add ("VOID:VARIANT");
                predefined_marshal_set.add ("BOOLEAN:BOXED,BOXED");
 
+               init ();
+       }
+
+       public static void init () {
+               if (reserved_identifiers != null) {
+                       return;
+               }
+
                reserved_identifiers = new HashSet<string> (str_hash, str_equal);
 
                // C99 keywords


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