Commit 2d6d2a1d11
Changed files (2)
src
codegen
src/codegen/c.zig
@@ -596,9 +596,11 @@ pub const DeclGen = struct {
},
location,
),
- .int => |int| try writer.print("{x}", .{
- try dg.fmtIntLiteral(Type.usize, int.toValue(), .Other),
- }),
+ .int => |int| {
+ try writer.writeByte('(');
+ try dg.renderCType(writer, ptr_cty);
+ try writer.print("){x}", .{try dg.fmtIntLiteral(Type.usize, int.toValue(), .Other)});
+ },
.eu_payload, .opt_payload => |base| {
const ptr_base_ty = mod.intern_pool.typeOf(base).toType();
const base_ty = ptr_base_ty.childType(mod);
src/TypedValue.zig
@@ -345,12 +345,13 @@ pub fn print(
try writer.print("[{}]", .{elem.index});
},
.field => |field| {
- const container_ty = ip.typeOf(field.base).toType();
+ const ptr_container_ty = ip.typeOf(field.base).toType();
try print(.{
- .ty = container_ty,
+ .ty = ptr_container_ty,
.val = field.base.toValue(),
}, writer, level - 1, mod);
+ const container_ty = ptr_container_ty.childType(mod);
switch (container_ty.zigTypeTag(mod)) {
.Struct => {
if (container_ty.isTuple(mod)) {
@@ -375,6 +376,7 @@ pub fn print(
}
},
}
+ return;
},
.opt => |opt| switch (opt.val) {
.none => return writer.writeAll("null"),