| ... | @@ -207,29 +207,18 @@ pub fn generateSymbol( | ... | @@ -207,29 +207,18 @@ pub fn generateSymbol( |
| 207 | .bytes => { | 207 | .bytes => { |
| 208 | // TODO populate .debug_info for the array | 208 | // TODO populate .debug_info for the array |
| 209 | const payload = typed_value.val.castTag(.bytes).?; | 209 | const payload = typed_value.val.castTag(.bytes).?; |
| 210 | if (typed_value.ty.sentinel()) |sentinel| { | 210 | const len = @intCast(usize, typed_value.ty.arrayLenIncludingSentinel()); |
| 211 | try code.ensureUnusedCapacity(payload.data.len + 1); | 211 | // The bytes payload already includes the sentinel, if any |
| 212 | code.appendSliceAssumeCapacity(payload.data); | 212 | try code.ensureUnusedCapacity(len); |
| 213 | switch (try generateSymbol(bin_file, src_loc, .{ | 213 | code.appendSliceAssumeCapacity(payload.data[0..len]); |
| 214 | .ty = typed_value.ty.elemType(), | 214 | return Result{ .appended = {} }; |
| 215 | .val = sentinel, | | |
| 216 | }, code, debug_output, reloc_info)) { | | |
| 217 | .appended => return Result{ .appended = {} }, | | |
| 218 | .externally_managed => |slice| { | | |
| 219 | code.appendSliceAssumeCapacity(slice); | | |
| 220 | return Result{ .appended = {} }; | | |
| 221 | }, | | |
| 222 | .fail => |em| return Result{ .fail = em }, | | |
| 223 | } | | |
| 224 | } else { | | |
| 225 | return Result{ .externally_managed = payload.data }; | | |
| 226 | } | | |
| 227 | }, | 215 | }, |
| 228 | .aggregate => { | 216 | .aggregate => { |
| 229 | // TODO populate .debug_info for the array | 217 | // TODO populate .debug_info for the array |
| 230 | const elem_vals = typed_value.val.castTag(.aggregate).?.data; | 218 | const elem_vals = typed_value.val.castTag(.aggregate).?.data; |
| 231 | const elem_ty = typed_value.ty.elemType(); | 219 | const elem_ty = typed_value.ty.elemType(); |
| 232 | for (elem_vals) |elem_val| { | 220 | const len = @intCast(usize, typed_value.ty.arrayLenIncludingSentinel()); |
| | 221 | for (elem_vals[0..len]) |elem_val| { |
| 233 | switch (try generateSymbol(bin_file, src_loc, .{ | 222 | switch (try generateSymbol(bin_file, src_loc, .{ |
| 234 | .ty = elem_ty, | 223 | .ty = elem_ty, |
| 235 | .val = elem_val, | 224 | .val = elem_val, |