Ejemplo n.º 1
0
 void CompileSteps(XPathExprList steps, bool start)
 {
     for (int i = 0; i < steps.Count; ++i)
     {
         Fx.Assert(XPathExprType.PathStep == steps[i].Type, "");
         XPathStepExpr step = (XPathStepExpr)steps[i];
         if (!step.SelectDesc.Axis.IsSupported())
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new QueryCompileException(QueryCompileError.UnsupportedAxis));
         }
         Opcode stepOpcode = null;
         if (start && 0 == i)
         {
             // First steps
             // Is this an absolute path? We have an absolute path if the first step selects the root
             if (QueryNodeType.Root == step.SelectDesc.Type)
             {
                 stepOpcode = new SelectRootOpcode();
             }
             else
             {
                 stepOpcode = new InitialSelectOpcode(step.SelectDesc);
             }
         }
         else
         {
             Fx.Assert(QueryNodeType.Root != step.SelectDesc.Type, "");
             stepOpcode = new SelectOpcode(step.SelectDesc);
         }
         this.codeBlock.Append(stepOpcode);
         // The step may have predicates..
         if (step.SubExprCount > 0)
         {
             this.compiler.nestingLevel++;
             if (this.compiler.nestingLevel > 3) // throw if we find something deepter than [ [ ] ]
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new QueryCompileException(QueryCompileError.PredicateNestingTooDeep));
             }
             this.CompilePredicates(step.SubExpr);
             this.compiler.nestingLevel--;
         }
     }
 }
Ejemplo n.º 2
0
 private void CompileSteps(XPathExprList steps, bool start)
 {
     for (int i = 0; i < steps.Count; i++)
     {
         XPathStepExpr expr = (XPathStepExpr)steps[i];
         if (!expr.SelectDesc.Axis.IsSupported())
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new QueryCompileException(QueryCompileError.UnsupportedAxis));
         }
         Opcode opcode = null;
         if (start && (i == 0))
         {
             if (QueryNodeType.Root == expr.SelectDesc.Type)
             {
                 opcode = new SelectRootOpcode();
             }
             else
             {
                 opcode = new InitialSelectOpcode(expr.SelectDesc);
             }
         }
         else
         {
             opcode = new SelectOpcode(expr.SelectDesc);
         }
         this.codeBlock.Append(opcode);
         if (expr.SubExprCount > 0)
         {
             this.compiler.nestingLevel++;
             if (this.compiler.nestingLevel > 3)
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new QueryCompileException(QueryCompileError.PredicateNestingTooDeep));
             }
             this.CompilePredicates(expr.SubExpr);
             this.compiler.nestingLevel--;
         }
     }
 }
Ejemplo n.º 3
0
 void CompileSteps(XPathExprList steps, bool start)
 {
     for (int i = 0; i < steps.Count; ++i)
     {
         Fx.Assert(XPathExprType.PathStep == steps[i].Type, "");
         XPathStepExpr step = (XPathStepExpr)steps[i];
         if (!step.SelectDesc.Axis.IsSupported())
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new QueryCompileException(QueryCompileError.UnsupportedAxis));
         }
         Opcode stepOpcode = null;
         if (start && 0 == i)
         {
             // First steps
             // Is this an absolute path? We have an absolute path if the first step selects the root
             if (QueryNodeType.Root == step.SelectDesc.Type)
             {
                 stepOpcode = new SelectRootOpcode();
             }
             else
             {
                 stepOpcode = new InitialSelectOpcode(step.SelectDesc);
             }
         }
         else
         {
             Fx.Assert(QueryNodeType.Root != step.SelectDesc.Type, "");
             stepOpcode = new SelectOpcode(step.SelectDesc);
         }
         this.codeBlock.Append(stepOpcode);
         // The step may have predicates..
         if (step.SubExprCount > 0)
         {
             this.compiler.nestingLevel++;
             if (this.compiler.nestingLevel > 3) // throw if we find something deepter than [ [ ] ]
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new QueryCompileException(QueryCompileError.PredicateNestingTooDeep));
             }
             this.CompilePredicates(step.SubExpr);
             this.compiler.nestingLevel--;
         }
     }
 }
 private void CompileSteps(XPathExprList steps, bool start)
 {
     for (int i = 0; i < steps.Count; i++)
     {
         XPathStepExpr expr = (XPathStepExpr) steps[i];
         if (!expr.SelectDesc.Axis.IsSupported())
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new QueryCompileException(QueryCompileError.UnsupportedAxis));
         }
         Opcode opcode = null;
         if (start && (i == 0))
         {
             if (QueryNodeType.Root == expr.SelectDesc.Type)
             {
                 opcode = new SelectRootOpcode();
             }
             else
             {
                 opcode = new InitialSelectOpcode(expr.SelectDesc);
             }
         }
         else
         {
             opcode = new SelectOpcode(expr.SelectDesc);
         }
         this.codeBlock.Append(opcode);
         if (expr.SubExprCount > 0)
         {
             this.compiler.nestingLevel++;
             if (this.compiler.nestingLevel > 3)
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new QueryCompileException(QueryCompileError.PredicateNestingTooDeep));
             }
             this.CompilePredicates(expr.SubExpr);
             this.compiler.nestingLevel--;
         }
     }
 }