Пример #1
0
 public QilNode GetLast()
 {
     if (_last == null)
     {
         // Create a let that will be fixed up later in ConstructLoop or by LastFixupVisitor
         _last = _f.Let(_f.Double(0));
     }
     return(_last);
 }
        private QilNode MatchPatternsWhosePriorityGreater(QilIterator it, List <Pattern> patternList, QilNode matcher)
        {
            if (patternList.Count == 0)
            {
                return(matcher);
            }
            if (IsNoMatch(matcher))
            {
                return(MatchPatterns(it, patternList));
            }

            QilIterator stopPriority = f.Let(matcher);
            QilNode     result       = f.Int32(NoMatch);
            int         lastPriority = NoMatch;

            foreach (Pattern pattern in patternList)
            {
                // if (stopPriority > pattern.Priority) then stopPriority     else
                // if ($it =~ pattern.Match)            then pattern.Priority else...

                // First 'if' is generated lazily since it is not needed if priorities are consecutive numbers
                Debug.Assert(pattern.Priority > lastPriority);
                if (pattern.Priority > lastPriority + 1)
                {
                    result = f.Conditional(f.Gt(stopPriority, f.Int32(lastPriority)), stopPriority, result);
                }

                result       = f.Conditional(MatchPattern(it, pattern.Match), f.Int32(pattern.Priority), result);
                lastPriority = pattern.Priority;
            }

            // If the last pattern has the highest priority, the check can be eliminated
            if (lastPriority != this.priority)
            {
                result = f.Conditional(f.Gt(stopPriority, f.Int32(lastPriority)), stopPriority, result);
            }

            return(f.Loop(stopPriority, result));
        }
Пример #3
0
 public QilNode GetLast() =>
 // Create a let that will be fixed up later in ConstructLoop or by LastFixupVisitor
 _last ??= _f.Let(_f.Double(0));