Example #1
0
 public virtual Node VisitQueryQuantifiedExpression(QueryQuantifiedExpression qqe, QueryQuantifiedExpression changes, QueryQuantifiedExpression deletions, QueryQuantifiedExpression insertions){
   this.UpdateSourceContext(qqe, changes);
   if (qqe == null) return changes;
   if (changes != null){
     if (deletions == null || insertions == null)
       Debug.Assert(false);
     else{
     }
   }else if (deletions != null)
     return null;
   return qqe;
 }
Example #2
0
 public virtual Node VisitQueryQuantifiedExpression(QueryQuantifiedExpression qqe){
   if (qqe == null) return null;
   qqe.Expression = this.VisitExpression(qqe.Expression);
   return qqe;
 }
    public virtual Differences VisitQueryQuantifiedExpression(QueryQuantifiedExpression qqe1, QueryQuantifiedExpression qqe2){
      Differences differences = new Differences(qqe1, qqe2);
      if (qqe1 == null || qqe2 == null){
        if (qqe1 != qqe2) differences.NumberOfDifferences++; else differences.NumberOfSimilarities++;
        return differences;
      }
      QueryQuantifiedExpression changes = (QueryQuantifiedExpression)qqe2.Clone();
      QueryQuantifiedExpression deletions = (QueryQuantifiedExpression)qqe2.Clone();
      QueryQuantifiedExpression insertions = (QueryQuantifiedExpression)qqe2.Clone();

      //      qqe1.Expression;
      //      qqe1.Left;
      //      qqe1.Right;

      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;
    }
Example #4
0
 public override Node VisitQueryQuantifier(QueryQuantifier qq) {
   if (qq == null) return null;
   QueryQuantifiedExpression savedQQE = this.currentQuantifiedExpression;
   this.currentQuantifiedExpression = null;
   qq.Expression = this.VisitExpression(qq.Expression);
   this.currentQuantifiedExpression = savedQQE;
   if (qq.Expression == null || qq.Expression.Type == null) return null;
   Cardinality card = this.typeSystem.GetCardinality(qq.Expression, this.TypeViewer);
   if (card != Cardinality.OneOrMore && card != Cardinality.ZeroOrMore) {
     this.HandleError(qq.Expression, Error.QueryNotStream);
     return null;
   }
   if (this.currentQuantifiedExpression == null) {
     this.HandleError(qq, Error.QueryBadQuantifier);
     return null;
   }
   if (this.currentQuantifiedExpression.Left != qq &&
     this.currentQuantifiedExpression.Right != qq) {
     this.HandleError(qq, Error.QueryBadQuantifier);
     return null;
   }
   if (qq.Type == null) return null;
   return qq;
 }
Example #5
0
 public override Node VisitQueryQuantifiedExpression(QueryQuantifiedExpression qqe) {
   if (qqe == null) return null;
   QueryQuantifiedExpression saveQQE = this.currentQuantifiedExpression;
   this.currentQuantifiedExpression = qqe;
   qqe.Expression = this.VisitBooleanExpression(qqe.Expression);
   this.currentQuantifiedExpression = saveQQE;
   if (qqe.Expression == null || qqe.Type == null) return null;
   Cardinality card = this.typeSystem.GetCardinality(qqe.Expression, this.TypeViewer);
   if (card == Cardinality.OneOrMore || card == Cardinality.ZeroOrMore) {
     this.HandleError(qqe.Expression, Error.QueryNotScalar);
     return null;
   }
   if (qqe.Type == null) return null;
   // TODO: we need to insert the same logic as the one used in an if statement
   if (!this.typeSystem.ImplicitCoercionFromTo(qqe.Type, SystemTypes.Boolean, this.TypeViewer) && 
     !this.typeSystem.ImplicitCoercionFromTo(qqe.Type, SystemTypes.SqlBoolean, this.TypeViewer)) {
     this.HandleError(qqe, Error.QueryBadQuantifiedExpression);
     return null;
   }
   return qqe;
 }
Example #6
0
 public virtual void VisitQueryQuantifiedExpression(QueryQuantifiedExpression qqe){
   if (qqe == null) return;
   this.VisitExpression(qqe.Expression);
 }
Example #7
0
 public override Node VisitQueryQuantifiedExpression(QueryQuantifiedExpression qqe){
   if (qqe == null) return null;
   qqe.Expression = this.VisitExpression(qqe.Expression);
   if (qqe.Expression != null && qqe.Expression.Type != null){
     qqe.Type = qqe.Expression.Type;
   }
   return qqe;
 }
Example #8
0
 public virtual Node VisitQueryQuantifiedExpression(QueryQuantifiedExpression qqe1, QueryQuantifiedExpression qqe2){
   if (qqe1 == null) return null;
   if (qqe2 == null)
     qqe1.Expression = this.VisitExpression(qqe1.Expression, null);
   else
     qqe1.Expression = this.VisitExpression(qqe1.Expression, qqe2.Expression);
   return qqe1;
 }
Example #9
0
 public override Node VisitQueryQuantifiedExpression(QueryQuantifiedExpression qqe){
   if (qqe == null) return null;
   return base.VisitQueryQuantifiedExpression((QueryQuantifiedExpression)qqe.Clone());
 }
Example #10
0
 public override Node VisitQueryQuantifiedExpression(QueryQuantifiedExpression qqe) {
   Block block = new Block(new StatementList(4));
   Expression locResult = new Local(qqe.Type);
   Expression retTrue = this.typeSystem.ImplicitCoercion(Literal.True, qqe.Type, this.TypeViewer);
   Expression retFalse = this.typeSystem.ImplicitCoercion(Literal.False, qqe.Type, this.TypeViewer);
   Statement feOuter = null;
   Statement feInner = null;
   Block outerBody = null;
   Block innerBody = null;
   BlockScope scope = this.currentMethod.Body.Scope;
   QueryQuantifier outer = null;
   QueryQuantifier inner = null;
   if (qqe.Left != null && qqe.Right != null) {
     outer = qqe.Left;
     inner = qqe.Right;
     outer.Target = new Local(outer.Type);
     feOuter = this.BuildClosureForEach(outer.Expression, ref outer.Target, out outerBody, scope);
     inner.Target = new Local(inner.Type);
     feInner = this.BuildClosureForEach(inner.Expression, ref inner.Target, out innerBody, scope);
     outerBody.Statements.Add(feInner);
     block.Statements.Add(feOuter);
   }
   else if (qqe.Left != null) {
     inner = qqe.Left;
     inner.Target = new Local(inner.Type);
     feInner = this.BuildClosureForEach(qqe.Left.Expression, ref inner.Target, out innerBody, scope);
     block.Statements.Add(feInner);
   }
   else if (qqe.Right != null) {
     inner = qqe.Right;
     inner.Target = new Local(inner.Type);
     feInner = this.BuildClosureForEach(inner.Expression, ref inner.Target, out innerBody, scope);
     block.Statements.Add(feInner);
   }
   else {
     // error condition;
     return Literal.False;
   }
   Block onTrue = new Block(new StatementList(new AssignmentStatement(locResult, retTrue)));
   Block onFalse = new Block(new StatementList(new AssignmentStatement(locResult, retFalse)));
   Block exit = new Block();
   Expression test = qqe.Expression;
   if (outer == null || outer.NodeType == inner.NodeType) {
     if (inner.NodeType == NodeType.QueryAny) {
       innerBody.Statements.Add(new Branch(test, onTrue));
       block.Statements.Add(new Branch(null, onFalse));
     }
     else {
       test = new UnaryExpression(test, NodeType.LogicalNot);
       test.Type = SystemTypes.Boolean;
       innerBody.Statements.Add(new Branch(test, onFalse));
       block.Statements.Add(new Branch(null, onTrue));
     }
   }
   else {
     if (outer.NodeType == NodeType.QueryAll) {
       Block bottom = new Block();
       innerBody.Statements.Add(new Branch(test, bottom));
       outerBody.Statements.Add(new Branch(null, onFalse));
       outerBody.Statements.Add(bottom);
       block.Statements.Add(new Branch(null, onTrue));
     }
     else {
       test = new UnaryExpression(test, NodeType.LogicalNot);
       test.Type = SystemTypes.Boolean;
       Block bottom = new Block();
       innerBody.Statements.Add(new Branch(test, bottom));
       outerBody.Statements.Add(new Branch(null, onTrue));
       outerBody.Statements.Add(bottom);
       block.Statements.Add(new Branch(null, onFalse));
     }
   }
   block.Statements.Add(onTrue);
   block.Statements.Add(new Branch(null, exit));
   block.Statements.Add(onFalse);
   block.Statements.Add(exit);
   block.Statements.Add(new ExpressionStatement(locResult));
   BlockExpression be = new BlockExpression(block, locResult.Type);
   return this.VisitBlockExpression(be);
 }
Example #11
0
 public override Expression VisitBinaryExpression(BinaryExpression be){
   Expression result = base.VisitBinaryExpression(be);
   if ( (be.Operand1 != null && (be.Operand1.NodeType == NodeType.QueryAny || be.Operand1.NodeType == NodeType.QueryAll))
     || (be.Operand2 != null && (be.Operand2.NodeType == NodeType.QueryAny || be.Operand2.NodeType == NodeType.QueryAll))){
     QueryQuantifiedExpression qq = new QueryQuantifiedExpression();
     qq.Left = be.Operand1 as QueryQuantifier;
     qq.Right = be.Operand2 as QueryQuantifier;
     qq.Expression = result;
     result = qq;
   }
   return result;
 }
Example #12
0
 public override Node VisitQueryQuantifiedExpression(QueryQuantifiedExpression qq) {
   base.VisitQueryQuantifiedExpression(qq);
   return this.Compose(qq, this.GetComposer(qq.Expression));
 }
Example #13
0
 public override Node VisitQueryQuantifiedExpression(QueryQuantifiedExpression qq)
 {
     base.VisitQueryQuantifiedExpression(qq);
     return(this.Compose(qq, this.GetComposer(qq.Expression)));
 }
 public EventingVisitor(Action<QueryQuantifiedExpression> visitQueryQuantifiedExpression) { VisitedQueryQuantifiedExpression += visitQueryQuantifiedExpression; } public event Action<QueryQuantifiedExpression> VisitedQueryQuantifiedExpression; public override Node VisitQueryQuantifiedExpression(QueryQuantifiedExpression qqe) { if (VisitedQueryQuantifiedExpression != null) VisitedQueryQuantifiedExpression(qqe); return base.VisitQueryQuantifiedExpression(qqe); }