authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-11-02 16:14:57-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-11-03 20:05:32-07:00
log73b96ac114c74a2167fdc0ae0332a5087eab5c74
treea24656c5199d8573e346677a60c77262999b1f51
parent5f1f14519949ea8c9fc136e14b01b419fe59b751

accept a transformation index


1 files changed, 3 insertions(+), 12 deletions(-)

src/reduce.zig+3-12
...@@ -7,24 +7,16 @@ const usage =...@@ -7,24 +7,16 @@ const usage =
7 \\7 \\
8;8;
99
10const Transformation = enum {
11 none,
12};
13
14// Roadmap:10// Roadmap:
15// - add the main loop that checks for interestingness11// - add the main loop that checks for interestingness
16// - add transformations12// - add transformations
17// - gut function
18// - replace body with `@trap();`
19// - discard the parameters
20// - add thread pool13// - add thread pool
21// - add support for `@import` detection and other files14// - add support for `@import` detection and other files
15// - reduce flags sent to the compiler
2216
23pub fn main(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {17pub fn main(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
24 const file_path = args[2];18 const file_path = args[2];
25 const transformation = std.meta.stringToEnum(Transformation, args[3]);19 const transformation_index = try std.fmt.parseInt(u32, args[3], 0);
26
27 assert(transformation == .none);
2820
29 const source_code = try std.fs.cwd().readFileAllocOptions(21 const source_code = try std.fs.cwd().readFileAllocOptions(
30 arena,22 arena,
...@@ -46,8 +38,7 @@ pub fn main(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {...@@ -46,8 +38,7 @@ pub fn main(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
46 rendered.clearRetainingCapacity();38 rendered.clearRetainingCapacity();
4739
48 var gut_functions: std.AutoHashMapUnmanaged(u32, void) = .{};40 var gut_functions: std.AutoHashMapUnmanaged(u32, void) = .{};
49 try gut_functions.put(arena, 1, {});41 try gut_functions.put(arena, transformation_index, {});
50 try gut_functions.put(arena, 3, {});
5142
52 try tree.renderToArrayList(&rendered, .{43 try tree.renderToArrayList(&rendered, .{
53 .gut_functions = gut_functions,44 .gut_functions = gut_functions,