コード例 #1
0
ファイル: Context.cs プロジェクト: wyl2008056/Llvm.NET
        /// <summary>Creates a simple boolean attribute</summary>
        /// <param name="kind">Kind of attribute</param>
        public AttributeValue CreateAttribute(AttributeKind kind)
        {
            if (kind.RequiresIntValue( ))
            {
                throw new ArgumentException($"Attribute {kind} requires a value", nameof(kind));
            }

            return(CreateAttribute(kind, 0ul));
        }
コード例 #2
0
        /// <summary>Creates an attribute with an integer value parameter</summary>
        /// <param name="kind">The kind of attribute</param>
        /// <param name="value">Value for the attribute</param>
        /// <remarks>
        /// <para>Not all attributes support a value and those that do don't all support
        /// a full 64bit value. The following table provides the kinds of attributes
        /// accepting a value and the allowed size of the values.</para>
        /// <list type="table">
        /// <listheader><term><see cref="AttributeKind"/></term><term>Bit Length</term></listheader>
        /// <item><term><see cref="AttributeKind.Alignment"/></term><term>32</term></item>
        /// <item><term><see cref="AttributeKind.StackAlignment"/></term><term>32</term></item>
        /// <item><term><see cref="AttributeKind.Dereferenceable"/></term><term>64</term></item>
        /// <item><term><see cref="AttributeKind.DereferenceableOrNull"/></term><term>64</term></item>
        /// </list>
        /// </remarks>
        /// <returns><see cref="AttributeValue"/> with the specified kind and value</returns>
        public AttributeValue CreateAttribute(AttributeKind kind, UInt64 value)
        {
            kind.ValidateDefined(nameof(kind));
            if (!kind.RequiresIntValue( ))
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Attribute_0_does_not_support_a_value, kind), nameof(kind));
            }

            var handle = LLVMCreateEnumAttribute(ContextHandle
                                                 , kind.GetEnumAttributeId( )
                                                 , value
                                                 );

            return(AttributeValue.FromHandle(this, handle));
        }
コード例 #3
0
        /// <summary>Creates an attribute with an integer value parameter</summary>
        /// <param name="kind">The kind of attribute</param>
        /// <param name="value">Value for the attribute</param>
        /// <remarks>
        /// <para>Not all attributes support a value and those that do don't all support
        /// a full 64bit value. The following table provides the kinds of attributes
        /// accepting a value and the allowed size of the values.</para>
        /// <list type="table">
        /// <listheader><term><see cref="AttributeKind"/></term><term>Bit Length</term></listheader>
        /// <item><term><see cref="AttributeKind.Alignment"/></term><term>32</term></item>
        /// <item><term><see cref="AttributeKind.StackAlignment"/></term><term>32</term></item>
        /// <item><term><see cref="AttributeKind.Dereferenceable"/></term><term>64</term></item>
        /// <item><term><see cref="AttributeKind.DereferenceableOrNull"/></term><term>64</term></item>
        /// </list>
        /// </remarks>
        /// <returns><see cref="AttributeValue"/> with the specified kind and value</returns>
        public AttributeValue CreateAttribute(AttributeKind kind, UInt64 value)
        {
            kind.ValidateDefined(nameof(kind));
            if (!kind.RequiresIntValue( ))
            {
                throw new ArgumentException($"Attribute {kind} does not support a value", nameof(kind));
            }

            var handle = LLVMCreateEnumAttribute(ContextHandle
                                                 , kind.GetEnumAttributeId( )
                                                 , value
                                                 );

            return(AttributeValue.FromHandle(this, handle));
        }