Beispiel #1
0
        protected override ISet <DescriptorKind> Transfer(DivideExpression expression, RuleEngine engine)
        {
            var left  = engine.Visit(expression.Left);
            var right = engine.Visit(expression.Right);

            if (right.Contains(One.Instance) || left.Contains(Zero.Instance))
            {
                return(left);
            }

            if (AllContainRule(LoopIndependent.Instance, left, right))
            {
                return(_loopIndependentSet);
            }

            return(_emptySet);
        }
Beispiel #2
0
 /// <summary>
 /// Transfers the information of the given expression to the resulting set.
 /// </summary>
 /// <param name="expression">The expression where the information should be transferred of.</param>
 /// <param name="engine">The engine applying the transfer.</param>
 /// <returns>The transferred information.</returns>
 protected abstract ISet <DescriptorKind> Transfer(TExpression expression, RuleEngine engine);
        protected override ISet <DescriptorKind> Transfer(ModuloExpression expression, RuleEngine engine)
        {
            var left  = engine.Visit(expression.Left);
            var right = engine.Visit(expression.Right);

            var result = new HashSet <DescriptorKind>();

            if (left.Contains(Zero.Instance) || right.Contains(One.Instance))
            {
                result.Add(Zero.Instance);
            }

            if (AllContainRule(LoopIndependent.Instance, left, right))
            {
                result.Add(LoopIndependent.Instance);
            }

            return(result);
        }
Beispiel #4
0
 public ISet <DescriptorKind> Transfer(Expression expression, RuleEngine engine)
 {
     return(Transfer((TExpression)expression, engine));
 }
        protected override ISet <DescriptorKind> Transfer(VariableExpression expression, RuleEngine engine)
        {
            var variableName = expression.Name;

            return(engine.Input
                   .Where(descriptor => descriptor.Name.Equals(variableName))
                   .Select(descriptor => descriptor.Kind)
                   .WithoutKind <Definition>()
                   .ToImmutableHashSet());
        }