Ejemplo n.º 1
0
 public override bool Walk(ForIn node)
 {
     if (CheckBlock(node.Body))
     {
         Span = GetTargetStatement(node).GetSpan(_tree.LocationResolver);
         return(false);
     }
     return(base.Walk(node));
 }
Ejemplo n.º 2
0
        public virtual void Visit(ForIn node)
        {
            if (node != null)
            {
                if (node.Variable != null)
                {
                    node.Variable.Accept(this);
                }

                if (node.Collection != null)
                {
                    node.Collection.Accept(this);
                }

                if (node.Body != null)
                {
                    node.Body.Accept(this);
                }
            }
        }
Ejemplo n.º 3
0
        public override bool Walk(ForIn node)
        {
            var coll      = _eval.Evaluate(node.Collection);
            var variable  = node.Variable as Var;
            var lookupVar = node.Variable as ExpressionStatement;

            if (variable != null)
            {
                string varName = variable.First().Name;
                Debug.Assert(_eval.Scope.ContainsVariable(varName));
                var  prevVar    = _eval.Scope.GetVariable(node.Variable, _unit, varName);
                bool walkedBody = false;
                if (coll.Count == 1)
                {
                    foreach (var value in coll)
                    {
                        var values = value.GetEnumerationValues(node, _unit);
                        if (values.Count < 50)
                        {
                            walkedBody = true;
                            Debug.WriteLine(String.Format("Enumerating: {1} {0}", value, values.Count));

                            foreach (var individualValue in values)
                            {
                                var newVar = new LocalNonEnqueingVariableDef();
                                _eval.Scope.ReplaceVariable(variable.First().Name, newVar);

                                _eval.Scope.AssignVariable(
                                    varName,
                                    node,
                                    _unit,
                                    individualValue
                                    );
                                node.Body.Walk(this);
                                prevVar.AddTypes(
                                    _unit,
                                    newVar.GetTypesNoCopy(
                                        _unit.ProjectEntry,
                                        _unit.ProjectEntry
                                        )
                                    );
                            }
                        }
                    }
                }

                if (!walkedBody)
                {
                    foreach (var value in coll)
                    {
                        var values = value.GetEnumerationValues(node, _unit);
                        prevVar.AddTypes(
                            _unit,
                            values
                            );
                    }

                    // we replace the variable here so that we analyze w/ empty
                    // types, but we do the assignment so users get completions against
                    // anything in the for body.
                    var newVar = new LocalNonEnqueingVariableDef();
                    _eval.Scope.ReplaceVariable(variable.First().Name, newVar);

                    node.Body.Walk(this);
                }

                _eval.Scope.ReplaceVariable(varName, prevVar);
            }
            else if (lookupVar != null)
            {
                // TODO: _eval.AssignTo(node, lookupVar.Expression, values);
                node.Body.Walk(this);
            }


            return(false);
        }
Ejemplo n.º 4
0
 internal protected virtual T Visit(ForIn node)
 {
     return(Visit(node as CodeNode));
 }
Ejemplo n.º 5
0
 public override bool Walk(ForIn node)
 {
     AddNode(node); return(true);
 }
Ejemplo n.º 6
0
 public virtual void Visit(ForIn node)
 {
     if (node != null)
     {
          AcceptChildren(node);
     }
 }
 public void Visit(ForIn node)
 {
     // not applicable; terminate
 }
Ejemplo n.º 8
0
 public virtual void PostWalk(ForIn node) { }
Ejemplo n.º 9
0
 public virtual bool Walk(ForIn node) { return true; }
Ejemplo n.º 10
0
 protected override EP_VP1 Visit(ForIn node)
 {
     return(Visit(node as CodeNode));
 }
Ejemplo n.º 11
0
 public virtual bool Walk(ForIn node)
 {
     return(true);
 }
Ejemplo n.º 12
0
 public virtual void PostWalk(ForIn node)
 {
 }
Ejemplo n.º 13
0
        public virtual void Visit(ForIn node)
        {
            if (node != null)
            {
                if (node.Variable != null)
                {
                    node.Variable.Accept(this);
                }

                if (node.Collection != null)
                {
                    node.Collection.Accept(this);
                }

                if (node.Body != null)
                {
                    node.Body.Accept(this);
                }
            }
        }