Пример #1
0
        /// <summary>
        /// Tests if a particular type is an integer type.
        /// </summary>
        /// <param name="type">The type to examine.</param>
        /// <returns>
        /// <c>true</c> if <paramref name="type"/> has an integer spec;
        /// otherwise, <c>false</c>.
        /// </returns>
        public static bool IsIntegerType(this IType type)
        {
            var attr = type.Attributes.GetOrNull(
                IntrinsicAttribute.GetIntrinsicAttributeType(AttributeName));

            return(attr != null);
        }
Пример #2
0
 /// <summary>
 /// Reads out an integer spec attribute as an integer spec.
 /// </summary>
 /// <param name="attribute">The integer spec attribute to read.</param>
 /// <returns>The integer spec described by the attribute.</returns>
 public static IntegerSpec Read(IntrinsicAttribute attribute)
 {
     ContractHelpers.Assert(attribute.Name == AttributeName);
     ContractHelpers.Assert(attribute.Arguments.Count == 2);
     return(new IntegerSpec(
                ((IntegerConstant)attribute.Arguments[0]).ToInt32(),
                ((IntegerConstant)attribute.Arguments[1]).ToBoolean()));
 }
Пример #3
0
        /// <summary>
        /// Gets a type's integer spec if it has one.
        /// </summary>
        /// <param name="type">The type to examine.</param>
        /// <returns>
        /// An integer spec if <paramref name="type"/> has one; otherwise, <c>null</c>.
        /// </returns>
        public static IntegerSpec GetIntegerSpecOrNull(this IType type)
        {
            var attr = type.Attributes.GetOrNull(
                IntrinsicAttribute.GetIntrinsicAttributeType(AttributeName));

            if (attr == null)
            {
                return(null);
            }
            else
            {
                return(Read((IntrinsicAttribute)attr));
            }
        }
Пример #4
0
        /// <summary>
        /// Gets a member's access modifier. Members are internal by default.
        /// </summary>
        /// <param name="member">The member to examine.</param>
        /// <returns>The member's access modifier if it has one; otherwise, internal.</returns>
        public static AccessModifier GetAccessModifier(this IMember member)
        {
            var attr = member.Attributes.GetOrNull(
                IntrinsicAttribute.GetIntrinsicAttributeType(AttributeName));

            if (attr == null)
            {
                return(AccessModifier.Internal);
            }
            else
            {
                return(Read((IntrinsicAttribute)attr));
            }
        }
Пример #5
0
 /// <summary>
 /// Reads out an access modifier attribute as an access modifier.
 /// </summary>
 /// <param name="attribute">The access modifier attribute to read.</param>
 /// <returns>The access modifier described by the attribute.</returns>
 public static AccessModifier Read(IntrinsicAttribute attribute)
 {
     ContractHelpers.Assert(attribute.Name == AttributeName);
     ContractHelpers.Assert(attribute.Arguments.Count == 1);
     return(invModifierNames[((StringConstant)attribute.Arguments[0]).Value]);
 }