public static ExpressionFingerprint Create(Expression expression, ParserContext context)
  {
      BinaryExpression binaryExpression = (expression as BinaryExpression);
      if (binaryExpression != null)
          return BinaryExpressionFingerprint.Create(binaryExpression, context);
  
      ConditionalExpression conditionalExpression = (expression as ConditionalExpression);
      if (conditionalExpression != null)
          return ConditionalExpressionFingerprint.Create(conditionalExpression, context);
 
      ConstantExpression constantExpression = (expression as ConstantExpression);
      if (constantExpression != null)
          return ConstantExpressionFingerprint.Create(constantExpression, context);
  
      MemberExpression memberExpression = (expression as MemberExpression);
      if (memberExpression != null)
          return MemberExpressionFingerprint.Create(memberExpression, context);
  
      MethodCallExpression methodCallExpression = (expression as MethodCallExpression);
      if (methodCallExpression != null)
          return MethodCallExpressionFingerprint.Create(methodCallExpression, context);
  
      ParameterExpression parameterExpression = (expression as ParameterExpression);
      if (parameterExpression != null)
          return ParameterExpressionFingerprint.Create(parameterExpression, context);
  
      UnaryExpression unaryExpression = (expression as UnaryExpression);
      if (unaryExpression != null)
          return UnaryExpressionFingerprint.Create(unaryExpression, context);
      
      return null;
  }
        public override Expression ToExpression(ParserContext context)
        {
            BinaryExpression index = Expression.ArrayIndex(
                ParserContext.HoistedValuesParameter, 
                Expression.Constant(_index));

            return Expression.Convert(index, Type);
        }
 public static ParameterExpressionFingerprint Create(
     ParameterExpression expression, ParserContext context)
 {
     if (expression == context.Instance)
         return new ParameterExpressionFingerprint(expression);
     else
         return null;
 }
        public override Expression ToExpression(ParserContext context)
        {
            Expression operand = ToExpression(_operand, context);

            if (NodeType == ExpressionType.UnaryPlus)
                return Expression.UnaryPlus(operand, Method);
            
            return Expression.MakeUnary(NodeType, operand, Type, _method);
        }
        public static UnaryExpressionFingerprint Create(
            UnaryExpression expression, ParserContext context)
        {
            ExpressionFingerprint operand = Create(expression.Operand, context);
            if (operand == null && expression.Operand != null)
                return null;

            return new UnaryExpressionFingerprint(expression) {
                    _operand = operand
                };
        }
        public static MemberExpressionFingerprint Create(
            MemberExpression expression, ParserContext context)
        {
            ExpressionFingerprint target = Create(expression.Expression, context);
            if (target == null && expression.Expression != null)
                return null;

            return new MemberExpressionFingerprint(expression) {
                    _target = target
                };
        }
        public static ConstantExpressionFingerprint Create(
            ConstantExpression expression, ParserContext context)
        {
            ConstantExpressionFingerprint fingerprint =
                new ConstantExpressionFingerprint(expression)
                {
                    _index = context.HoistedValues.Count
                };

            context.HoistedValues.Add(expression.Value);
            return fingerprint;
        }
        public static MethodCallExpressionFingerprint Create(
            MethodCallExpression expression, ParserContext context)
        {
            ReadOnlyCollection<ExpressionFingerprint> arguments = 
                Create(expression.Arguments, context);
            if (arguments == null)
                return null;

            ExpressionFingerprint target = Create(expression.Object, context);
            if (target == null && expression.Object != null)
                return null;

            return new MethodCallExpressionFingerprint(expression) {
                    _arguments = arguments,
                    _target = target
                };
        }
        public static BinaryExpressionFingerprint Create(
            BinaryExpression expression, ParserContext context)
        {
            if (expression.Conversion != null)
                return null;

            ExpressionFingerprint left = Create(expression.Left, context);
            if (left == null && expression.Left != null)
                return null;

            ExpressionFingerprint right = Create(expression.Right, context);
            if (right == null && expression.Right != null)
                return null;

            return new BinaryExpressionFingerprint(expression) {
                    _left = left, _right = right
                };
        }
        public static ConditionalExpressionFingerprint Create(
            ConditionalExpression expression, ParserContext context)
        {
            ExpressionFingerprint test = Create(expression.Test, context);
            if (test == null && expression.Test != null)
                return null;

            ExpressionFingerprint ifTrue = Create(expression.IfTrue, context);
            if (ifTrue == null && expression.IfTrue != null)
                return null;

            ExpressionFingerprint ifFalse = Create(expression.IfFalse, context);
            if (ifFalse == null && expression.IfFalse != null)
                return null;

            return new ConditionalExpressionFingerprint(expression) {
                    _test = test, _ifTrue = ifTrue, _ifFalse = ifFalse
                };
        }
 public override Expression ToExpression(ParserContext context)
 {
     return context.Instance;
 }
        public override Expression ToExpression(ParserContext context)
        {
            Expression target = ToExpression(_target, context);
            IEnumerable<Expression> arguments = ToExpression(_arguments, context);

            return Expression.Call(target, _method, arguments);
        }
 public abstract Expression ToExpression(ParserContext context);
 protected static IEnumerable<Expression> ToExpression(
     IEnumerable<ExpressionFingerprint> fingerprints, ParserContext context)
 {
     return fingerprints.Select(f => ToExpression(f, context));
 }
 protected static Expression ToExpression(ExpressionFingerprint fingerprint, ParserContext context)
 {
     return (fingerprint == null) ? null : fingerprint.ToExpression(context);
 }
 public static ReadOnlyCollection<ExpressionFingerprint> Create(
     IEnumerable<Expression> expressions, ParserContext context)
 {
     List<ExpressionFingerprint> fingerprints = new List<ExpressionFingerprint>();
     foreach (Expression expression in expressions)
     {
         ExpressionFingerprint fingerprint = Create(expression, context);
         if (fingerprint == null && expression != null)
             return null;
         
         fingerprints.Add(fingerprint);
     }
     return new ReadOnlyCollection<ExpressionFingerprint>(fingerprints);
 }
        public override Expression ToExpression(ParserContext context)
        {
            Expression test = ToExpression(_test, context);
            Expression ifTrue = ToExpression(_ifTrue, context);
            Expression ifFalse = ToExpression(_ifFalse, context);

            return Expression.Condition(test, ifTrue, ifFalse);
        }
 public override Expression ToExpression(ParserContext context)
 {
     return Expression.MakeMemberAccess(
         ToExpression(_target, context), _member);
 }
        public override Expression ToExpression(ParserContext context)
        {
            Expression left = ToExpression(_left, context);
            Expression right = ToExpression(_right, context);

            return Expression.MakeBinary(NodeType, left, right, _isLiftedToNull, _method);
        }
 public override Expression ToExpression(ParserContext context)
 {
     return(context.Instance);
 }