forked from M-Labs/nac3
1
0
Fork 0

FloatKind::{get_float_type -> float_type}

This commit is contained in:
lyken 2024-08-28 12:53:55 +08:00
parent cc5950e88c
commit 5f95d1530a
No known key found for this signature in database
GPG Key ID: 3BD5FC6AC8325DD8
1 changed files with 6 additions and 6 deletions

View File

@ -9,7 +9,7 @@ use inkwell::{
use super::*;
pub trait FloatKind<'ctx>: fmt::Debug + Clone + Copy {
fn get_float_type(&self, ctx: &'ctx Context) -> FloatType<'ctx>;
fn float_type(&self, ctx: &'ctx Context) -> FloatType<'ctx>;
}
#[derive(Debug, Clone, Copy, Default)]
@ -18,13 +18,13 @@ pub struct Float32;
pub struct Float64;
impl<'ctx> FloatKind<'ctx> for Float32 {
fn get_float_type(&self, ctx: &'ctx Context) -> FloatType<'ctx> {
fn float_type(&self, ctx: &'ctx Context) -> FloatType<'ctx> {
ctx.f32_type()
}
}
impl<'ctx> FloatKind<'ctx> for Float64 {
fn get_float_type(&self, ctx: &'ctx Context) -> FloatType<'ctx> {
fn float_type(&self, ctx: &'ctx Context) -> FloatType<'ctx> {
ctx.f64_type()
}
}
@ -33,7 +33,7 @@ impl<'ctx> FloatKind<'ctx> for Float64 {
pub struct AnyFloat<'ctx>(FloatType<'ctx>);
impl<'ctx> FloatKind<'ctx> for AnyFloat<'ctx> {
fn get_float_type(&self, _ctx: &'ctx Context) -> FloatType<'ctx> {
fn float_type(&self, _ctx: &'ctx Context) -> FloatType<'ctx> {
self.0
}
}
@ -52,7 +52,7 @@ impl<'ctx, N: FloatKind<'ctx>> Float<'ctx, N> {
impl<'ctx, N: FloatKind<'ctx>> ModelBase<'ctx> for Float<'ctx, N> {
fn llvm_type_impl(&self, _size_t: IntType<'ctx>, ctx: &'ctx Context) -> BasicTypeEnum<'ctx> {
self.kind.get_float_type(ctx).into()
self.kind.float_type(ctx).into()
}
fn check_type_impl(
@ -65,7 +65,7 @@ impl<'ctx, N: FloatKind<'ctx>> ModelBase<'ctx> for Float<'ctx, N> {
return Err(ModelError(format!("Expecting FloatType, but got {ty:?}")));
};
let expected_ty = self.kind.get_float_type(ctx);
let expected_ty = self.kind.float_type(ctx);
if ty != expected_ty {
return Err(ModelError(format!("Expecting {expected_ty:?}, but got {ty:?}")));
}