private static IAnalysisSet EvaluateListComprehension(ExpressionEvaluator ee, Node node) { if (ee._unit.State.LanguageVersion.Is2x()) { // list comprehension is in enclosing scope in 2.x ListComprehension listComp = (ListComprehension)node; WalkComprehension(ee, listComp, start: 0); var listInfo = (ListInfo)ee.Scope.GetOrMakeNodeValue( node, NodeValueKind.ListComprehension, (x) => new ListInfo( VariableDef.EmptyArray, ee._unit.State.ClassInfos[BuiltinTypeId.List], node, ee._unit.ProjectEntry ).SelfSet); listInfo.AddTypes(ee._unit, new[] { ee.Evaluate(listComp.Item) }); return(listInfo.SelfSet); } else { // list comprehension has its own scope in 3.x return(EvaluateComprehension(ee, node)); } }
public override void PostWalk(ListComprehension node) { if (_curUnit.State.LanguageVersion.Is3x()) { Debug.Assert(_scope is ComprehensionScope); _scope = _scope.OuterScope; } base.PostWalk(node); }
public override bool Walk(ListComprehension node) { if (_libraryMode) { return(false); } _stack.Enter(SymbolKind.None); return(base.Walk(node)); }
private static PythonNode Wrap(ListComprehension exp, PythonNode parent) { var result = new ListComprehensionNode(exp) { Parent = parent }; result.AddChild(Wrap(exp.Item, result)); exp.Iterators.ForEach(e => result.AddChild(Wrap(e, result))); return(result); }
public CodeExpression VisitListComprehension(ListComprehension lc) { m.EnsureImport("System.Linq"); var compFor = (CompFor)lc.Collection; var v = lc.Projection.Accept(this); var c = TranslateToLinq(v, compFor); return(m.Appl( m.MethodRef( c, "ToList"))); }
public override bool Walk(ListComprehension node) { // List comprehension runs in a new scope in 3.x, runs in the same // scope in 2.x. But these don't get their own analysis units // because they are still just expressions. if (_curUnit.State.LanguageVersion.Is3x()) { EnsureComprehensionScope(node, MakeListComprehensionScope); } return(base.Walk(node)); }
public CodeExpression VisitListComprehension(ListComprehension lc) { var compFor = (CompFor)lc.Collection; var v = compFor.variable.Accept(this); var c = Translate(v, compFor); var mr = new CodeMethodReferenceExpression(c, "Select"); var s = m.Appl(mr, new CodeExpression[] { m.Lambda( new CodeExpression[] { v }, lc.Projection.Accept(this)) }); return(s); }
// ListComp public override bool Walk(ListComprehension node) { BitArray save = _bits; _bits = new BitArray(_bits); foreach (ComprehensionIterator iter in node.Iterators) { iter.Walk(this); } node.Item.Walk(this); _bits = save; return(false); }
private static ISet <Namespace> EvaluateListComprehension(ExpressionEvaluator ee, Node node) { ListComprehension listComp = (ListComprehension)node; for (int i = 0; i < listComp.Iterators.Count; i++) { ComprehensionFor compFor = listComp.Iterators[i] as ComprehensionFor; if (compFor != null) { foreach (var listType in ee.Evaluate(compFor.List)) { ee.AssignTo(node, compFor.Left, listType.GetEnumeratorTypes(node, ee._unit)); } } } return(ee.GlobalScope.GetOrMakeNodeVariable( node, (x) => new ListInfo(new [] { ee.Evaluate(listComp.Item) }, ee._unit.ProjectState._listType).SelfSet)); }
public void VisitListComprehension(ListComprehension lc) { throw new NotImplementedException(); }
private Unit MapUnitToExtGaps(Unit unit) { return(MapList(unit, (Seq seq) => ListComprehension(Gaps(ListExt(seq)), (int e) => (seq[0].Item1, seq[0].Item2, e)))); }
public override bool Walk(ListComprehension node) { ProcessComprehension(node, node.Item, node.Iterators); return(false); }
// ListComprehension public override bool Walk(ListComprehension node) { return(false); }
// ListComprehension public override bool Walk(ListComprehension node) { return false; }
// ListComprehension public virtual bool Walk(ListComprehension node) { return true; }
// ListComprehension public virtual bool Walk(ListComprehension node) { return(true); }
public override void PostWalk(ListComprehension node) => ExitComprehension(node);
public override bool Walk(ListComprehension node) { node.Walk(new ComprehensionWalker(_walker, _localNames, _localNameExpressions)); return(false); }
public override bool Walk(ListComprehension node) { _stack.Enter(SymbolKind.None); return(base.Walk(node)); }
public override void PostWalk(ListComprehension node) { PostWalkWorker(node); }
public void VisitListComprehension(ListComprehension lc) { throw new NotImplementedException(); }
// ListComprehension public override bool Walk(ListComprehension node) { return Location >= node.StartIndex && Location <= node.EndIndex; }
public override bool Walk(ListComprehension node) { BeginScope(); return(base.Walk(node)); }
// ListComprehension public override bool Walk(ListComprehension node) { return(Location >= node.StartIndex && Location <= node.EndIndex); }
private List <Inferred> InferListComp(ListComprehension node, Scope scope) { return(MakeList(module.InferType(typeof(IronPython.Runtime.List)))); }
public virtual void PostWalk(ListComprehension node) { }
public void PostWalk(ListComprehension node) { PostProcess(node); }
public override void PostWalk(ListComprehension node) { }
// ListComprehension public override bool Walk(ListComprehension node) { return(ShouldWalkWorker(node)); }
public override void PostWalk(ListComprehension node) { }
/// <remarks> /// Python's list comprehension will bind the variables used in generators. /// This will erase the original values of the variables even after the /// comprehension. /// </remarks> public DataType VisitListComprehension(ListComprehension l) { l.Collection.Accept(this); return(analyzer.TypeFactory.CreateList(l.Projection.Accept(this))); }
public virtual void PostWalk(ListComprehension node) { }
public override bool Walk(ListComprehension node) { return(UpdateLineInfo(node, true)); }
public override void PostWalk(ListComprehension node) { EndScope(false); Debug.Assert(_head != null); base.PostWalk(node); }
// ListComprehension public bool Walk(ListComprehension node) { return(Process(node)); }