public static bool IsEqualTo(this TypeStruct first, TypeStruct second)
        {
            if (first.Tag != second.Tag)
            {
                return(false);
            }

            switch (first.Tag)
            {
            case TypeStructs.Quantified:
                var arrow1 = (TypeStruct.Quantified)first;
                var arrow2 = (TypeStruct.Quantified)second;

                return(arrow1.Content.Polarity == arrow2.Content.Polarity &&
                       arrow1.Content.From.IsEqualTo(arrow2.Content.From) &&
                       arrow1.Content.To.IsEqualTo(arrow2.Content.To));

            case TypeStructs.Module:
                var module1 = (TypeStruct.Module)first;
                var module2 = (TypeStruct.Module)second;

                var members1 = module1.Content.Members;
                var members2 = module2.Content.Members;

                if (members1.Length != members2.Length)
                {
                    return(false);
                }

                foreach (var index in ArrayOperations.CountUp(members1.Length))
                {
                    if (!members1[index].IsEqualTo(members2[index]))
                    {
                        return(false);
                    }
                }

                return(true);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Esempio n. 2
0
 public Type(TypeStruct content)
     : base(TypedProductions.Type)
 {
     Content = content;
 }