From e62509ae6782f0ed312664b0842eaa1630c35287 Mon Sep 17 00:00:00 2001 From: lyken Date: Sun, 25 Aug 2024 20:59:58 +0800 Subject: [PATCH] core: change call_nac3_range_len to take Int Instances --- nac3core/src/codegen/irrt/mod.rs | 10 +++------- nac3core/src/codegen/object/range.rs | 9 +-------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/nac3core/src/codegen/irrt/mod.rs b/nac3core/src/codegen/irrt/mod.rs index 7976ac78..f259419b 100644 --- a/nac3core/src/codegen/irrt/mod.rs +++ b/nac3core/src/codegen/irrt/mod.rs @@ -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>, + stop: Instance<'ctx, Int>, + step: Instance<'ctx, Int>, ) -> Instance<'ctx, Int> { - 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", diff --git a/nac3core/src/codegen/object/range.rs b/nac3core/src/codegen/object/range.rs index 127ad935..4eaf634c 100644 --- a/nac3core/src/codegen/object/range.rs +++ b/nac3core/src/codegen/object/range.rs @@ -91,14 +91,7 @@ impl<'ctx, N: IntKind<'ctx>> RustRange<'ctx, N> { ctx: &mut CodeGenContext<'ctx, '_>, ) -> Instance<'ctx, Int> { 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) } }