コード例 #1
0
 public bool IsAssociatedTypeProtocolConstrained(TypeMapper mapper)
 {
     if (Constraints.Count == 0)
     {
         return(false);
     }
     foreach (BaseConstraint bc in Constraints)
     {
         Entity ent = null;
         InheritanceConstraint inh = bc as InheritanceConstraint;
         if (inh != null)
         {
             ent = mapper.GetEntityForTypeSpec(inh.InheritsTypeSpec);
         }
         else
         {
             EqualityConstraint eq = (EqualityConstraint)bc;
             ent = mapper.GetEntityForTypeSpec(eq.Type2Spec);
         }
         if (ent == null)
         {
             continue;                     // shouldn't happen
         }
         if (ent.EntityType != EntityType.Protocol)
         {
             return(false);
         }
         if (ent.Type is ProtocolDeclaration proto && proto.HasAssociatedTypes)
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #2
0
 public bool IsClassConstrained(TypeMapper mapper)
 {
     if (Constraints.Count == 0)
     {
         return(false);
     }
     foreach (BaseConstraint bc in Constraints)
     {
         Entity ent = null;
         InheritanceConstraint inh = bc as InheritanceConstraint;
         if (inh != null)
         {
             ent = mapper.GetEntityForTypeSpec(inh.InheritsTypeSpec);
         }
         else
         {
             EqualityConstraint eq = (EqualityConstraint)bc;
             ent = mapper.GetEntityForTypeSpec(eq.Type2Spec);
         }
         if (ent == null)
         {
             continue;                     // shouldn't happen
         }
         if (ent.EntityType == EntityType.Class)
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #3
0
		public bool IsProtocolConstrained (TypeMapper mapper)
		{
			if (Constraints.Count == 0)
				return false;
			foreach (BaseConstraint bc in Constraints) {
				Entity ent = null;
				InheritanceConstraint inh = bc as InheritanceConstraint;
				if (inh != null) {
					ent = mapper.GetEntityForTypeSpec (inh.InheritsTypeSpec);
				} else {
					EqualityConstraint eq = (EqualityConstraint)bc;
					ent = mapper.GetEntityForTypeSpec (eq.Type2Spec);
				}
				if (ent == null)
					continue; // shouldn't happen
				if (ent.EntityType != EntityType.Protocol)
					return false;
			}
			return true;
		}