@@ -58,6 +58,8 @@ pub enum Value {
5858 FunctionReference ( String ) , // 函数引用
5959 EnumValue ( EnumInstance ) , // 新增:枚举实例
6060 Pointer ( PointerInstance ) , // 新增:指针实例
61+ ArrayPointer ( ArrayPointerInstance ) , // 新增:数组指针实例
62+ PointerArray ( PointerArrayInstance ) , // 新增:指针数组实例
6163 FunctionPointer ( FunctionPointerInstance ) , // 新增:函数指针实例
6264 LambdaFunctionPointer ( LambdaFunctionPointerInstance ) , // 新增:Lambda函数指针实例
6365 None , // 表示空值或未定义的值
@@ -93,6 +95,24 @@ pub struct PointerInstance {
9395 pub tag_id : Option < u64 > , // 指针标记ID,用于安全检查
9496}
9597
98+ // 数组指针实例 (*[size]Type)
99+ #[ derive( Debug , Clone ) ]
100+ pub struct ArrayPointerInstance {
101+ pub address : usize , // 数组的内存地址
102+ pub element_type : PointerType , // 数组元素类型
103+ pub array_size : usize , // 数组大小
104+ pub is_null : bool , // 是否为空指针
105+ pub tag_id : Option < u64 > , // 指针标记ID
106+ }
107+
108+ // 指针数组实例 ([size]*Type)
109+ #[ derive( Debug , Clone ) ]
110+ pub struct PointerArrayInstance {
111+ pub pointers : Vec < PointerInstance > , // 指针数组
112+ pub element_type : PointerType , // 指针指向的类型
113+ pub array_size : usize , // 数组大小
114+ }
115+
96116// 指针类型信息
97117#[ derive( Debug , Clone ) ]
98118pub enum PointerType {
@@ -105,6 +125,7 @@ pub enum PointerType {
105125 Class ( String ) ,
106126 Function ( Vec < crate :: ast:: Type > , Box < crate :: ast:: Type > ) , // 函数指针
107127 Pointer ( Box < PointerType > ) , // 多级指针
128+ Array ( Box < PointerType > , usize ) , // 数组类型(元素类型,大小)
108129}
109130
110131// 函数指针实例
@@ -181,6 +202,16 @@ impl Value {
181202 format ! ( "{}0x{:x}" , stars, ptr. address)
182203 }
183204 } ,
205+ Value :: ArrayPointer ( array_ptr) => {
206+ if array_ptr. is_null {
207+ "null" . to_string ( )
208+ } else {
209+ format ! ( "*[{}]@0x{:x}" , array_ptr. array_size, array_ptr. address)
210+ }
211+ } ,
212+ Value :: PointerArray ( ptr_array) => {
213+ format ! ( "[{}]*ptr" , ptr_array. array_size)
214+ } ,
184215 Value :: FunctionPointer ( func_ptr) => {
185216 if func_ptr. is_null {
186217 "null" . to_string ( )
@@ -292,6 +323,16 @@ impl fmt::Display for Value {
292323 write ! ( f, "*fn(lambda)" )
293324 }
294325 } ,
326+ Value :: ArrayPointer ( array_ptr) => {
327+ if array_ptr. is_null {
328+ write ! ( f, "null" )
329+ } else {
330+ write ! ( f, "*[{}]@0x{:x}" , array_ptr. array_size, array_ptr. address)
331+ }
332+ } ,
333+ Value :: PointerArray ( ptr_array) => {
334+ write ! ( f, "[{}]*ptr" , ptr_array. array_size)
335+ } ,
295336 Value :: None => write ! ( f, "null" ) ,
296337 }
297338 }
0 commit comments