Exemplo n.º 1
0
 public CatFxnType Rename(CatFxnType f)
 {
     if (f == null)
     {
         throw new Exception("Invalid null parameter to rename function");
     }
     return(new CatFxnType(Rename(f.GetCons()), Rename(f.GetProd()), f.HasSideEffects()));
 }
Exemplo n.º 2
0
        /// <summary>
        /// This is a raw equivalency check: no normalization is done.
        /// To comparse function type normally you would use CompareFxnTypes,
        /// which in turn calls this function.
        /// </summary>
        public override bool Equals(CatKind k)
        {
            if (!(k is CatFxnType))
            {
                return(false);
            }
            CatFxnType f = k as CatFxnType;

            return(GetCons().Equals(f.GetCons()) && GetProd().Equals(f.GetProd()) &&
                   HasSideEffects() == f.HasSideEffects());
        }
Exemplo n.º 3
0
        public static string ToPrettyString(CatFxnType ft, Dictionary <string, string> dic)
        {
            // remove rho variables
            ft = ft.Clone();
            ft.RemoveImplicitRhoVariables();

            string s = ToPrettyString(ft.GetCons(), dic);

            if (ft.HasSideEffects())
            {
                s += " ~> ";
            }
            else
            {
                s += " -> ";
            }

            s += ToPrettyString(ft.GetProd(), dic);

            return(s);
        }
Exemplo n.º 4
0
        public override bool IsSubtypeOf(CatKind k)
        {
            if (k.IsAny() || k.IsDynFxn())
            {
                return(IsRuntimePolymorphic());
            }
            if (k is CatTypeVar)
            {
                return(true);
            }
            if (!(k is CatFxnType))
            {
                return(false);
            }
            CatFxnType f   = k as CatFxnType;
            bool       ret = GetCons().IsSubtypeOf(f.GetCons()) && GetProd().IsSubtypeOf(f.GetProd());

            if (HasSideEffects())
            {
                ret = ret && f.HasSideEffects();
            }
            return(ret);
        }
Exemplo n.º 5
0
 public CatFxnType Rename(CatFxnType f)
 {
     if (f == null)
         throw new Exception("Invalid null parameter to rename function");
     return new CatFxnType(Rename(f.GetCons()), Rename(f.GetProd()), f.HasSideEffects());
 }
Exemplo n.º 6
0
 static CatFxnType RenameVars(CatFxnType ft, CatTypeVarList vars)
 {
     return new CatFxnType(RenameVars(ft.GetCons(), vars), RenameVars(ft.GetProd(), vars), ft.HasSideEffects());
 }
Exemplo n.º 7
0
        public static string ToPrettyString(CatFxnType ft, Dictionary<string, string> dic)
        {
            // remove rho variables
            ft = ft.Clone();
            ft.RemoveImplicitRhoVariables();

            string s = ToPrettyString(ft.GetCons(), dic);                        
            if (ft.HasSideEffects())
                s += " ~> ";
            else
                s += " -> ";

            s += ToPrettyString(ft.GetProd(), dic);

            return s;
        }
Exemplo n.º 8
0
 static CatFxnType RenameVars(CatFxnType ft, CatTypeVarList vars)
 {
     return(new CatFxnType(RenameVars(ft.GetCons(), vars), RenameVars(ft.GetProd(), vars), ft.HasSideEffects()));
 }