[vala/staging: 5/6] Release taken references to CodeContext after using it



commit 2dc47785171f8f62f7f017939681e0d5cf3e9847
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Thu Dec 14 10:23:14 2017 +0100

    Release taken references to CodeContext after using it
    
    https://bugzilla.gnome.org/show_bug.cgi?id=712694

 codegen/valaccodebasemodule.vala |    3 +++
 codegen/valagirwriter.vala       |    3 +++
 vala/valaflowanalyzer.vala       |    2 ++
 vala/valagenieparser.vala        |    1 +
 vala/valagirparser.vala          |    2 ++
 vala/valaparser.vala             |    1 +
 vala/valasemanticanalyzer.vala   |    7 ++++---
 vala/valasymbolresolver.vala     |    3 +++
 8 files changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index f99acce..56ff942 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -526,6 +526,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                        var stream = FileStream.open (context.symbols_filename, "w");
                        if (stream == null) {
                                Report.error (null, "unable to open `%s' for writing".printf 
(context.symbols_filename));
+                               this.context = null;
                                return;
                        }
 
@@ -552,6 +553,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                                Report.error (null, "unable to open `%s' for writing".printf 
(context.internal_header_filename));
                        }
                }
+
+               this.context = null;
        }
 
        public void push_context (EmitContext emit_context) {
diff --git a/codegen/valagirwriter.vala b/codegen/valagirwriter.vala
index 47e1d2a..bd814f0 100644
--- a/codegen/valagirwriter.vala
+++ b/codegen/valagirwriter.vala
@@ -165,6 +165,7 @@ public class Vala.GIRWriter : CodeVisitor {
                stream = FileStream.open (filename, "w");
                if (stream == null) {
                        Report.error (null, "unable to open `%s' for writing".printf (filename));
+                       this.context = null;
                        return;
                }
 
@@ -196,6 +197,8 @@ public class Vala.GIRWriter : CodeVisitor {
                if (our_namespaces.size == 0) {
                        Report.error (null, "No suitable namespace found to export for GIR");
                }
+
+               this.context = null;
        }
 
        private void write_doc (string? comment) {
diff --git a/vala/valaflowanalyzer.vala b/vala/valaflowanalyzer.vala
index 3683b81..122e58d 100644
--- a/vala/valaflowanalyzer.vala
+++ b/vala/valaflowanalyzer.vala
@@ -112,6 +112,8 @@ public class Vala.FlowAnalyzer : CodeVisitor {
                                file.accept (this);
                        }
                }
+
+               this.context = null;
        }
 
        public override void visit_source_file (SourceFile source_file) {
diff --git a/vala/valagenieparser.vala b/vala/valagenieparser.vala
index df4f66e..f9aba46 100644
--- a/vala/valagenieparser.vala
+++ b/vala/valagenieparser.vala
@@ -86,6 +86,7 @@ public class Vala.Genie.Parser : CodeVisitor {
        public void parse (CodeContext context) {
                this.context = context;
                context.accept (this);
+               this.context = null;
        }
 
        public override void visit_source_file (SourceFile source_file) {
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index 0754e8d..edc580c 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -1327,6 +1327,8 @@ public class Vala.GirParser : CodeVisitor {
                foreach (var metadata in metadata_roots) {
                        report_unused_metadata (metadata);
                }
+
+               this.context = null;
        }
 
        void map_vala_to_gir () {
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index ec5e34e..6228ba9 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -76,6 +76,7 @@ public class Vala.Parser : CodeVisitor {
        public void parse (CodeContext context) {
                this.context = context;
                context.accept (this);
+               this.context = null;
        }
 
        public override void visit_source_file (SourceFile source_file) {
diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala
index a7bbb18..fce226b 100644
--- a/vala/valasemanticanalyzer.vala
+++ b/vala/valasemanticanalyzer.vala
@@ -28,9 +28,8 @@ using GLib;
  * Code visitor analyzing and checking code.
  */
 public class Vala.SemanticAnalyzer : CodeVisitor {
-       public CodeContext context { get; set; }
+       CodeContext context;
 
-       public Symbol root_symbol;
        public Symbol current_symbol { get; set; }
        public SourceFile current_source_file { get; set; }
 
@@ -181,7 +180,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
        public void analyze (CodeContext context) {
                this.context = context;
 
-               root_symbol = context.root;
+               var root_symbol = context.root;
 
                bool_type = new BooleanType ((Struct) root_symbol.scope.lookup ("bool"));
                string_type = new ObjectType ((Class) root_symbol.scope.lookup ("string"));
@@ -224,6 +223,8 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                current_symbol = root_symbol;
                context.root.check (context);
                context.accept (this);
+
+               this.context = null;
        }
 
        public override void visit_source_file (SourceFile file) {
diff --git a/vala/valasymbolresolver.vala b/vala/valasymbolresolver.vala
index 32c84e4..53ad728 100644
--- a/vala/valasymbolresolver.vala
+++ b/vala/valasymbolresolver.vala
@@ -42,6 +42,9 @@ public class Vala.SymbolResolver : CodeVisitor {
                root_symbol = context.root;
 
                context.root.accept (this);
+
+               root_symbol = null;
+               this.context = null;
        }
        
        public override void visit_namespace (Namespace ns) {


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