internal override void Match(int valIndex, ref Value val, QueryBranchResultSet results)
 {
     if (ValueDataType.Sequence == val.Type)
     {
         NodeSequence sequence = val.Sequence;
         for (int i = 0; i < sequence.Count; i++)
         {
             this.Match(valIndex, sequence.Items[i].NumberValue(), results);
         }
     }
     else
     {
         this.Match(valIndex, val.ToDouble(), results);
     }
 }
 internal override void Match(int valIndex, ref Value val, QueryBranchResultSet results)
 {
     QueryBranch branch = null;
     if (ValueDataType.Sequence == val.Type)
     {
         NodeSequence sequence = val.Sequence;
         for (int i = 0; i < sequence.Count; i++)
         {
             branch = this[sequence.Items[i].StringValue()];
             if (branch != null)
             {
                 results.Add(branch, valIndex);
             }
         }
     }
     else
     {
         branch = this[val.String];
         if (branch != null)
         {
             results.Add(branch, valIndex);
         }
     }
 }
        // Fully general compare
        internal bool CompareTo(ref Value val, RelationOperator op)
        {
            switch (this.type)
            {
                default:
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.TypeMismatch));

                case ValueDataType.Boolean:
                    switch (val.type)
                    {
                        default:
                            throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.TypeMismatch));
                        case ValueDataType.Boolean:
                            return QueryValueModel.Compare(this.boolVal, val.boolVal, op);
                        case ValueDataType.Double:
                            return QueryValueModel.Compare(this.boolVal, val.dblVal, op);
                        case ValueDataType.Sequence:
                            return QueryValueModel.Compare(this.boolVal, val.sequence, op);
                        case ValueDataType.String:
                            return QueryValueModel.Compare(this.boolVal, val.strVal, op);
                    }

                case ValueDataType.Double:
                    switch (val.type)
                    {
                        default:
                            throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.TypeMismatch));
                        case ValueDataType.Boolean:
                            return QueryValueModel.Compare(this.dblVal, val.boolVal, op);
                        case ValueDataType.Double:
                            return QueryValueModel.Compare(this.dblVal, val.dblVal, op);
                        case ValueDataType.Sequence:
                            return QueryValueModel.Compare(this.dblVal, val.sequence, op);
                        case ValueDataType.String:
                            return QueryValueModel.Compare(this.dblVal, val.strVal, op);
                    }

                case ValueDataType.Sequence:
                    switch (val.type)
                    {
                        default:
                            throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.TypeMismatch));
                        case ValueDataType.Boolean:
                            return QueryValueModel.Compare(this.sequence, val.boolVal, op);
                        case ValueDataType.Double:
                            return QueryValueModel.Compare(this.sequence, val.dblVal, op);
                        case ValueDataType.Sequence:
                            return QueryValueModel.Compare(this.sequence, val.sequence, op);
                        case ValueDataType.String:
                            return QueryValueModel.Compare(this.sequence, val.strVal, op);
                    }

                case ValueDataType.String:
                    switch (val.type)
                    {
                        default:
                            throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.TypeMismatch));
                        case ValueDataType.Boolean:
                            return QueryValueModel.Compare(this.strVal, val.boolVal, op);
                        case ValueDataType.Double:
                            return QueryValueModel.Compare(this.strVal, val.dblVal, op);
                        case ValueDataType.Sequence:
                            return QueryValueModel.Compare(this.strVal, val.sequence, op);
                        case ValueDataType.String:
                            return QueryValueModel.Compare(this.strVal, val.strVal, op);
                    }
            }
        }
 internal abstract void Match(int valIndex, ref Value val, QueryBranchResultSet results);
 internal override void Match(int valIndex, ref Value val, QueryBranchResultSet results)
 {
     QueryBranch branch = null;
     if (ValueDataType.Sequence == val.Type)
     {
         NodeSequence sequence = val.Sequence;
         for (int i = 0; i < sequence.Count; ++i)
         {
             branch = this[sequence.Items[i].NumberValue()];
             if (null != branch)
             {
                 results.Add(branch, valIndex);
             }
         }
     }
     else
     {
         branch = this[val.ToDouble()];
         if (null != branch)
         {
             results.Add(branch, valIndex);
         }
     }
 }
 internal virtual void CollectMatches(int valIndex, ref Value val, QueryBranchResultSet results)
 {
     this.branchIndex.Match(valIndex, ref val, results);
 }
 internal void Push(Value[] buffer, int startAt, int addCount)
 {
     if (addCount > 0)
     {
         int index = this.stack.stackPtr + 1;
         this.stack.stackPtr += addCount;
         if (this.stack.NeedsGrowth)
         {
             this.GrowStack(addCount);
         }
         if (1 == addCount)
         {
             this.buffer.buffer[index] = buffer[startAt];
         }
         else
         {
             Array.Copy(buffer, startAt, this.buffer.buffer, index, addCount);
         }
         this.buffer.buffer[this.frames.stackPtr].FrameEndPtr = this.stack.stackPtr;
     }
 }