@@ -35,14 +35,6 @@ impl Type {
35
35
pub fn get < ' a , T > ( context : & ' a Context ) -> & ' a Type where T : Compile < ' a > {
36
36
T :: get_type ( context)
37
37
}
38
- /// Make a new array with the length given.
39
- pub fn new_array < ' a > ( element : & ' a Type , length : usize ) -> & ' a Type {
40
- unsafe { core:: LLVMArrayType ( element. into ( ) , length as c_uint ) } . into ( )
41
- }
42
- /// Make a new vector with the length given.
43
- pub fn new_vector < ' a > ( element : & ' a Type , length : usize ) -> & ' a Type {
44
- unsafe { core:: LLVMVectorType ( element. into ( ) , length as c_uint ) } . into ( )
45
- }
46
38
/// Returns true if the size of the type is known at compile-time.
47
39
///
48
40
/// This is equivalent to the type implementing `Sized` in Rust
@@ -196,4 +188,45 @@ impl IntegerType {
196
188
pub fn get_width ( & self ) -> usize {
197
189
unsafe { core:: LLVMGetIntTypeWidth ( self . into ( ) ) as usize }
198
190
}
191
+ }
192
+
193
+ /// A vector type.
194
+ pub struct VectorType ;
195
+ native_ref ! { & VectorType = LLVMTypeRef }
196
+ get_context ! { VectorType , LLVMGetTypeContext }
197
+ to_str ! { VectorType , LLVMPrintTypeToString }
198
+ sub ! { VectorType , LLVMVectorTypeKind }
199
+ impl VectorType {
200
+ /// Make a new vector type with the length given.
201
+ pub fn new ( element : & Type , length : usize ) -> & VectorType {
202
+ unsafe { core:: LLVMVectorType ( element. into ( ) , length as c_uint ) } . into ( )
203
+ }
204
+ /// Returns the element type of this vector type.
205
+ pub fn get_element ( & self ) -> & Type {
206
+ unsafe { mem:: transmute ( core:: LLVMGetElementType ( self . into ( ) ) ) }
207
+ }
208
+ /// Returns the number of elements in this vector type.
209
+ pub fn get_size ( & self ) -> usize {
210
+ unsafe { core:: LLVMGetVectorSize ( self . into ( ) ) as usize }
211
+ }
212
+ }
213
+ /// An array type.
214
+ pub struct ArrayType ;
215
+ native_ref ! { & ArrayType = LLVMTypeRef }
216
+ get_context ! { ArrayType , LLVMGetTypeContext }
217
+ to_str ! { ArrayType , LLVMPrintTypeToString }
218
+ sub ! { ArrayType , LLVMArrayTypeKind }
219
+ impl ArrayType {
220
+ /// Make a new array type with the length given.
221
+ pub fn new ( element : & Type , length : usize ) -> & ArrayType {
222
+ unsafe { core:: LLVMArrayType ( element. into ( ) , length as c_uint ) } . into ( )
223
+ }
224
+ /// Returns the element type of this array type.
225
+ pub fn get_element ( & self ) -> & Type {
226
+ unsafe { mem:: transmute ( core:: LLVMGetElementType ( self . into ( ) ) ) }
227
+ }
228
+ /// Returns the number of elements in this vector type.
229
+ pub fn get_length ( & self ) -> usize {
230
+ unsafe { core:: LLVMGetArrayLength ( self . into ( ) ) as usize }
231
+ }
199
232
}
0 commit comments