예제 #1
0
        /// <summary>
        /// Constructs a new primitive type.
        /// </summary>
        /// <param name="typeContext">The parent type context.</param>
        /// <param name="basicValueType">The basic value type.</param>
        internal PrimitiveType(IRTypeContext typeContext, BasicValueType basicValueType)
            : base(typeContext)
        {
            BasicValueType = basicValueType;

            Size = Alignment = BasicTypeInformation[(int)basicValueType];
        }
예제 #2
0
 /// <summary>
 /// Constructs a new padding type.
 /// </summary>
 /// <param name="typeContext">The parent type context.</param>
 /// <param name="primitiveType">The primitive type to use for padding.</param>
 internal PaddingType(IRTypeContext typeContext, PrimitiveType primitiveType)
     : base(typeContext)
 {
     PrimitiveType = primitiveType;
     Size          = PrimitiveType.Size;
     Alignment     = PrimitiveType.Alignment;
 }
예제 #3
0
        /// <summary>
        /// Constructs a new type.
        /// </summary>
        /// <param name="typeContext">The parent type context.</param>
        protected TypeNode(IRTypeContext typeContext)
            : base(Location.Unknown)
        {
            TypeContext = typeContext;

            Size      = 1;
            Alignment = 1;
        }
예제 #4
0
 /// <summary>
 /// Constructs a new view type.
 /// </summary>
 /// <param name="typeContext">The parent type context.</param>
 /// <param name="elementType">The element type.</param>
 /// <param name="addressSpace">The associated address space.</param>
 internal ViewType(
     IRTypeContext typeContext,
     TypeNode elementType,
     MemoryAddressSpace addressSpace)
     : base(typeContext, elementType, addressSpace)
 {
     Size = Alignment = 4;
     AddFlags(TypeFlags.ViewDependent);
 }
예제 #5
0
            /// <summary>
            /// Creates a new type builder with the given capacity.
            /// </summary>
            /// <param name="typeContext">The current type context.</param>
            /// <param name="capacity">The initial capacity.</param>
            internal Builder(IRTypeContext typeContext, int capacity)
            {
                Debug.Assert(capacity >= 0, "Invalid capacity");
                fieldsBuilder    = ImmutableArray.CreateBuilder <TypeNode>(capacity);
                allFieldsBuilder = ImmutableArray.CreateBuilder <TypeNode>(capacity);
                offsetsBuilder   = ImmutableArray.CreateBuilder <int>(capacity);
                TypeContext      = typeContext;

                Alignment = Offset = 0;
            }
예제 #6
0
 /// <summary>
 /// Constructs a new address type.
 /// </summary>
 /// <param name="typeContext">The parent type context.</param>
 /// <param name="elementType">The element type.</param>
 /// <param name="addressSpace">The associated address space.</param>
 protected AddressSpaceType(
     IRTypeContext typeContext,
     TypeNode elementType,
     MemoryAddressSpace addressSpace)
     : base(typeContext)
 {
     Debug.Assert(elementType != null, "Invalid element type");
     ElementType  = elementType;
     AddressSpace = addressSpace;
     AddFlags(elementType.Flags);
 }
예제 #7
0
 /// <summary>
 /// Constructs a new array type.
 /// </summary>
 /// <param name="typeContext">The parent type context.</param>
 /// <param name="elementType">The element type.</param>
 /// <param name="dimensions">The number of dimensions.</param>
 internal ArrayType(
     IRTypeContext typeContext,
     TypeNode elementType,
     int dimensions)
     : base(typeContext)
 {
     ElementType = elementType;
     Dimensions  = dimensions;
     Size        = Alignment = 4;
     AddFlags(elementType.Flags | TypeFlags.ArrayDependent);
 }
예제 #8
0
 /// <summary>
 /// Constructs a new pointer type.
 /// </summary>
 /// <param name="typeContext">The parent type context.</param>
 /// <param name="elementType">The element type.</param>
 /// <param name="addressSpace">The associated address space.</param>
 internal PointerType(
     IRTypeContext typeContext,
     TypeNode elementType,
     MemoryAddressSpace addressSpace)
     : base(typeContext, elementType, addressSpace)
 {
     Size = Alignment =
         typeContext.Context.TargetPlatform == TargetPlatform.X86
         ? 4
         : 8;
     AddFlags(TypeFlags.PointerDependent);
 }
예제 #9
0
파일: ArrayType.cs 프로젝트: losttech/ILGPU
        /// <summary>
        /// Constructs a new array type.
        /// </summary>
        /// <param name="typeContext">The parent type context.</param>
        /// <param name="elementType">The element type.</param>
        /// <param name="numDimensions">The number of array dimensions.</param>
        internal ArrayType(
            IRTypeContext typeContext,
            TypeNode elementType,
            int numDimensions)
            : base(typeContext)
        {
            this.Assert(numDimensions > 0);
            ElementType   = elementType;
            NumDimensions = numDimensions;

            Size = Alignment = 4;
            AddFlags(TypeFlags.ArrayDependent);
        }
예제 #10
0
            /// <summary>
            /// Creates a new type builder with the given capacity.
            /// </summary>
            /// <param name="typeContext">The current type context.</param>
            /// <param name="capacity">The initial capacity.</param>
            /// <param name="size">The custom size in bytes (if any).</param>
            internal Builder(
                IRTypeContext typeContext,
                int capacity,
                int size)
            {
                Debug.Assert(capacity >= 0, "Invalid capacity");
                Debug.Assert(size >= 0, "Invalid size");

                typeFlags = TypeFlags.None;

                fieldsBuilder    = ImmutableArray.CreateBuilder <TypeNode>(capacity);
                allFieldsBuilder = ImmutableArray.CreateBuilder <TypeNode>(capacity);
                offsetsBuilder   = ImmutableArray.CreateBuilder <int>(capacity);
                TypeContext      = typeContext;

                ExplicitSize = size;
                Alignment    = Offset = 0;
            }
예제 #11
0
 /// <summary>
 /// Constructs a new pointer type.
 /// </summary>
 /// <param name="typeContext">The parent type context.</param>
 /// <param name="elementType">The element type.</param>
 /// <param name="addressSpace">The associated address space.</param>
 internal PointerType(
     IRTypeContext typeContext,
     TypeNode elementType,
     MemoryAddressSpace addressSpace)
     : base(typeContext, elementType, addressSpace)
 {
     if (typeContext.TargetPlatform == TargetPlatform.X86)
     {
         Size           = Alignment = 4;
         BasicValueType = BasicValueType.Int32;
     }
     else
     {
         Size           = Alignment = 8;
         BasicValueType = BasicValueType.Int64;
     }
     AddFlags(TypeFlags.PointerDependent);
 }
예제 #12
0
파일: VoidType.cs 프로젝트: m4rs-mt/ILGPU
 /// <summary>
 /// Constructs a new void type.
 /// </summary>
 /// <param name="typeContext">The parent type context.</param>
 internal VoidType(IRTypeContext typeContext)
     : base(typeContext)
 {
 }
예제 #13
0
 /// <summary>
 /// Constructs a new string type.
 /// </summary>
 /// <param name="typeContext">The parent type context.</param>
 internal StringType(IRTypeContext typeContext)
     : base(typeContext)
 {
 }
예제 #14
0
 /// <summary>
 /// Constructs a new .Net runtime-specific handle type.
 /// </summary>
 /// <param name="typeContext">The parent type context.</param>
 internal HandleType(IRTypeContext typeContext)
     : base(typeContext)
 {
 }