Пример #1
0
        private Query ProcessNode(AstNode root, Flags flags, out Props props)
        {
            if (++_parseDepth > MaxParseDepth)
            {
                throw XPathException.Create(SR.Xp_QueryTooComplex);
            }

            Debug.Assert(root != null, "root != null");
            Query result = null;
            props = Props.None;
            switch (root.Type)
            {
                case AstNode.AstType.Axis:
                    result = ProcessAxis((Axis)root, flags, out props);
                    break;
                case AstNode.AstType.Operator:
                    result = ProcessOperator((Operator)root, out props);
                    break;
                case AstNode.AstType.Filter:
                    result = ProcessFilter((Filter)root, flags, out props);
                    break;
                case AstNode.AstType.ConstantOperand:
                    result = new OperandQuery(((Operand)root).OperandValue);
                    break;
                case AstNode.AstType.Variable:
                    result = ProcessVariable((Variable)root);
                    break;
                case AstNode.AstType.Function:
                    result = ProcessFunction((Function)root, out props);
                    break;
                case AstNode.AstType.Group:
                    result = new GroupQuery(ProcessNode(((Group)root).GroupNode, Flags.None, out props));
                    break;
                case AstNode.AstType.Root:
                    result = new AbsoluteQuery();
                    break;
                default:
                    Debug.Fail("Unknown QueryType encountered!!");
                    break;
            }
            --_parseDepth;
            return result;
        }
 private Query ProcessNode(AstNode root, Flags flags, out Props props) {
     Debug.Assert(root != null, "root != null");
     Query result = null;
     props = Props.None;
     switch (root.Type) {
     case AstNode.AstType.Axis:
         result = ProcessAxis((Axis)root, flags, out props);
         break;
     case AstNode.AstType.Operator:
         result = ProcessOperator((Operator)root, out props);
         break;
     case AstNode.AstType.Filter:
         result = ProcessFilter((Filter)root, flags, out props);
         break;
     case AstNode.AstType.ConstantOperand:
         result = new OperandQuery(((Operand)root).OperandValue);
         break;
     case AstNode.AstType.Variable:
         result = ProcessVariable((Variable)root);
         break;
     case AstNode.AstType.Function:
         result = ProcessFunction((Function)root, out props);
         break;
     case AstNode.AstType.Group:
         result = new GroupQuery(ProcessNode(((Group)root).GroupNode, Flags.None, out props));
         break;
     case AstNode.AstType.Root:
         result = new AbsoluteQuery();
         break;
     default:
         Debug.Assert(false, "Unknown QueryType encountered!!");
         break;
     }
     return result;
 }