Example #1
0
        /// <summary>Initializes a new instance of the <see cref="DebugBasicType"/> class.</summary>
        /// <param name="llvmType">Type to wrap debug information for</param>
        /// <param name="module">Module to use when constructing the debug information</param>
        /// <param name="name">Source language name of the type</param>
        /// <param name="encoding">Encoding for the type</param>
        public DebugBasicType(ITypeRef llvmType, BitcodeModule module, string name, DiTypeKind encoding)
        {
            llvmType.ValidateNotNull(nameof(llvmType));
            module.ValidateNotNull(nameof(module));
            name.ValidateNotNullOrWhiteSpace(nameof(name));

            if (module.Layout == null)
            {
                throw new ArgumentException("Module needs Layout to build basic types", nameof(module));
            }

            switch (llvmType.Kind)
            {
            case TypeKind.Void:
            case TypeKind.Float16:
            case TypeKind.Float32:
            case TypeKind.Float64:
            case TypeKind.X86Float80:
            case TypeKind.Float128m112:
            case TypeKind.Float128:
            case TypeKind.Integer:
                break;

            default:
                throw new ArgumentException("Expected a primitive type", nameof(llvmType));
            }

            NativeType = llvmType;
            DIType     = module.DIBuilder
                         .CreateBasicType(name
                                          , module.Layout.BitSizeOf(llvmType)
                                          , encoding
                                          );
        }
Example #2
0
        /// <summary>Initializes a new instance of the <see cref="DebugBasicType"/> class.</summary>
        /// <param name="llvmType">Type to wrap debug information for</param>
        /// <param name="module">Module to use when constructing the debug information</param>
        /// <param name="name">Source language name of the type</param>
        /// <param name="encoding">Encoding for the type</param>
        public DebugBasicType(ITypeRef llvmType, BitcodeModule module, string name, DiTypeKind encoding)
            : base(llvmType,
                   module.ValidateNotNull(nameof(module))
                   .DIBuilder
                   .CreateBasicType(name
                                    , module.Layout.BitSizeOf(llvmType)
                                    , encoding
                                    )
                   )
        {
            name.ValidateNotNullOrWhiteSpace(nameof(name));

            if (module.Layout == null)
            {
                throw new ArgumentException(Resources.Module_needs_Layout_to_build_basic_types, nameof(module));
            }

            switch (llvmType.Kind)
            {
            case TypeKind.Void:
            case TypeKind.Float16:
            case TypeKind.Float32:
            case TypeKind.Float64:
            case TypeKind.X86Float80:
            case TypeKind.Float128m112:
            case TypeKind.Float128:
            case TypeKind.Integer:
                break;

            default:
                throw new ArgumentException(Resources.Expected_a_primitive_type, nameof(llvmType));
            }
        }