Пример #1
0
 public bool isDerivedFrom(Context context, CategoryType other)
 {
     try
     {
         IDeclaration thisDecl = getDeclaration(context);
         if (thisDecl is CategoryDeclaration)
         {
             return(isDerivedFrom(context, (CategoryDeclaration)thisDecl, other));
         }
     }
     catch (SyntaxError)
     {
     }
     return(false); // TODO
 }
Пример #2
0
 public bool isDerivedFrom(Context context, CategoryDeclaration decl, CategoryType other)
 {
     if (decl.getDerivedFrom() == null)
     {
         return(false);
     }
     foreach (String derived in decl.getDerivedFrom())
     {
         CategoryType ct = new CategoryType(derived);
         if (ct.Equals(other) || ct.isDerivedFrom(context, other))
         {
             return(true);
         }
     }
     return(false);
 }
Пример #3
0
        public override bool Equals(Object obj)
        {
            if (obj == this)
            {
                return(true);
            }
            if (obj == null)
            {
                return(false);
            }
            if (!(obj is CategoryType))
            {
                return(false);
            }
            CategoryType other = (CategoryType)obj;

            return(this.GetTypeName().Equals(other.GetTypeName()));
        }
Пример #4
0
        public override bool isMoreSpecificThan(Context context, IType other)
        {
            if (other is NullType || other is AnyType || other is MissingType)
            {
                return(true);
            }
            if (!(other is CategoryType))
            {
                return(false);
            }
            CategoryType otherCat = (CategoryType)other;

            if (otherCat.isAnonymous())
            {
                return(true);
            }
            CategoryDeclaration thisDecl = context.getRegisteredDeclaration <CategoryDeclaration>(this.GetTypeName());

            if (thisDecl.isDerivedFrom(context, otherCat))
            {
                return(true);
            }
            return(false);
        }
Пример #5
0
 public bool isDerivedFromAnonymous(Context context, CategoryDeclaration thisDecl, CategoryType other)
 {
     if (!other.isAnonymous())
     {
         return(false);
     }
     try
     {
         IDeclaration otherDecl = other.getDeclaration(context);
         if (otherDecl is CategoryDeclaration)
         {
             return(isDerivedFromAnonymous(context, thisDecl, (CategoryDeclaration)otherDecl));
         }
     }
     catch (SyntaxError)
     {
     }
     return(false); // TODO
 }
Пример #6
0
 public bool isAssignableFrom(Context context, CategoryType other)
 {
     return("Any" == this.typeName ||
            other.isDerivedFrom(context, this) ||
            other.isDerivedFromAnonymous(context, this));
 }
Пример #7
0
 public CategoryType(CategoryType source, bool mutable)
     : base(source.GetFamily())
 {
     this.typeName = source.typeName;
     this.Mutable  = mutable;
 }