[vala/staging] semanticanalyzer: Transform replaced_nodes field into method



commit f9c196100e0ff8a2001609dd90eca2bfb6bb5ed1
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Thu Dec 14 20:15:29 2017 +0100

    semanticanalyzer: Transform replaced_nodes field into method

 vala/valaassignment.vala       |    2 +-
 vala/valamethodcall.vala       |    2 +-
 vala/valasemanticanalyzer.vala |    8 +++++++-
 vala/valatemplate.vala         |    2 +-
 vala/valaunaryexpression.vala  |    2 +-
 5 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/vala/valaassignment.vala b/vala/valaassignment.vala
index 761a02e..6f9f07b 100644
--- a/vala/valaassignment.vala
+++ b/vala/valaassignment.vala
@@ -133,7 +133,7 @@ public class Vala.Assignment : Expression {
                                i++;
                        }
 
-                       context.analyzer.replaced_nodes.add (this);
+                       context.analyzer.add_replaced_node (this);
                        parent_node.replace_expression (this, stmt.expression);
                        return stmt.expression.check (context);
                }
diff --git a/vala/valamethodcall.vala b/vala/valamethodcall.vala
index 76f2403..3080ae5 100644
--- a/vala/valamethodcall.vala
+++ b/vala/valamethodcall.vala
@@ -295,7 +295,7 @@ public class Vala.MethodCall : Expression {
                                struct_creation_expression.add_argument (arg);
                        }
                        struct_creation_expression.target_type = target_type;
-                       context.analyzer.replaced_nodes.add (this);
+                       context.analyzer.add_replaced_node (this);
                        parent_node.replace_expression (this, struct_creation_expression);
                        struct_creation_expression.check (context);
                        return true;
diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala
index 5424d7f..20e68eb 100644
--- a/vala/valasemanticanalyzer.vala
+++ b/vala/valasemanticanalyzer.vala
@@ -165,7 +165,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
 
        // keep replaced alive to make sure they remain valid
        // for the whole execution of CodeNode.accept
-       public List<CodeNode> replaced_nodes = new ArrayList<CodeNode> ();
+       List<CodeNode> replaced_nodes;
 
        public SemanticAnalyzer () {
        }
@@ -177,6 +177,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
         */
        public void analyze (CodeContext context) {
                this.context = context;
+               replaced_nodes = new ArrayList<CodeNode> ();
 
                var root_symbol = context.root;
 
@@ -222,9 +223,14 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                context.root.check (context);
                context.accept (this);
 
+               replaced_nodes = null;
                this.context = null;
        }
 
+       public void add_replaced_node (CodeNode node) {
+               replaced_nodes.add (node);
+       }
+
        public override void visit_source_file (SourceFile file) {
                current_source_file = file;
 
diff --git a/vala/valatemplate.vala b/vala/valatemplate.vala
index 5e27a7b..514e716 100644
--- a/vala/valatemplate.vala
+++ b/vala/valatemplate.vala
@@ -81,7 +81,7 @@ public class Vala.Template : Expression {
                }
                expr.target_type = target_type;
 
-               context.analyzer.replaced_nodes.add (this);
+               context.analyzer.add_replaced_node (this);
                parent_node.replace_expression (this, expr);
                return expr.check (context);
        }
diff --git a/vala/valaunaryexpression.vala b/vala/valaunaryexpression.vala
index 95b0d4f..650e41c 100644
--- a/vala/valaunaryexpression.vala
+++ b/vala/valaunaryexpression.vala
@@ -224,7 +224,7 @@ public class Vala.UnaryExpression : Expression {
 
                        var assignment = new Assignment (ma, bin, AssignmentOperator.SIMPLE, 
source_reference);
                        assignment.target_type = target_type;
-                       context.analyzer.replaced_nodes.add (this);
+                       context.analyzer.add_replaced_node (this);
                        parent_node.replace_expression (this, assignment);
                        assignment.check (context);
                        return true;


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