View over a Qil choice operator.
Don't construct QIL nodes directly; instead, use the QilFactory.
Inheritance: QilBinary
Esempio n. 1
0
 public XmlQueryType CheckChoice(QilChoice node)
 {
     CheckXmlType(node.Expression, XmlQueryTypeFactory.IntX);
     CheckClassAndNodeType(node.Branches, typeof(QilList), QilNodeType.BranchList);
     Check(node.Branches.Count > 0, node, "Choice must have at least one branch");
     return(node.Branches.XmlType);
 }
Esempio n. 2
0
        public QilChoice Choice(QilNode expression, QilNode branches)
        {
            QilChoice n = new QilChoice(QilNodeType.Choice, expression, branches);

            n.XmlType = this.typeCheck.CheckChoice(n);
            TraceNode(n);
            return(n);
        }
Esempio n. 3
0
 protected virtual QilNode VisitChoice(QilChoice n)
 {
     return(VisitChildren(n));
 }
 public XmlQueryType CheckChoice(QilChoice node) {
     CheckXmlType(node.Expression, XmlQueryTypeFactory.IntX);
     CheckClassAndNodeType(node.Branches, typeof(QilList), QilNodeType.BranchList);
     Check(node.Branches.Count > 0, node, "Choice must have at least one branch");
     return node.Branches.XmlType;
 }
Esempio n. 5
0
 protected virtual QilNode VisitChoice(QilChoice n) { return VisitChildren(n); }
Esempio n. 6
0
 protected override QilNode VisitChoice(QilChoice n)
 {
     return(NoReplace(n));
 }
Esempio n. 7
0
 protected override QilNode VisitChoice(QilChoice n) { return NoReplace(n); }
        protected override QilNode VisitChoice(QilChoice local0) {
            QilNode local1 = local0[0];
            QilNode local2 = local0[1];
            if (this[XmlILOptimization.AnnotateConstruction]) {
                if (AllowReplace(XmlILOptimization.AnnotateConstruction, local0)) {
                    
    this.contentAnalyzer.Analyze(local0, null);
}
            }
            return NoReplace(local0);
        }
Esempio n. 9
0
 public QilChoice Choice(QilNode expression, QilNode branches) {
     QilChoice n = new QilChoice(QilNodeType.Choice, expression, branches);
     n.XmlType = this.typeCheck.CheckChoice(n);
     TraceNode(n);
     return n;
 }
        /// <summary>
        /// Analyze choice.
        /// </summary>
        protected virtual void AnalyzeChoice(QilChoice ndChoice, XmlILConstructInfo info) {
            PossibleXmlStates xstatesChoice;
            int idx;

            // Visit default branch; save resulting states
            idx = ndChoice.Branches.Count - 1;
            ndChoice.Branches[idx] = AnalyzeContent(ndChoice.Branches[idx]);
            xstatesChoice = this.xstates;

            // Visit all other branches
            while (--idx >= 0) {
                // Restore starting states and visit the next branch
                this.xstates = info.InitialStates;
                ndChoice.Branches[idx] = AnalyzeContent(ndChoice.Branches[idx]);

                // Choice ending states consist of combination of all branch states
                if (xstatesChoice != this.xstates)
                    xstatesChoice = PossibleXmlStates.Any;
            }

            this.xstates = xstatesChoice;
        }
Esempio n. 11
0
        /// <summary>
        /// Generate code for QilNodeType.Choice.
        /// </summary>
        protected override QilNode VisitChoice(QilChoice ndChoice)
        {
            QilNode ndBranches;
            Label[] switchLabels;
            Label lblOtherwise, lblDone;
            int regBranches, idx;
            Debug.Assert(XmlILConstructInfo.Read(ndChoice).PushToWriterFirst);

            // Evaluate the expression
            NestedVisit(ndChoice.Expression);

            // Generate switching code
            ndBranches = ndChoice.Branches;
            regBranches = ndBranches.Count - 1;
            switchLabels = new Label[regBranches];
            for (idx = 0; idx < regBranches; idx++)
                switchLabels[idx] = _helper.DefineLabel();

            lblOtherwise = _helper.DefineLabel();
            lblDone = _helper.DefineLabel();

            // switch (value)
            //   case 0: goto Label[0];
            //   ...
            //   case N-1: goto Label[N-1];
            //   default: goto LabelOtherwise;
            _helper.Emit(OpCodes.Switch, switchLabels);
            _helper.EmitUnconditionalBranch(OpCodes.Br, lblOtherwise);

            for (idx = 0; idx < regBranches; idx++)
            {
                // Label[i]:
                _helper.MarkLabel(switchLabels[idx]);

                // Generate regular branch code
                NestedVisit(ndBranches[idx]);

                // goto LabelDone
                _helper.EmitUnconditionalBranch(OpCodes.Br, lblDone);
            }

            // LabelOtherwise:
            _helper.MarkLabel(lblOtherwise);

            // Generate otherwise branch code
            NestedVisit(ndBranches[idx]);

            // LabelDone:
            _helper.MarkLabel(lblDone);

            _iterCurr.Storage = StorageDescriptor.None();

            return ndChoice;
        }
Esempio n. 12
0
 protected override QilNode VisitChoice(QilChoice local0)
 {
     QilNode local1 = local0[0];
     QilNode local2 = local0[1];
     if (this[XmlILOptimization.AnnotateConstruction])
     {
         // PATTERN: [AnnotateConstruction] $ctor:(Choice * *) => { ... }
         if (AllowReplace(XmlILOptimization.AnnotateConstruction, local0))
         {
             _contentAnalyzer.Analyze(local0, null);
         }
     }
     return NoReplace(local0);
 }