Esempio n. 1
0
        public CatClass(CatClass o, string s, CatKind k)
        {
            foreach (KeyValuePair<string, CatKind> kvp in o.GetFields())
                mpFields.Add(kvp.Key, kvp.Value);

            mpFields.Add(s, k);
        }
Esempio n. 2
0
 public CatKind Rename(CatKind k)
 {
     if (k is CatFxnType)
         return Rename(k as CatFxnType);
     else if (k is CatTypeKind)
         return Rename(k as CatTypeKind);
     else if (k is CatStackVar)
         return Rename(k as CatStackVar);
     else if (k is CatTypeVector)
         return Rename(k as CatTypeVector);
     else if (k is CatCustomKind)
         return k;
     else if (k is CatRecursiveType)
         return k;
     else
         throw new Exception(k.ToString() + " is an unrecognized kind");
 }
 public Constraint CatKindToConstraint(CatKind k)
 {
     if (k is CatTypeVector)
     {
         return TypeVectorToConstraintVector(k as CatTypeVector);
     }
     else if (k is CatFxnType)
     {
         return FxnTypeToRelation(k as CatFxnType);
     }
     else if (k.IsKindVar())
     {
         return KindVarToConstraintVar(k);
     }
     else
     {
         return new Constant(k.ToIdString());
     }   
 }
Esempio n. 4
0
 public static bool IsFreeVar(CatKind k, CatFxnType left, CatFxnType right, CatFxnType except)
 {
     return !DoesVarOccurIn(k, left, except) && !DoesVarOccurIn(k, right, except);
 }
Esempio n. 5
0
 public static bool DoesVarOccurIn(CatKind k, CatFxnType ft, CatFxnType except)
 {
     if (!k.IsKindVar()) return false;
     if (k == except) return false;
     return DoesVarOccurIn(k, ft.GetCons(), except) || DoesVarOccurIn(k, ft.GetProd(), except);
 }
Esempio n. 6
0
        public static bool DoesVarOccurIn(CatKind k, CatTypeVector vec, CatFxnType except)
        {
            foreach (CatKind tmp in vec.GetKinds())
            {
                if (tmp.IsKindVar() && tmp.Equals(k))
                    return true;

                if (tmp is CatFxnType)
                    if (DoesVarOccurIn(k, tmp as CatFxnType, except))
                        return true;
            }
            return false;
        }
Esempio n. 7
0
 public override bool Equals(CatKind k)
 {
     return k is CatRecursiveType;
 }
Esempio n. 8
0
 public CatQuotedType(CatKind k)
 {
     GetProd().Add(k);
 }
Esempio n. 9
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;
 }
Esempio n. 10
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());
 }
Esempio n. 11
0
 public bool IsFreeVar(CatKind var)
 {
     if (!var.IsKindVar())
         return false;
     return mpFreeVars.ContainsKey(var.ToString());
 }
Esempio n. 12
0
 private bool IsFreeVar(CatKind k, CatVarScopes scopes)
 {
     return scopes.IsFreeVar(this, k);
 }
Esempio n. 13
0
 public bool DoesVarExist(CatKind k)
 {
     Trace.Assert(k.IsKindVar());
     foreach (CatKind tmp in GetDescendantKinds())
         if (tmp.Equals(k))
             return true;
     return false;
 }
Esempio n. 14
0
 public Constraint KindVarToConstraintVar(CatKind k)
 {
     Trace.Assert(k.IsKindVar());
     return CreateVar(k.ToString().Substring(1));
 }
Esempio n. 15
0
 public CatClass AddFieldType(string s, CatKind k)
 {
     return new CatClass(this, s, k);
 }