diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Compilation.zig | 1 | ||||
| -rw-r--r-- | src/aro_translate_c.zig | 7 | ||||
| -rw-r--r-- | src/main.zig | 1 |
3 files changed, 7 insertions, 2 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig index 3eec2a6e94..5bfabfdcfc 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -3980,6 +3980,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult { man.hash.add(@as(u16, 0xb945)); // Random number to distinguish translate-c from compiling C objects man.hash.addBytes(c_src); + man.hash.add(comp.c_frontend); // If the previous invocation resulted in clang errors, we will see a hit // here with 0 files in the manifest, in which case it is actually a miss. diff --git a/src/aro_translate_c.zig b/src/aro_translate_c.zig index 5686c848bf..eaa99694de 100644 --- a/src/aro_translate_c.zig +++ b/src/aro_translate_c.zig @@ -308,7 +308,6 @@ fn transVarDecl(_: *Context, _: NodeIndex, _: ?usize) Error!void { fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: NodeIndex, field_nodes: []const NodeIndex) Error!void { const node_types = c.tree.nodes.items(.ty); const ty = node_types[@intFromEnum(enum_decl)]; - const node_data = c.tree.nodes.items(.data); if (c.decl_table.get(@intFromPtr(ty.data.@"enum"))) |_| return; // Avoid processing this decl twice const toplevel = scope.id == .root; @@ -342,11 +341,15 @@ fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: NodeIndex, field_nodes: else => |e| return e, }; + const val = c.tree.value_map.get(field_node).?; + const str = try std.fmt.allocPrint(c.arena, "{d}", .{val.data.int}); + const int = try ZigTag.integer_literal.create(c.arena, str); + const enum_const_def = try ZigTag.enum_constant.create(c.arena, .{ .name = enum_val_name, .is_public = toplevel, .type = enum_const_type_node, - .value = transExpr(c, node_data[@intFromEnum(field_node)].decl.node, .used) catch @panic("TODO"), + .value = int, }); if (toplevel) try addTopLevelDecl(c, enum_val_name, enum_const_def) diff --git a/src/main.zig b/src/main.zig index 6dd4fb0725..4c44076cd4 100644 --- a/src/main.zig +++ b/src/main.zig @@ -4265,6 +4265,7 @@ fn cmdTranslateC(comp: *Compilation, arena: Allocator, fancy_output: ?*Compilati defer man.deinit(); man.hash.add(@as(u16, 0xb945)); // Random number to distinguish translate-c from compiling C objects + man.hash.add(comp.c_frontend); Compilation.cache_helpers.hashCSource(&man, c_source_file) catch |err| { fatal("unable to process '{s}': {s}", .{ c_source_file.src_path, @errorName(err) }); }; |
