Пример #1
0
 public static IType Unroll(IType type)
 {
     /*
     (TApp TCRec (TAbs unique type3)) = type
     return UnrollRecursiveType(type3, unique);
     */
     if (type is TApp)
     {
         IType type1 = ((TApp)type).Function;
         IType type2 = ((TApp)type).Argument;
         if (type1 is TCRec)
         {
             if (type2 is TAbs)
             {
                 Unique unique = ((TAbs)type2).Parameter;
                 IType type3 = ((TAbs)type2).Body;
                 return UnrollRecursiveType(type3, unique);
             }
         }
     }
     throw new ArgumentException(
         string.Format(
             "{0} is not a recursive type", type.Show()
         )
     );
 }
Пример #2
0
 private IType CheckFunctionTypeApp(
     IType parameterType,
     IType returnType,
     IType argumentType
 )
 {
     if (!argumentType.Equals(parameterType))
     {
         throw new ArgumentException(
             string.Format(
                 "unexpected {0}, expected {1}",
                 argumentType.Show(),
                 parameterType.Show()
             )
         );
     }
     return returnType;
 }