Example #1
0
        /// <summary>
        /// Merge constructor.
        /// </summary>
        public FlowState(FlowState state1, FlowState state2)
        {
            Debug.Assert(state1 != null);
            Debug.Assert(state2 != null);
            Debug.Assert(state1.FlowContext == state2.FlowContext);

            //
            _varsType        = EnumeratorExtension.MixArrays(state1._varsType, state2._varsType, TypeRefMask.Or);
            _flowCtx         = state1._flowCtx;
            _initializedMask = state1._initializedMask & state2._initializedMask;

            // intersection of other variable flags
            if (state1._lessThanLongMax != null && state2._lessThanLongMax != null)
            {
                _lessThanLongMax = new HashSet <VariableHandle>(state1._lessThanLongMax);
                _lessThanLongMax.Intersect(state2._lessThanLongMax);
            }

            //// merge variables kind,
            //// conflicting kinds are not allowed currently!
            //if (state1._varKindMap != null || state1._varKindMap != null)
            //{
            //    _varKindMap = new Dictionary<VariableName, VariableKind>();
            //    if (state1._varKindMap != null) state1._varKindMap.Foreach(k => SetVarKind(k.Key, k.Value));
            //    if (state2._varKindMap != null) state2._varKindMap.Foreach(k => SetVarKind(k.Key, k.Value));
            //}
        }
Example #2
0
        /// <summary>
        /// Merge constructor.
        /// </summary>
        public FlowState(FlowState state1, FlowState state2)
        {
            Debug.Assert(state1 != null);
            Debug.Assert(state2 != null);
            Debug.Assert(state1.FlowContext == state2.FlowContext);
            Debug.Assert(state1.Version == state2.Version);

            //
            FlowContext      = state1.FlowContext;
            _varsType        = EnumeratorExtension.MergeArrays(state1._varsType, state2._varsType, MergeType);
            _initializedMask = state1._initializedMask | state2._initializedMask;

            // intersection of other variable flags
            if (state1._notes != null && state2._notes != null)
            {
                _notes = new HashSet <NoteData>(state1._notes);
                _notes.Intersect(state2._notes);
            }

            Version = state1.Version;

            //// merge variables kind,
            //// conflicting kinds are not allowed currently!
            //if (state1._varKindMap != null || state1._varKindMap != null)
            //{
            //    _varKindMap = new Dictionary<VariableName, VariableKind>();
            //    if (state1._varKindMap != null) state1._varKindMap.Foreach(k => SetVarKind(k.Key, k.Value));
            //    if (state2._varKindMap != null) state2._varKindMap.Foreach(k => SetVarKind(k.Key, k.Value));
            //}
        }
Example #3
0
        public bool Equals(FlowState other)
        {
            if (object.ReferenceEquals(this, other))
            {
                return(true);
            }

            if (other == null ||
                other._flowCtx != _flowCtx ||
                other._initializedMask != _initializedMask)
            {
                return(false);
            }

            return(EnumeratorExtension.EqualEntries(_varsType, other._varsType));
        }
Example #4
0
        /// <summary>
        /// Merge constructor.
        /// </summary>
        public FlowState(FlowState state1, FlowState state2)
        {
            Contract.ThrowIfNull(state1);
            Contract.ThrowIfNull(state2);
            Debug.Assert(state1._common == state2._common);

            //
            _varsType        = EnumeratorExtension.MixArrays(state1._varsType, state2._varsType, TypeRefMask.Or);
            _common          = state1._common;
            _initializedMask = state1._initializedMask & state2._initializedMask;

            // intersection of other variable flags
            if (state1._lessThanLongMax != null && state2._lessThanLongMax != null)
            {
                _lessThanLongMax = new HashSet <string>(state1._lessThanLongMax);
                _lessThanLongMax.Intersect(state2._lessThanLongMax);
            }
        }