| ... | @@ -2149,15 +2149,18 @@ pub fn makeBool(x: bool) Value { | ... | @@ -2149,15 +2149,18 @@ pub fn makeBool(x: bool) Value { |
| 2149 | return if (x) .true else .false; | 2149 | return if (x) .true else .false; |
| 2150 | } | 2150 | } |
| 2151 | | 2151 | |
| 2152 | /// `parent_ptr` must be a single-pointer to some optional. | 2152 | /// `parent_ptr` must be a single-pointer or C pointer to some optional. |
| | 2153 | /// |
| 2153 | /// Returns a pointer to the payload of the optional. | 2154 | /// Returns a pointer to the payload of the optional. |
| | 2155 | /// |
| 2154 | /// May perform type resolution. | 2156 | /// May perform type resolution. |
| 2155 | pub fn ptrOptPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value { | 2157 | pub fn ptrOptPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value { |
| 2156 | const zcu = pt.zcu; | 2158 | const zcu = pt.zcu; |
| 2157 | const parent_ptr_ty = parent_ptr.typeOf(zcu); | 2159 | const parent_ptr_ty = parent_ptr.typeOf(zcu); |
| 2158 | const opt_ty = parent_ptr_ty.childType(zcu); | 2160 | const opt_ty = parent_ptr_ty.childType(zcu); |
| | 2161 | const ptr_size = parent_ptr_ty.ptrSize(zcu); |
| 2159 | | 2162 | |
| 2160 | assert(parent_ptr_ty.ptrSize(zcu) == .one); | 2163 | assert(ptr_size == .one or ptr_size == .c); |
| 2161 | assert(opt_ty.zigTypeTag(zcu) == .optional); | 2164 | assert(opt_ty.zigTypeTag(zcu) == .optional); |
| 2162 | | 2165 | |
| 2163 | const result_ty = try pt.ptrTypeSema(info: { | 2166 | const result_ty = try pt.ptrTypeSema(info: { |
| ... | @@ -2212,9 +2215,12 @@ pub fn ptrEuPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value { | ... | @@ -2212,9 +2215,12 @@ pub fn ptrEuPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value { |
| 2212 | } })); | 2215 | } })); |
| 2213 | } | 2216 | } |
| 2214 | | 2217 | |
| 2215 | /// `parent_ptr` must be a single-pointer to a struct, union, or slice. | 2218 | /// `parent_ptr` must be a single-pointer or c pointer to a struct, union, or slice. |
| | 2219 | /// |
| 2216 | /// Returns a pointer to the aggregate field at the specified index. | 2220 | /// Returns a pointer to the aggregate field at the specified index. |
| | 2221 | /// |
| 2217 | /// For slices, uses `slice_ptr_index` and `slice_len_index`. | 2222 | /// For slices, uses `slice_ptr_index` and `slice_len_index`. |
| | 2223 | /// |
| 2218 | /// May perform type resolution. | 2224 | /// May perform type resolution. |
| 2219 | pub fn ptrField(parent_ptr: Value, field_idx: u32, pt: Zcu.PerThread) !Value { | 2225 | pub fn ptrField(parent_ptr: Value, field_idx: u32, pt: Zcu.PerThread) !Value { |
| 2220 | const zcu = pt.zcu; | 2226 | const zcu = pt.zcu; |