]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Move next_lambda_id into LambdaExpression
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 14 Dec 2017 18:45:51 +0000 (19:45 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Fri, 15 Dec 2017 08:00:23 +0000 (09:00 +0100)
vala/valalambdaexpression.vala
vala/valasemanticanalyzer.vala

index d194eca6f8514e57c31b8abd3663e809000745bd..a3ee20a2fa14ed811225e2d2b8a72fe597ec8520 100644 (file)
@@ -27,6 +27,8 @@ using GLib;
  * anonymous methods with implicitly typed parameters.
  */
 public class Vala.LambdaExpression : Expression {
+       private static int next_lambda_id = 0;
+
        /**
         * The expression body of this lambda expression. Only one of
         * expression_body or statement_body may be set.
@@ -111,14 +113,6 @@ public class Vala.LambdaExpression : Expression {
                return false;
        }
 
-       string get_lambda_name (CodeContext context) {
-               var result = "_lambda%d_".printf (context.analyzer.next_lambda_id);
-
-               context.analyzer.next_lambda_id++;
-
-               return result;
-       }
-
        public override bool check (CodeContext context) {
                if (checked) {
                        return !error;
@@ -138,7 +132,7 @@ public class Vala.LambdaExpression : Expression {
 
                var cb = (Delegate) ((DelegateType) target_type).delegate_symbol;
                var return_type = cb.return_type.get_actual_type (target_type, null, this);
-               method = new Method (get_lambda_name (context), return_type, source_reference);
+               method = new Method ("_lambda%d_".printf (next_lambda_id++), return_type, source_reference);
                // track usage for flow analyzer
                method.used = true;
                method.version.check (source_reference);
index 9bf704594a4ef6b11f12cd0575cf4baf1143c827..5424d7fd0b718fdb7cd99fcbc3c98dca020d397b 100644 (file)
@@ -163,8 +163,6 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
        public DataType error_type;
        public Class gsource_type;
 
-       public int next_lambda_id = 0;
-
        // keep replaced alive to make sure they remain valid
        // for the whole execution of CodeNode.accept
        public List<CodeNode> replaced_nodes = new ArrayList<CodeNode> ();