forked from M-Labs/nac3
get_type* -> llvm_type*
This commit is contained in:
parent
40aa27c42c
commit
a2937e1742
@ -13,7 +13,7 @@ use super::*;
|
|||||||
pub struct Any<'ctx>(pub BasicTypeEnum<'ctx>);
|
pub struct Any<'ctx>(pub BasicTypeEnum<'ctx>);
|
||||||
|
|
||||||
impl<'ctx> ModelBase<'ctx> for Any<'ctx> {
|
impl<'ctx> ModelBase<'ctx> for Any<'ctx> {
|
||||||
fn get_type_impl(&self, _size_t: IntType<'ctx>, _ctx: &'ctx Context) -> BasicTypeEnum<'ctx> {
|
fn llvm_type_impl(&self, _size_t: IntType<'ctx>, _ctx: &'ctx Context) -> BasicTypeEnum<'ctx> {
|
||||||
self.0.as_basic_type_enum()
|
self.0.as_basic_type_enum()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,8 +47,8 @@ pub struct Array<Len, Item> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'ctx, Len: ArrayLen, Item: ModelBase<'ctx>> ModelBase<'ctx> for Array<Len, Item> {
|
impl<'ctx, Len: ArrayLen, Item: ModelBase<'ctx>> ModelBase<'ctx> for Array<Len, Item> {
|
||||||
fn get_type_impl(&self, size_t: IntType<'ctx>, ctx: &'ctx Context) -> BasicTypeEnum<'ctx> {
|
fn llvm_type_impl(&self, size_t: IntType<'ctx>, ctx: &'ctx Context) -> BasicTypeEnum<'ctx> {
|
||||||
let item = self.item.get_type_impl(size_t, ctx);
|
let item = self.item.llvm_type_impl(size_t, ctx);
|
||||||
item.array_type(self.len.length()).into()
|
item.array_type(self.len.length()).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,8 +24,8 @@ pub trait ModelBase<'ctx> {
|
|||||||
// NOTE: Taking `size_t` here instead of `CodeGenerator` to be object safe.
|
// NOTE: Taking `size_t` here instead of `CodeGenerator` to be object safe.
|
||||||
// In fact, all the entire model abstraction need from the `CodeGenerator` is its `get_size_type()`.
|
// In fact, all the entire model abstraction need from the `CodeGenerator` is its `get_size_type()`.
|
||||||
|
|
||||||
// NOTE: Model's get_type but object-safe and returns BasicTypeEnum, instead of a known BasicType variant.
|
// NOTE: Model's llvm_type but object-safe and returns BasicTypeEnum, instead of a known BasicType variant.
|
||||||
fn get_type_impl(&self, size_t: IntType<'ctx>, ctx: &'ctx Context) -> BasicTypeEnum<'ctx>;
|
fn llvm_type_impl(&self, size_t: IntType<'ctx>, ctx: &'ctx Context) -> BasicTypeEnum<'ctx>;
|
||||||
|
|
||||||
// NOTE: Model's check_type but object-safe.
|
// NOTE: Model's check_type but object-safe.
|
||||||
fn check_type_impl(
|
fn check_type_impl(
|
||||||
@ -45,7 +45,7 @@ pub trait ModelBase<'ctx> {
|
|||||||
/// - [`Int<AnyInt>`] identifies an [`IntType`] with bit-width of whatever is set in the [`AnyInt`] object.
|
/// - [`Int<AnyInt>`] identifies an [`IntType`] with bit-width of whatever is set in the [`AnyInt`] object.
|
||||||
/// - [`Any`] identifies a [`BasicType`] set in the [`Any`] object itself.
|
/// - [`Any`] identifies a [`BasicType`] set in the [`Any`] object itself.
|
||||||
///
|
///
|
||||||
/// You can get the [`BasicType`] out of a model with [`Model::get_type`].
|
/// You can get the [`BasicType`] out of a model with [`Model::llvm_type`].
|
||||||
///
|
///
|
||||||
/// Furthermore, [`Instance<'ctx, M>`] is a simple structure that carries a [`BasicValue`] with [`BasicType`] identified by model `M`.
|
/// Furthermore, [`Instance<'ctx, M>`] is a simple structure that carries a [`BasicValue`] with [`BasicType`] identified by model `M`.
|
||||||
///
|
///
|
||||||
@ -85,10 +85,14 @@ pub trait Model<'ctx>: fmt::Debug + Clone + Copy + ModelBase<'ctx> {
|
|||||||
|
|
||||||
/// Return the [`BasicType`] of this model.
|
/// Return the [`BasicType`] of this model.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
fn get_type<G: CodeGenerator + ?Sized>(&self, generator: &G, ctx: &'ctx Context) -> Self::Type {
|
fn llvm_type<G: CodeGenerator + ?Sized>(
|
||||||
|
&self,
|
||||||
|
generator: &G,
|
||||||
|
ctx: &'ctx Context,
|
||||||
|
) -> Self::Type {
|
||||||
let size_t = generator.get_size_type(ctx);
|
let size_t = generator.get_size_type(ctx);
|
||||||
|
|
||||||
let ty = self.get_type_impl(size_t, ctx);
|
let ty = self.llvm_type_impl(size_t, ctx);
|
||||||
match Self::Type::try_from(ty) {
|
match Self::Type::try_from(ty) {
|
||||||
Ok(ty) => ty,
|
Ok(ty) => ty,
|
||||||
_ => panic!("Model::Type is inconsistent with what is returned from ModelBase::get_type_impl()! Got {ty:?}."),
|
_ => panic!("Model::Type is inconsistent with what is returned from ModelBase::get_type_impl()! Got {ty:?}."),
|
||||||
@ -101,7 +105,7 @@ pub trait Model<'ctx>: fmt::Debug + Clone + Copy + ModelBase<'ctx> {
|
|||||||
generator: &mut G,
|
generator: &mut G,
|
||||||
ctx: &'ctx Context,
|
ctx: &'ctx Context,
|
||||||
) -> IntValue<'ctx> {
|
) -> IntValue<'ctx> {
|
||||||
self.get_type(generator, ctx).size_of().unwrap()
|
self.llvm_type(generator, ctx).size_of().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if a [`BasicType`] matches the [`BasicType`] of this model.
|
/// Check if a [`BasicType`] matches the [`BasicType`] of this model.
|
||||||
@ -149,7 +153,7 @@ pub trait Model<'ctx>: fmt::Debug + Clone + Copy + ModelBase<'ctx> {
|
|||||||
generator: &mut G,
|
generator: &mut G,
|
||||||
ctx: &CodeGenContext<'ctx, '_>,
|
ctx: &CodeGenContext<'ctx, '_>,
|
||||||
) -> Instance<'ctx, Ptr<Self>> {
|
) -> Instance<'ctx, Ptr<Self>> {
|
||||||
let p = ctx.builder.build_alloca(self.get_type(generator, ctx.ctx), "").unwrap();
|
let p = ctx.builder.build_alloca(self.llvm_type(generator, ctx.ctx), "").unwrap();
|
||||||
unsafe { Ptr(*self).believe_value(p) }
|
unsafe { Ptr(*self).believe_value(p) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +164,8 @@ pub trait Model<'ctx>: fmt::Debug + Clone + Copy + ModelBase<'ctx> {
|
|||||||
ctx: &CodeGenContext<'ctx, '_>,
|
ctx: &CodeGenContext<'ctx, '_>,
|
||||||
len: IntValue<'ctx>,
|
len: IntValue<'ctx>,
|
||||||
) -> Instance<'ctx, Ptr<Self>> {
|
) -> Instance<'ctx, Ptr<Self>> {
|
||||||
let p = ctx.builder.build_array_alloca(self.get_type(generator, ctx.ctx), len, "").unwrap();
|
let p =
|
||||||
|
ctx.builder.build_array_alloca(self.llvm_type(generator, ctx.ctx), len, "").unwrap();
|
||||||
unsafe { Ptr(*self).believe_value(p) }
|
unsafe { Ptr(*self).believe_value(p) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,7 +175,7 @@ pub trait Model<'ctx>: fmt::Debug + Clone + Copy + ModelBase<'ctx> {
|
|||||||
ctx: &mut CodeGenContext<'ctx, '_>,
|
ctx: &mut CodeGenContext<'ctx, '_>,
|
||||||
name: Option<&str>,
|
name: Option<&str>,
|
||||||
) -> Result<Instance<'ctx, Ptr<Self>>, String> {
|
) -> Result<Instance<'ctx, Ptr<Self>>, String> {
|
||||||
let ty = self.get_type(generator, ctx.ctx).as_basic_type_enum();
|
let ty = self.llvm_type(generator, ctx.ctx).as_basic_type_enum();
|
||||||
let p = generator.gen_var_alloc(ctx, ty, name)?;
|
let p = generator.gen_var_alloc(ctx, ty, name)?;
|
||||||
Ok(unsafe { Ptr(*self).believe_value(p) })
|
Ok(unsafe { Ptr(*self).believe_value(p) })
|
||||||
}
|
}
|
||||||
@ -183,7 +188,7 @@ pub trait Model<'ctx>: fmt::Debug + Clone + Copy + ModelBase<'ctx> {
|
|||||||
name: Option<&'ctx str>,
|
name: Option<&'ctx str>,
|
||||||
) -> Result<Instance<'ctx, Ptr<Self>>, String> {
|
) -> Result<Instance<'ctx, Ptr<Self>>, String> {
|
||||||
// TODO: Remove ArraySliceValue
|
// TODO: Remove ArraySliceValue
|
||||||
let ty = self.get_type(generator, ctx.ctx).as_basic_type_enum();
|
let ty = self.llvm_type(generator, ctx.ctx).as_basic_type_enum();
|
||||||
let p = generator.gen_array_var_alloc(ctx, ty, len, name)?;
|
let p = generator.gen_array_var_alloc(ctx, ty, len, name)?;
|
||||||
Ok(unsafe { Ptr(*self).believe_value(PointerValue::from(p)) })
|
Ok(unsafe { Ptr(*self).believe_value(PointerValue::from(p)) })
|
||||||
}
|
}
|
||||||
@ -206,7 +211,7 @@ pub trait Model<'ctx>: fmt::Debug + Clone + Copy + ModelBase<'ctx> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
let value = match self.get_type(generator, ctx).as_basic_type_enum() {
|
let value = match self.llvm_type(generator, ctx).as_basic_type_enum() {
|
||||||
BasicTypeEnum::ArrayType(t) => make!(t, BasicValueEnum::into_array_value),
|
BasicTypeEnum::ArrayType(t) => make!(t, BasicValueEnum::into_array_value),
|
||||||
BasicTypeEnum::IntType(t) => make!(t, BasicValueEnum::into_int_value),
|
BasicTypeEnum::IntType(t) => make!(t, BasicValueEnum::into_int_value),
|
||||||
BasicTypeEnum::FloatType(t) => make!(t, BasicValueEnum::into_float_value),
|
BasicTypeEnum::FloatType(t) => make!(t, BasicValueEnum::into_float_value),
|
||||||
|
@ -42,7 +42,7 @@ impl<'ctx> FloatKind<'ctx> for AnyFloat<'ctx> {
|
|||||||
pub struct Float<N>(pub N);
|
pub struct Float<N>(pub N);
|
||||||
|
|
||||||
impl<'ctx, N: FloatKind<'ctx>> ModelBase<'ctx> for Float<N> {
|
impl<'ctx, N: FloatKind<'ctx>> ModelBase<'ctx> for Float<N> {
|
||||||
fn get_type_impl(&self, _size_t: IntType<'ctx>, ctx: &'ctx Context) -> BasicTypeEnum<'ctx> {
|
fn llvm_type_impl(&self, _size_t: IntType<'ctx>, ctx: &'ctx Context) -> BasicTypeEnum<'ctx> {
|
||||||
self.0.get_float_type(ctx).into()
|
self.0.get_float_type(ctx).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ impl<'ctx, 'a, 'b, 'c, 'd, G: CodeGenerator + ?Sized> CallFunction<'ctx, 'a, 'b,
|
|||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn arg<M: Model<'ctx>>(mut self, arg: Instance<'ctx, M>) -> Self {
|
pub fn arg<M: Model<'ctx>>(mut self, arg: Instance<'ctx, M>) -> Self {
|
||||||
let arg = Arg {
|
let arg = Arg {
|
||||||
ty: arg.model.get_type(self.generator, self.ctx.ctx).as_basic_type_enum().into(),
|
ty: arg.model.llvm_type(self.generator, self.ctx.ctx).as_basic_type_enum().into(),
|
||||||
val: arg.value.as_basic_value_enum().into(),
|
val: arg.value.as_basic_value_enum().into(),
|
||||||
};
|
};
|
||||||
self.args.push(arg);
|
self.args.push(arg);
|
||||||
@ -73,7 +73,7 @@ impl<'ctx, 'a, 'b, 'c, 'd, G: CodeGenerator + ?Sized> CallFunction<'ctx, 'a, 'b,
|
|||||||
/// Call the function and expect the function to return a value of type of `return_model`.
|
/// Call the function and expect the function to return a value of type of `return_model`.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn returning<M: Model<'ctx>>(self, name: &str, return_model: M) -> Instance<'ctx, M> {
|
pub fn returning<M: Model<'ctx>>(self, name: &str, return_model: M) -> Instance<'ctx, M> {
|
||||||
let ret_ty = return_model.get_type(self.generator, self.ctx.ctx);
|
let ret_ty = return_model.llvm_type(self.generator, self.ctx.ctx);
|
||||||
|
|
||||||
let ret = self.call(|tys| ret_ty.fn_type(tys, false), name);
|
let ret = self.call(|tys| ret_ty.fn_type(tys, false), name);
|
||||||
let ret = BasicValueEnum::try_from(ret.as_any_value_enum()).unwrap(); // Must work
|
let ret = BasicValueEnum::try_from(ret.as_any_value_enum()).unwrap(); // Must work
|
||||||
|
@ -69,7 +69,7 @@ impl<'ctx> IntKind<'ctx> for AnyInt<'ctx> {
|
|||||||
pub struct Int<N>(pub N);
|
pub struct Int<N>(pub N);
|
||||||
|
|
||||||
impl<'ctx, N: IntKind<'ctx>> ModelBase<'ctx> for Int<N> {
|
impl<'ctx, N: IntKind<'ctx>> ModelBase<'ctx> for Int<N> {
|
||||||
fn get_type_impl(&self, size_t: IntType<'ctx>, ctx: &'ctx Context) -> BasicTypeEnum<'ctx> {
|
fn llvm_type_impl(&self, size_t: IntType<'ctx>, ctx: &'ctx Context) -> BasicTypeEnum<'ctx> {
|
||||||
self.0.get_int_type(size_t, ctx).into()
|
self.0.get_int_type(size_t, ctx).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ impl<'ctx, N: IntKind<'ctx>> Int<N> {
|
|||||||
ctx: &'ctx Context,
|
ctx: &'ctx Context,
|
||||||
value: u64,
|
value: u64,
|
||||||
) -> Instance<'ctx, Self> {
|
) -> Instance<'ctx, Self> {
|
||||||
let value = self.get_type(generator, ctx).const_int(value, false);
|
let value = self.llvm_type(generator, ctx).const_int(value, false);
|
||||||
unsafe { self.believe_value(value) }
|
unsafe { self.believe_value(value) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ impl<'ctx, N: IntKind<'ctx>> Int<N> {
|
|||||||
generator: &mut G,
|
generator: &mut G,
|
||||||
ctx: &'ctx Context,
|
ctx: &'ctx Context,
|
||||||
) -> Instance<'ctx, Self> {
|
) -> Instance<'ctx, Self> {
|
||||||
let value = self.get_type(generator, ctx).const_zero();
|
let value = self.llvm_type(generator, ctx).const_zero();
|
||||||
unsafe { self.believe_value(value) }
|
unsafe { self.believe_value(value) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ impl<'ctx, N: IntKind<'ctx>> Int<N> {
|
|||||||
generator: &mut G,
|
generator: &mut G,
|
||||||
ctx: &'ctx Context,
|
ctx: &'ctx Context,
|
||||||
) -> Instance<'ctx, Self> {
|
) -> Instance<'ctx, Self> {
|
||||||
let value = self.get_type(generator, ctx).const_all_ones();
|
let value = self.llvm_type(generator, ctx).const_all_ones();
|
||||||
unsafe { self.believe_value(value) }
|
unsafe { self.believe_value(value) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,7 +150,7 @@ impl<'ctx, N: IntKind<'ctx>> Int<N> {
|
|||||||
);
|
);
|
||||||
let value = ctx
|
let value = ctx
|
||||||
.builder
|
.builder
|
||||||
.build_int_s_extend_or_bit_cast(value, self.get_type(generator, ctx.ctx), "")
|
.build_int_s_extend_or_bit_cast(value, self.llvm_type(generator, ctx.ctx), "")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
unsafe { self.believe_value(value) }
|
unsafe { self.believe_value(value) }
|
||||||
}
|
}
|
||||||
@ -166,7 +166,7 @@ impl<'ctx, N: IntKind<'ctx>> Int<N> {
|
|||||||
< self.0.get_int_type(generator.get_size_type(ctx.ctx), ctx.ctx).get_bit_width()
|
< self.0.get_int_type(generator.get_size_type(ctx.ctx), ctx.ctx).get_bit_width()
|
||||||
);
|
);
|
||||||
let value =
|
let value =
|
||||||
ctx.builder.build_int_s_extend(value, self.get_type(generator, ctx.ctx), "").unwrap();
|
ctx.builder.build_int_s_extend(value, self.llvm_type(generator, ctx.ctx), "").unwrap();
|
||||||
unsafe { self.believe_value(value) }
|
unsafe { self.believe_value(value) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,7 +182,7 @@ impl<'ctx, N: IntKind<'ctx>> Int<N> {
|
|||||||
);
|
);
|
||||||
let value = ctx
|
let value = ctx
|
||||||
.builder
|
.builder
|
||||||
.build_int_z_extend_or_bit_cast(value, self.get_type(generator, ctx.ctx), "")
|
.build_int_z_extend_or_bit_cast(value, self.llvm_type(generator, ctx.ctx), "")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
unsafe { self.believe_value(value) }
|
unsafe { self.believe_value(value) }
|
||||||
}
|
}
|
||||||
@ -198,7 +198,7 @@ impl<'ctx, N: IntKind<'ctx>> Int<N> {
|
|||||||
< self.0.get_int_type(generator.get_size_type(ctx.ctx), ctx.ctx).get_bit_width()
|
< self.0.get_int_type(generator.get_size_type(ctx.ctx), ctx.ctx).get_bit_width()
|
||||||
);
|
);
|
||||||
let value =
|
let value =
|
||||||
ctx.builder.build_int_z_extend(value, self.get_type(generator, ctx.ctx), "").unwrap();
|
ctx.builder.build_int_z_extend(value, self.llvm_type(generator, ctx.ctx), "").unwrap();
|
||||||
unsafe { self.believe_value(value) }
|
unsafe { self.believe_value(value) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,7 +214,7 @@ impl<'ctx, N: IntKind<'ctx>> Int<N> {
|
|||||||
);
|
);
|
||||||
let value = ctx
|
let value = ctx
|
||||||
.builder
|
.builder
|
||||||
.build_int_truncate_or_bit_cast(value, self.get_type(generator, ctx.ctx), "")
|
.build_int_truncate_or_bit_cast(value, self.llvm_type(generator, ctx.ctx), "")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
unsafe { self.believe_value(value) }
|
unsafe { self.believe_value(value) }
|
||||||
}
|
}
|
||||||
@ -230,7 +230,7 @@ impl<'ctx, N: IntKind<'ctx>> Int<N> {
|
|||||||
> self.0.get_int_type(generator.get_size_type(ctx.ctx), ctx.ctx).get_bit_width()
|
> self.0.get_int_type(generator.get_size_type(ctx.ctx), ctx.ctx).get_bit_width()
|
||||||
);
|
);
|
||||||
let value =
|
let value =
|
||||||
ctx.builder.build_int_truncate(value, self.get_type(generator, ctx.ctx), "").unwrap();
|
ctx.builder.build_int_truncate(value, self.llvm_type(generator, ctx.ctx), "").unwrap();
|
||||||
unsafe { self.believe_value(value) }
|
unsafe { self.believe_value(value) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,9 +28,9 @@ pub type OpaquePtr = Ptr<()>;
|
|||||||
//
|
//
|
||||||
// See https://thedan64.github.io/inkwell/inkwell/builder/struct.Builder.html#method.build_load.
|
// See https://thedan64.github.io/inkwell/inkwell/builder/struct.Builder.html#method.build_load.
|
||||||
impl<'ctx, Item: ModelBase<'ctx>> ModelBase<'ctx> for Ptr<Item> {
|
impl<'ctx, Item: ModelBase<'ctx>> ModelBase<'ctx> for Ptr<Item> {
|
||||||
fn get_type_impl(&self, size_t: IntType<'ctx>, ctx: &'ctx Context) -> BasicTypeEnum<'ctx> {
|
fn llvm_type_impl(&self, size_t: IntType<'ctx>, ctx: &'ctx Context) -> BasicTypeEnum<'ctx> {
|
||||||
// TODO: LLVM 15: ctx.ptr_type(AddressSpace::default())
|
// TODO: LLVM 15: ctx.ptr_type(AddressSpace::default())
|
||||||
let item = self.0.get_type_impl(size_t, ctx);
|
let item = self.0.llvm_type_impl(size_t, ctx);
|
||||||
item.ptr_type(AddressSpace::default()).into()
|
item.ptr_type(AddressSpace::default()).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ impl<'ctx, Item: Model<'ctx>> Ptr<Item> {
|
|||||||
ctx: &'ctx Context,
|
ctx: &'ctx Context,
|
||||||
) -> Instance<'ctx, Ptr<Item>> {
|
) -> Instance<'ctx, Ptr<Item>> {
|
||||||
// TODO: LLVM 15: Write in an impl where `Item` does not have to be `Model<'ctx>`.
|
// TODO: LLVM 15: Write in an impl where `Item` does not have to be `Model<'ctx>`.
|
||||||
let ptr = self.get_type(generator, ctx).const_null();
|
let ptr = self.llvm_type(generator, ctx).const_null();
|
||||||
unsafe { self.believe_value(ptr) }
|
unsafe { self.believe_value(ptr) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ impl<'ctx, Item: Model<'ctx>> Ptr<Item> {
|
|||||||
// ```
|
// ```
|
||||||
// return self.believe_value(ptr);
|
// return self.believe_value(ptr);
|
||||||
// ```
|
// ```
|
||||||
let t = self.get_type(generator, ctx.ctx);
|
let t = self.llvm_type(generator, ctx.ctx);
|
||||||
let ptr = ctx.builder.build_pointer_cast(ptr, t, "").unwrap();
|
let ptr = ctx.builder.build_pointer_cast(ptr, t, "").unwrap();
|
||||||
unsafe { self.believe_value(ptr) }
|
unsafe { self.believe_value(ptr) }
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,8 @@ pub trait StructKind<'ctx>: fmt::Debug + Clone + Copy {
|
|||||||
/// Get the LLVM [`StructType`] of this [`StructKind`].
|
/// Get the LLVM [`StructType`] of this [`StructKind`].
|
||||||
fn get_struct_type(&self, size_t: IntType<'ctx>, ctx: &'ctx Context) -> StructType<'ctx> {
|
fn get_struct_type(&self, size_t: IntType<'ctx>, ctx: &'ctx Context) -> StructType<'ctx> {
|
||||||
let entries = self.entries();
|
let entries = self.entries();
|
||||||
let entries = entries.into_iter().map(|t| t.model.get_type_impl(size_t, ctx)).collect_vec();
|
let entries =
|
||||||
|
entries.into_iter().map(|t| t.model.llvm_type_impl(size_t, ctx)).collect_vec();
|
||||||
ctx.struct_type(&entries, false)
|
ctx.struct_type(&entries, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -93,7 +94,7 @@ impl<'ctx, S: StructKind<'ctx>> Struct<S> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'ctx, S: StructKind<'ctx>> ModelBase<'ctx> for Struct<S> {
|
impl<'ctx, S: StructKind<'ctx>> ModelBase<'ctx> for Struct<S> {
|
||||||
fn get_type_impl(&self, size_t: IntType<'ctx>, ctx: &'ctx Context) -> BasicTypeEnum<'ctx> {
|
fn llvm_type_impl(&self, size_t: IntType<'ctx>, ctx: &'ctx Context) -> BasicTypeEnum<'ctx> {
|
||||||
self.0.get_struct_type(size_t, ctx).as_basic_type_enum()
|
self.0.get_struct_type(size_t, ctx).as_basic_type_enum()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user