1
0
forked from M-Labs/nac3

core: change call_nac3_range_len to take Int Instances

This commit is contained in:
lyken 2024-08-25 20:59:58 +08:00
parent 58be4a8b09
commit e62509ae67
No known key found for this signature in database
GPG Key ID: 3BD5FC6AC8325DD8
2 changed files with 4 additions and 15 deletions

View File

@ -613,14 +613,10 @@ pub fn call_nac3_range_len<'ctx, G: CodeGenerator + ?Sized, N: IntKind<'ctx>>(
generator: &mut G,
ctx: &mut CodeGenContext<'ctx, '_>,
int_kind: N,
start: IntValue<'ctx>,
stop: IntValue<'ctx>,
step: IntValue<'ctx>,
start: Instance<'ctx, Int<N>>,
stop: Instance<'ctx, Int<N>>,
step: Instance<'ctx, Int<N>>,
) -> Instance<'ctx, Int<N>> {
let start = Int(int_kind).check_value(generator, ctx.ctx, start).unwrap();
let stop = Int(int_kind).check_value(generator, ctx.ctx, stop).unwrap();
let step = Int(int_kind).check_value(generator, ctx.ctx, step).unwrap();
let bit_width = int_kind.get_int_type(generator, ctx.ctx).get_bit_width();
let func_name = match bit_width {
32 => "__nac3_range_len_i32",

View File

@ -91,14 +91,7 @@ impl<'ctx, N: IntKind<'ctx>> RustRange<'ctx, N> {
ctx: &mut CodeGenContext<'ctx, '_>,
) -> Instance<'ctx, Int<N>> {
let int_kind = self.start.model.0;
call_nac3_range_len(
generator,
ctx,
int_kind,
self.start.value,
self.stop.value,
self.step.value,
)
call_nac3_range_len(generator, ctx, int_kind, self.start, self.stop, self.step)
}
}