Merge() public method

public Merge ( State other ) : void
other State
return void
Esempio n. 1
0
        public static State merge(State state1, State state2)
        {
            State ret = state1.Clone();

            ret.Merge(state2);
            return(ret);
        }
Esempio n. 2
0
        public DataType VisitIf(IfStatement i)
        {
            DataType type1, type2;
            State    s1 = scope.Clone();
            State    s2 = scope.Clone();

            // Ignore condition for now
            i.Test.Accept(this);

            if (i.Then != null)
            {
                type1 = i.Then.Accept(this);
            }
            else
            {
                type1 = DataType.Cont;
            }

            if (i.Else != null)
            {
                type2 = i.Else.Accept(this);
            }
            else
            {
                type2 = DataType.Cont;
            }

            bool cont1 = UnionType.Contains(type1, DataType.Cont);
            bool cont2 = UnionType.Contains(type2, DataType.Cont);

            // Decide which branch affects the downstream state
            if (cont1 && cont2)
            {
                s1.Merge(s2);
                scope.Overwrite(s1);
            }
            else if (cont1)
            {
                scope.Overwrite(s1);
            }
            else if (cont2)
            {
                scope.Overwrite(s2);
            }
            return(UnionType.Union(type1, type2));
        }