示例#1
0
        public bool CanBeImplicitlyConvertedTo(StatePrimitive type)
        {
            var a = this.Order;
            var b = type.Order;

            return(Equals(LcaMap[a, b], type));
        }
示例#2
0
 public void AddAncestor(StatePrimitive type)
 {
     if (!TryAddAncestor(type))
     {
         throw new InvalidOperationException();
     }
 }
示例#3
0
        public StatePrimitive GetLastCommonPrimitiveAncestor(StatePrimitive other)
        {
            var a = this.Order;
            var b = other.Order;

            return(LcaMap[a, b]);
        }
示例#4
0
        public void AddDescedant(StatePrimitive type)
        {
            if (type == null)
            {
                return;
            }

            if (Descedant == null)
            {
                Descedant = type;
            }
            else
            {
                var ancestor = Descedant.GetLastCommonAncestorOrNull(type);
                if (ancestor != null)
                {
                    Descedant = ancestor;
                }
            }
        }
示例#5
0
        public bool TryAddAncestor(StatePrimitive type)
        {
            if (type == null)
            {
                return(true);
            }

            if (Ancestor == null)
            {
                Ancestor = type;
            }
            else
            {
                var res = Ancestor.GetFirstCommonDescendantOrNull(type);
                if (res == null)
                {
                    return(false);
                }
                Ancestor = res;
            }

            return(true);
        }
示例#6
0
        public bool Fits(StatePrimitive primitiveState)
        {
            if (HasAncestor)
            {
                if (!primitiveState.CanBeImplicitlyConvertedTo(Ancestor))
                {
                    return(false);
                }
            }

            if (HasDescendant)
            {
                if (!Descedant.CanBeImplicitlyConvertedTo(primitiveState))
                {
                    return(false);
                }
            }

            if (IsComparable && !primitiveState.IsComparable)
            {
                return(false);
            }
            return(true);
        }
示例#7
0
文件: StateArray.cs 项目: tmteam/NFun
 public bool CanBeImplicitlyConvertedTo(StatePrimitive type)
 => type.Equals(StatePrimitive.Any);
示例#8
0
文件: StateArray.cs 项目: tmteam/NFun
 public bool Apply(IStateCombination2dimensionalVisitor visitor, TicNode ancestorNode, TicNode descendantNode,
                   StatePrimitive ancestor)
 => visitor.Apply(ancestor, this, ancestorNode, descendantNode);
示例#9
0
 public StatePrimitive GetFirstCommonDescendantOrNull(StatePrimitive other)
 => FcdMap[this.Order, other.Order];
示例#10
0
 public ConstrainsState(ITypeState desc = null, StatePrimitive anc = null)
 {
     Descedant = desc;
     Ancestor  = anc;
 }