Exemplo n.º 1
0
        public UnionAlternative AddAlternative(DataType dt)
        {
            var alt = new UnionAlternative(dt, Alternatives.Count);

            Alternatives.Add(alt);
            return(alt);
        }
Exemplo n.º 2
0
        public override DataType Clone()
        {
            DataType pre = PreferredType != null?PreferredType.Clone() : null;

            UnionType u = new UnionType(Name, pre);

            foreach (UnionAlternative a in this.Alternatives.Values)
            {
                UnionAlternative aClone = new UnionAlternative(a.DataType.Clone());
                u.Alternatives.Add(aClone);
            }
            return(u);
        }
Exemplo n.º 3
0
        public int Compare(UnionType x, UnionType y, int count)
        {
            int d;

            d = x.Alternatives.Count - y.Alternatives.Count;
            if (d != 0)
            {
                return(d);
            }
            ++count;
            for (int i = 0; i < x.Alternatives.Count; ++i)
            {
                UnionAlternative ax = x.Alternatives.Values[i];
                UnionAlternative ay = y.Alternatives.Values[i];
                d = Compare(ax.DataType, ay.DataType, count);
                if (d != 0)
                {
                    return(d);
                }
            }
            return(0);
        }