예제 #1
0
        private CopyAbstractValue(ImmutableHashSet <AnalysisEntity> analysisEntities, CopyAbstractValueKind kind)
        {
            Debug.Assert(analysisEntities.IsEmpty == (kind != CopyAbstractValueKind.Known));

            AnalysisEntities = analysisEntities;
            Kind             = kind;
        }
 public static bool IsKnown(this CopyAbstractValueKind kind)
 {
     return(kind switch
     {
         CopyAbstractValueKind.KnownValueCopy
         or CopyAbstractValueKind.KnownReferenceCopy => true,
         _ => false,
     });
        public static bool IsKnown(this CopyAbstractValueKind kind)
        {
            switch (kind)
            {
            case CopyAbstractValueKind.KnownValueCopy:
            case CopyAbstractValueKind.KnownReferenceCopy:
                return(true);

            default:
                return(false);
            }
        }
        public static CopyAbstractValueKind MergeIfBothKnown(this CopyAbstractValueKind kind, CopyAbstractValueKind kindToMerge)
        {
            if (!kind.IsKnown() ||
                !kindToMerge.IsKnown())
            {
                return(kind);
            }

            // Can only ensure value copy if one of the kinds is a value copy.
            return(kind == CopyAbstractValueKind.KnownValueCopy || kindToMerge == CopyAbstractValueKind.KnownValueCopy ?
                   CopyAbstractValueKind.KnownValueCopy :
                   CopyAbstractValueKind.KnownReferenceCopy);
        }
        internal CopyAbstractValue(ImmutableHashSet <AnalysisEntity> analysisEntities, CopyAbstractValueKind kind)
        {
            Debug.Assert(analysisEntities.IsEmpty != kind.IsKnown());
            Debug.Assert(kind != CopyAbstractValueKind.KnownReferenceCopy || analysisEntities.All(a => !a.Type.IsValueType));

            if (kind == CopyAbstractValueKind.KnownValueCopy &&
                analysisEntities.Count == 1 &&
                !analysisEntities.First().Type.IsValueType)
            {
                kind = CopyAbstractValueKind.KnownReferenceCopy;
            }

            AnalysisEntities = analysisEntities;
            Kind             = kind;
        }
 private CopyAbstractValue(CopyAbstractValueKind kind)
     : this(ImmutableHashSet <AnalysisEntity> .Empty, kind)
 {
     Debug.Assert(!kind.IsKnown());
 }