Ejemplo n.º 1
0
 /// <summary>
 /// Constructs a generator for unary expressions.
 /// </summary>
 /// <param name="kind">kind of unary expression to construct</param>
 /// <param name="g">operand generator</param>
 public static ExpressionGenerator UnOp(UnOp.Kind kind, ExpressionGenerator g)
 {
     return(() => new UnOp()
     {
         Operation = kind,
         Operand = g()
     });
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns <c>true</c> if the expression is a unary operation.
        /// </summary>
        public static bool IsUnOp(this Expression e, UnOp.Kind op)
        {
            UnOp uop = e as UnOp;

            if (uop == null)
            {
                return(false);
            }
            return(uop.Operation == op);
        }
Ejemplo n.º 3
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);
        }
 /// <summary>
 /// Creates the attribute.
 /// </summary>
 /// <param name="kind">kind of unary operation</param>
 public MapToUnOp(UnOp.Kind kind)
 {
     Kind = kind;
 }