/// <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]; }
/// <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; }
/// <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; }
/// <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); }
/// <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; }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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; }
/// <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); }
/// <summary> /// Constructs a new void type. /// </summary> /// <param name="typeContext">The parent type context.</param> internal VoidType(IRTypeContext typeContext) : base(typeContext) { }
/// <summary> /// Constructs a new string type. /// </summary> /// <param name="typeContext">The parent type context.</param> internal StringType(IRTypeContext typeContext) : base(typeContext) { }
/// <summary> /// Constructs a new .Net runtime-specific handle type. /// </summary> /// <param name="typeContext">The parent type context.</param> internal HandleType(IRTypeContext typeContext) : base(typeContext) { }