Ejemplo n.º 1
0
    public virtual Differences VisitQueryYielder(QueryYielder yielder1, QueryYielder yielder2){
      Differences differences = new Differences(yielder1, yielder2);
      if (yielder1 == null || yielder2 == null){
        if (yielder1 != yielder2) differences.NumberOfDifferences++; else differences.NumberOfSimilarities++;
        return differences;
      }
      QueryYielder changes = (QueryYielder)yielder2.Clone();
      QueryYielder deletions = (QueryYielder)yielder2.Clone();
      QueryYielder insertions = (QueryYielder)yielder2.Clone();

      //      yielder1.Body;
      //      yielder1.Source;
      //      yielder1.State;
      //      yielder1.Target;

      if (differences.NumberOfDifferences == 0){
        differences.Changes = null;
        differences.Deletions = null;
        differences.Insertions = null;
      }else{
        differences.Changes = changes;
        differences.Deletions = deletions;
        differences.Insertions = insertions;
      }
      return differences;
    }
Ejemplo n.º 2
0
 public virtual Node VisitQueryYielder(QueryYielder yielder, QueryYielder changes, QueryYielder deletions, QueryYielder insertions){
   this.UpdateSourceContext(yielder, changes);
   if (yielder == null) return changes;
   if (changes != null){
     if (deletions == null || insertions == null)
       Debug.Assert(false);
     else{
     }
   }else if (deletions != null)
     return null;
   return yielder;
 }
Ejemplo n.º 3
0
 public virtual void VisitQueryYielder(QueryYielder yielder){
   if (yielder == null) return;
   this.VisitExpression(yielder.Source);
   this.VisitExpression(yielder.Target);
   this.VisitBlock(yielder.Body);
 }
Ejemplo n.º 4
0
 public virtual Node VisitQueryYielder(QueryYielder yielder){
   if (yielder == null) return null;
   yielder.Source = this.VisitExpression(yielder.Source);
   yielder.Target = this.VisitExpression(yielder.Target);
   yielder.Body = this.VisitBlock(yielder.Body);
   return yielder;
 }
Ejemplo n.º 5
0
 public override Node VisitQueryYielder(QueryYielder yielder){
   if (yielder == null) return null;
   return base.VisitQueryYielder((QueryYielder)yielder.Clone());
 }
Ejemplo n.º 6
0
 public virtual Node VisitQueryYielder(QueryYielder yielder1, QueryYielder yielder2){
   if (yielder1 == null) return null;
   if (yielder2 == null){
     yielder1.Source = this.VisitExpression(yielder1.Source, null);
     yielder1.Target = this.VisitExpression(yielder1.Target, null);
     yielder1.Body = this.VisitBlock(yielder1.Body, null);
   }else{
     yielder1.Source = this.VisitExpression(yielder1.Source, yielder2.Source);
     yielder1.Target = this.VisitExpression(yielder1.Target, yielder2.Target);
     yielder1.Body = this.VisitBlock(yielder1.Body, yielder2.Body);
   }
   return yielder1;
 }
Ejemplo n.º 7
0
 public override Node VisitQueryYielder(QueryYielder qy) {
   bool savedFoldQuery = this.foldQuery;
   this.foldQuery = true;
   Block feBlock = (Block) this.Visit(qy.Source);
   this.foldQuery = false;
   Yielder yielder = new Yielder(this.typeSystem, this.TypeViewer);
   return this.Visit(yielder.YieldTo(feBlock, qy.Body, qy.Target, qy.State));
 }
Ejemplo n.º 8
0
 public virtual Statement BuildClosureForEach(Expression source, ref Expression target, out Block body, BlockScope scope) {
   source = this.GetInnerExpression(source);
   if (source is QueryExpression) {
     QueryYielder yielder = new QueryYielder();
     yielder.Source = source;
     yielder.Body = body = new Block(new StatementList(1));
     if (target == null) target = this.NewClosureLocal(this.typeSystem.GetStreamElementType(source, this.TypeViewer), scope);
     yielder.Target = target;
     yielder.State = this.NewClosureLocal(SystemTypes.Int32, scope);
     return yielder;
   }else{
     if (target == null){
       TypeNode elementType = this.typeSystem.GetStreamElementType(source, this.TypeViewer);
       target = target = this.NewClosureLocal(elementType, scope);
     }
     Literal tmpSource = new Literal(null, source.Type);
     ForEach fe = new ForEach(target.Type, target, tmpSource, new Block(new StatementList(1)));
     fe.ScopeForTemporaryVariables = scope;
     Checker checker = new Checker(null, this.typeSystem, null, null, null);
     checker.currentType = this.typeSystem.currentType = (scope.CapturedForClosure ? scope.ClosureClass : this.currentMethod.DeclaringType);
     checker.VisitForEach(fe);
     Debug.Assert(fe.SourceEnumerable != null);
     if (fe.SourceEnumerable != null){
       Debug.Assert(fe.SourceEnumerable is CollectionEnumerator, "SourceEnumerable == "+fe.SourceEnumerable.GetType());
       CollectionEnumerator ce = (CollectionEnumerator)fe.SourceEnumerable;
       ce.Collection = source;
     }
     body = fe.Body;
     return fe;
   }
 }
Ejemplo n.º 9
0
 public EventingVisitor(Action<QueryYielder> visitQueryYielder) { VisitedQueryYielder += visitQueryYielder; } public event Action<QueryYielder> VisitedQueryYielder; public override Node VisitQueryYielder(QueryYielder yielder) { if (VisitedQueryYielder != null) VisitedQueryYielder(yielder); return base.VisitQueryYielder(yielder); }