Example #1
0
        public override JmesPathExpression Accept(ITransformVisitor visitor)
        {
            JmesPathExpression[] visitedExpressionsStorage = expressions_;
            JmesPathExpression[] visitedExpressions        = null;

            for (int i = 0, n = expressions_.Length; i < n; i++)
            {
                var expression        = expressions_[i];
                var visitedExpression = expression.Accept(visitor);

                // the first time we visited a transformed argument, allocate new
                // argument storage and copy any preceding untransformed arguments
                if (expression != visitedExpression && visitedExpressions == null)
                {
                    visitedExpressions        = new JmesPathExpression[n];
                    visitedExpressionsStorage = visitedExpressions;
                    if (i > 0)
                    {
                        Array.Copy(expressions_, visitedExpressions, i - 1);
                    }
                }

                visitedExpressionsStorage[i] = visitedExpression;
            }

            // if our visited argument storage array and the one backing this
            // instance are the same, then no arguments were transformed
            if (visitedExpressionsStorage == expressions_)
            {
                return(visitor.Visit(this));
            }

            return(visitor.Visit(new JmesPathFunctionExpression(name_, visitedExpressionsStorage, function_)));
        }
 public JmesPathIndexExpression(JmesPathExpression expression, JmesPathExpression specifier)
     : base(expression, specifier)
 {
     System.Diagnostics.Debug.Assert(
         specifier is JmesPathIndex ||
         specifier is JmesPathFilterProjection ||
         specifier is JmesPathFlattenProjection ||
         specifier is JmesPathListWildcardProjection ||
         specifier is JmesPathSliceProjection ||
         false
         );
 }
 /// <summary>
 /// Initialize a new instance of the <see cref="JmesPathSubExpression"/> class
 /// with two <see cref="JmesPathExpression"/> objects.
 /// </summary>
 /// <param name="expression"></param>
 /// <param name="subExpression"></param>
 public JmesPathSubExpression(JmesPathExpression expression, JmesPathExpression subExpression)
     : base(expression, subExpression)
 {
     System.Diagnostics.Debug.Assert(
         subExpression is JmesPathFunctionExpression ||
         subExpression is JmesPathIdentifier ||
         subExpression is JmesPathMultiSelectHash ||
         subExpression is JmesPathMultiSelectList ||
         subExpression is JmesPathHashWildcardProjection ||
         subExpression is JmesPathFunctionExpression ||
         false
         );
 }
        /// <summary>
        /// Initialize a new instance of the <see cref="JmesPathCompoundExpression"/> class
        /// with two <see cref="JmesPathExpression"/> objects.
        /// </summary>
        /// <param name="left"></param>
        /// <param name="right"></param>
        protected JmesPathCompoundExpression(JmesPathExpression left, JmesPathExpression right)
        {
            if (left == null)
            {
                throw new ArgumentNullException(nameof(left));
            }
            if (right == null)
            {
                throw new ArgumentNullException(nameof(right));
            }

            left_  = left;
            right_ = right;
        }
 /// <summary>
 /// Initialize a new instance of the <see cref="JmesPathComparison" /> class
 /// that performs a comparison between two specified expressions.
 /// </summary>
 /// <param name="left"></param>
 /// <param name="right"></param>
 protected JmesPathComparison(JmesPathExpression left, JmesPathExpression right)
     : base(left, right)
 {
 }
 /// <summary>
 /// Initialize a new instance of the <see cref="JmesPathSimpleExpression"/> class.
 /// </summary>
 /// <param name="expression"></param>
 protected JmesPathSimpleExpression(JmesPathExpression expression)
 {
     expression_ = expression;
 }
Example #7
0
 /// <summary>
 /// Initialize a new instance of the <see cref="JmesPathNotEqualOperator"/> class.
 /// </summary>
 /// <param name="left"></param>
 /// <param name="right"></param>
 public JmesPathNotEqualOperator(JmesPathExpression left, JmesPathExpression right)
     : base(left, right)
 {
 }
 protected override JmesPathExpression CreateWith(JmesPathExpression left, JmesPathExpression right)
 => new JmesPathEqualOperator(left, right);
 public static void MakeExpressionType(JmesPathExpression expression)
 {
     expression.IsExpressionType = true;
 }
 protected override JmesPathExpression CreateWith(JmesPathExpression left, JmesPathExpression right)
 => new JmesPathIndexExpression(left, right);
 /// <summary>
 /// Initialize a new instance of the <see cref="JmesPathPipeExpression"/> class
 /// with two <see cref="JmesPathExpression"/> objects.
 /// </summary>
 /// <param name="left"></param>
 /// <param name="right"></param>
 public JmesPathPipeExpression(JmesPathExpression left, JmesPathExpression right)
     : base(left, right)
 {
 }
 public JmesParenExpression(JmesPathExpression expression)
 {
     expression_ = expression;
 }
 /// <summary>
 /// Initialize a new instance of the <see cref="JmesPathLessThanOperator"/> class
 /// to perform a comparison between two specified expressions.
 /// </summary>
 /// <param name="left"></param>
 /// <param name="right"></param>
 public JmesPathLessThanOperator(JmesPathExpression left, JmesPathExpression right)
     : base(left, right)
 {
 }
 protected abstract JmesPathExpression CreateWith(JmesPathExpression left, JmesPathExpression right);
 public JmesPathFilterProjection(JmesPathExpression expression)
 {
     expression_ = expression;
 }
 /// <summary>
 /// Initialize a new instance of the <see cref="JmesPathNotExpression"/>
 /// that negates the result of evaluating its associated expression.
 /// </summary>
 /// <param name="expression"></param>
 public JmesPathNotExpression(JmesPathExpression expression)
     : base(expression)
 {
 }
 /// <summary>
 /// Initialize a new instance of the <see cref="JmesPathGreaterThanOrEqualOperator"/> class
 /// to perform a comparison between two specified expressions.
 /// </summary>
 /// <param name="left"></param>
 /// <param name="right"></param>
 public JmesPathGreaterThanOrEqualOperator(JmesPathExpression left, JmesPathExpression right)
     : base(left, right)
 {
 }