Ejemplo n.º 1
0
        //$TODO: change the signature to disallow nulls.
        public DataType?Unify(DataType?a, DataType?b)
        {
            if (++recDepth > 100)
            {
                --recDepth;
                DebugEx.Error(trace, "Unifier: exceeded stack depth, giving up");
                if (a == null && b == null)
                {
                    return(null);
                }
                if (a == null)
                {
                    return(b);
                }
                if (b == null)
                {
                    return(a);
                }
                return(factory.CreateUnionType(null, null, new[] { a, b }));
            }
            var u = UnifyInternal(a, b);

            --recDepth;
            return(u);
        }
Ejemplo n.º 2
0
        public DataType Unify(DataType a, DataType b)
        {
            if (++recDepth > 100)
            {
                //$BUG: should emit warning in the error log.
                --recDepth;
                Debug.Print("Exceeded stack depth, giving up");
                return(factory.CreateUnionType(null, null, new[] { a, b }));
            }
            var u = UnifyInternal(a, b);

            --recDepth;
            return(u);
        }
Ejemplo n.º 3
0
        public override DataType BuildDataType(Reko.Core.Types.TypeFactory factory)
        {
            UnionType u = factory.CreateUnionType(Name, null);

            foreach (var alt in Alternatives)
            {
                u.Alternatives.Add(new UnionAlternative(alt.Name, alt.Type.BuildDataType(factory)));
            }
            return(u);
        }