| author | |
| committer | |
| log | 96f9e20152001c7611b2c40f36ef9a522165d9d0 |
| tree | 696de46e18d697cd772ccf9c36b7a967ca50749e |
| parent | e765495b114af3417aea4cffcd7c37f400aab3fe |
4 files changed, 10 insertions(+), 5 deletions(-)
src/Compilation.zig+1| ... | ... | @@ -3936,6 +3936,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult { |
| 3936 | 3936 | |
| 3937 | 3937 | man.hash.add(@as(u16, 0xb945)); // Random number to distinguish translate-c from compiling C objects |
| 3938 | 3938 | man.hash.addBytes(c_src); |
| 3939 | man.hash.add(comp.c_frontend); | |
| 3939 | 3940 | |
| 3940 | 3941 | // If the previous invocation resulted in clang errors, we will see a hit |
| 3941 | 3942 | // here with 0 files in the manifest, in which case it is actually a miss. |
src/aro_translate_c.zig+5-2| ... | ... | @@ -308,7 +308,6 @@ fn transVarDecl(_: *Context, _: NodeIndex, _: ?usize) Error!void { |
| 308 | 308 | fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: NodeIndex, field_nodes: []const NodeIndex) Error!void { |
| 309 | 309 | const node_types = c.tree.nodes.items(.ty); |
| 310 | 310 | const ty = node_types[@intFromEnum(enum_decl)]; |
| 311 | const node_data = c.tree.nodes.items(.data); | |
| 312 | 311 | if (c.decl_table.get(@intFromPtr(ty.data.@"enum"))) |_| |
| 313 | 312 | return; // Avoid processing this decl twice |
| 314 | 313 | const toplevel = scope.id == .root; |
| ... | ... | @@ -342,11 +341,15 @@ fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: NodeIndex, field_nodes: |
| 342 | 341 | else => |e| return e, |
| 343 | 342 | }; |
| 344 | 343 | |
| 344 | const val = c.tree.value_map.get(field_node).?; | |
| 345 | const str = try std.fmt.allocPrint(c.arena, "{d}", .{val.data.int}); | |
| 346 | const int = try ZigTag.integer_literal.create(c.arena, str); | |
| 347 | ||
| 345 | 348 | const enum_const_def = try ZigTag.enum_constant.create(c.arena, .{ |
| 346 | 349 | .name = enum_val_name, |
| 347 | 350 | .is_public = toplevel, |
| 348 | 351 | .type = enum_const_type_node, |
| 349 | .value = transExpr(c, node_data[@intFromEnum(field_node)].decl.node, .used) catch @panic("TODO"), | |
| 352 | .value = int, | |
| 350 | 353 | }); |
| 351 | 354 | if (toplevel) |
| 352 | 355 | try addTopLevelDecl(c, enum_val_name, enum_const_def) |
src/main.zig+1| ... | ... | @@ -4238,6 +4238,7 @@ fn cmdTranslateC(comp: *Compilation, arena: Allocator, fancy_output: ?*Compilati |
| 4238 | 4238 | defer man.deinit(); |
| 4239 | 4239 | |
| 4240 | 4240 | man.hash.add(@as(u16, 0xb945)); // Random number to distinguish translate-c from compiling C objects |
| 4241 | man.hash.add(comp.c_frontend); | |
| 4241 | 4242 | Compilation.cache_helpers.hashCSource(&man, c_source_file) catch |err| { |
| 4242 | 4243 | fatal("unable to process '{s}': {s}", .{ c_source_file.src_path, @errorName(err) }); |
| 4243 | 4244 | }; |
test/src/Cases.zig+3-3| ... | ... | @@ -681,11 +681,11 @@ pub fn lowerToBuildSteps( |
| 681 | 681 | } |
| 682 | 682 | } |
| 683 | 683 | |
| 684 | for (self.translate.items) |*case| switch (case.kind) { | |
| 684 | for (self.translate.items) |case| switch (case.kind) { | |
| 685 | 685 | .run => |output| { |
| 686 | 686 | const annotated_case_name = b.fmt("run-translated-c {s}", .{case.name}); |
| 687 | 687 | if (opt_test_filter) |filter| { |
| 688 | if (std.mem.indexOf(u8, annotated_case_name, filter) == null) return; | |
| 688 | if (std.mem.indexOf(u8, annotated_case_name, filter) == null) continue; | |
| 689 | 689 | } |
| 690 | 690 | if (!std.process.can_spawn) { |
| 691 | 691 | std.debug.print("Unable to spawn child processes on {s}, skipping test.\n", .{@tagName(builtin.os.tag)}); |
| ... | ... | @@ -723,7 +723,7 @@ pub fn lowerToBuildSteps( |
| 723 | 723 | .translate => |output| { |
| 724 | 724 | const annotated_case_name = b.fmt("zig translate-c {s}", .{case.name}); |
| 725 | 725 | if (opt_test_filter) |filter| { |
| 726 | if (std.mem.indexOf(u8, annotated_case_name, filter) == null) return; | |
| 726 | if (std.mem.indexOf(u8, annotated_case_name, filter) == null) continue; | |
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | const write_src = b.addWriteFiles(); |