| ... | @@ -1157,6 +1157,7 @@ pub const Value = extern union { | ... | @@ -1157,6 +1157,7 @@ pub const Value = extern union { |
| 1157 | ) Allocator.Error!Value { | 1157 | ) Allocator.Error!Value { |
| 1158 | switch (ty.zigTypeTag()) { | 1158 | switch (ty.zigTypeTag()) { |
| 1159 | .Int => { | 1159 | .Int => { |
| | 1160 | if (buffer.len == 0) return Value.zero; |
| 1160 | const int_info = ty.intInfo(target); | 1161 | const int_info = ty.intInfo(target); |
| 1161 | const endian = target.cpu.arch.endian(); | 1162 | const endian = target.cpu.arch.endian(); |
| 1162 | const Limb = std.math.big.Limb; | 1163 | const Limb = std.math.big.Limb; |
| ... | @@ -2185,6 +2186,33 @@ pub const Value = extern union { | ... | @@ -2185,6 +2186,33 @@ pub const Value = extern union { |
| 2185 | }; | 2186 | }; |
| 2186 | } | 2187 | } |
| 2187 | | 2188 | |
| | 2189 | pub fn canMutateComptimeVarState(val: Value) bool { |
| | 2190 | if (val.isComptimeMutablePtr()) return true; |
| | 2191 | switch (val.tag()) { |
| | 2192 | .repeated => return val.castTag(.repeated).?.data.canMutateComptimeVarState(), |
| | 2193 | .array => { |
| | 2194 | const elems = val.cast(Payload.Array).?.data; |
| | 2195 | for (elems) |elem| { |
| | 2196 | if (elem.canMutateComptimeVarState()) return true; |
| | 2197 | } |
| | 2198 | return false; |
| | 2199 | }, |
| | 2200 | .eu_payload => return val.castTag(.eu_payload).?.data.canMutateComptimeVarState(), |
| | 2201 | .eu_payload_ptr => return val.castTag(.eu_payload_ptr).?.data.canMutateComptimeVarState(), |
| | 2202 | .opt_payload => return val.castTag(.opt_payload).?.data.canMutateComptimeVarState(), |
| | 2203 | .opt_payload_ptr => return val.castTag(.opt_payload_ptr).?.data.canMutateComptimeVarState(), |
| | 2204 | .@"struct" => { |
| | 2205 | const fields = val.cast(Payload.Struct).?.data; |
| | 2206 | for (fields) |field| { |
| | 2207 | if (field.canMutateComptimeVarState()) return true; |
| | 2208 | } |
| | 2209 | return false; |
| | 2210 | }, |
| | 2211 | .@"union" => return val.cast(Payload.Union).?.data.val.canMutateComptimeVarState(), |
| | 2212 | else => return false, |
| | 2213 | } |
| | 2214 | } |
| | 2215 | |
| 2188 | /// Gets the decl referenced by this pointer. If the pointer does not point | 2216 | /// Gets the decl referenced by this pointer. If the pointer does not point |
| 2189 | /// to a decl, or if it points to some part of a decl (like field_ptr or element_ptr), | 2217 | /// to a decl, or if it points to some part of a decl (like field_ptr or element_ptr), |
| 2190 | /// this function returns null. | 2218 | /// this function returns null. |