예제 #1
0
 /// <summary>
 /// Creates a matching for "greater than or equal" comparison.
 /// </summary>
 /// <param name="y">right operand matching</param>
 /// <returns></returns>
 public Matching GtEq(Matching y)
 {
     return(MBinOp(SystemSharp.SysDOM.BinOp.Kind.GtEq, y));
 }
예제 #2
0
 /// <summary>
 /// Creates a matching for type cast expressions.
 /// </summary>
 /// <param name="srcType">source type</param>
 /// <param name="dstType">destination type</param>
 public Matching Cast(Type srcType, TypeDescriptor dstType)
 {
     var cast = IntrinsicFunctions.Cast((Expression)null, srcType, dstType);
     Matching newm = new Matching();
     newm._func = e => e.NodeEquals(cast) &&
             this.Match(e.Children.ElementAt(0));
     newm._gen = () => newm._expr == null ?
             IntrinsicFunctions.Cast(_gen(), srcType, dstType) :
             newm._expr;
     return newm;
 }
예제 #3
0
 /// <summary>
 /// Creates a matching for "less than" comparison.
 /// </summary>
 /// <param name="y">right operand matching</param>
 /// <returns></returns>
 public Matching Lt(Matching y)
 {
     return(MBinOp(SystemSharp.SysDOM.BinOp.Kind.Lt, y));
 }
예제 #4
0
 /// <summary>
 /// Creates a matching for "greater than or equal" comparison.
 /// </summary>
 /// <param name="y">right operand matching</param>
 /// <returns></returns>
 public Matching GtEq(Matching y)
 {
     return MBinOp(SystemSharp.SysDOM.BinOp.Kind.GtEq, y);
 }
예제 #5
0
 /// <summary>
 /// Creates a matching for "less than" comparison.
 /// </summary>
 /// <param name="y">right operand matching</param>
 /// <returns></returns>
 public Matching Lt(Matching y)
 {
     return MBinOp(SystemSharp.SysDOM.BinOp.Kind.Lt, y);
 }
예제 #6
0
 /// <summary>
 /// Constrains the matching, using an additional predicate.
 /// </summary>
 /// <param name="constraint">additional constraint</param>
 public Matching Constrain(Func<bool> constraint)
 {
     Matching result = new Matching();
     result._func = e => this.Match(e) && constraint();
     result._gen = this._gen;
     return result;
 }
예제 #7
0
 /// <summary>
 /// Creates a matching for the specified kind of binary operation.
 /// </summary>
 /// <param name="kind">kind of binary operation to match</param>
 /// <param name="peer">right child matching</param>
 public Matching MBinOp(BinOp.Kind kind, Matching peer)
 {
     BinOp cmp = new BinOp() { Operation = kind };
     Matching newm = new Matching();
     newm._func = e => e.NodeEquals(cmp) && 
             this.Match(e.Children.ElementAt(0)) && 
             peer.Match(e.Children.ElementAt(1));
     newm._gen = () => newm._expr == null ? 
         new BinOp() { Operation = kind, Operand1 = _gen(), Operand2 = peer._gen() } : newm._expr;
     return newm;
 }
예제 #8
0
 /// <summary>
 /// Creates a matching for the specified kind of unary operations.
 /// </summary>
 /// <param name="kind">kind of unary operation to match</param>
 public Matching MUnOp(UnOp.Kind kind)
 {
     UnOp cmp = new UnOp() { Operation = kind };
     Matching newm = new Matching();
     newm._func = e => e.NodeEquals(cmp) && 
             this.Match(e.Children.ElementAt(0));
     newm._gen = () => newm._expr == null ? 
             new UnOp() { Operation = kind, Operand = _gen() } : 
             newm._expr;
     return newm;
 }