From baf8ee2b3d72b3273fc2aa6692d343f66ffe1a9c Mon Sep 17 00:00:00 2001 From: lyken Date: Tue, 27 Aug 2024 17:28:27 +0800 Subject: [PATCH] Ptr::offset_const offset i64, can be negative --- nac3core/src/codegen/model/ptr.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nac3core/src/codegen/model/ptr.rs b/nac3core/src/codegen/model/ptr.rs index 1721c0a4..740696de 100644 --- a/nac3core/src/codegen/model/ptr.rs +++ b/nac3core/src/codegen/model/ptr.rs @@ -114,9 +114,9 @@ impl<'ctx, Item: Model<'ctx>> Instance<'ctx, Ptr> { pub fn offset_const( &self, ctx: &CodeGenContext<'ctx, '_>, - offset: u64, + offset: i64, ) -> Instance<'ctx, Ptr> { - let offset = ctx.ctx.i32_type().const_int(offset, false); + let offset = ctx.ctx.i32_type().const_int(offset as u64, true); self.offset(ctx, offset) } @@ -132,7 +132,7 @@ impl<'ctx, Item: Model<'ctx>> Instance<'ctx, Ptr> { pub fn set_index_const( &self, ctx: &CodeGenContext<'ctx, '_>, - index: u64, + index: i64, value: Instance<'ctx, Item>, ) { self.offset_const(ctx, index).store(ctx, value); @@ -151,7 +151,7 @@ impl<'ctx, Item: Model<'ctx>> Instance<'ctx, Ptr> { &self, generator: &mut G, ctx: &CodeGenContext<'ctx, '_>, - index: u64, + index: i64, ) -> Instance<'ctx, Item> { self.offset_const(ctx, index).load(generator, ctx) }