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 =
77 \\
88;
99
10const Transformation = enum {
11 none,
12};
13
1410// Roadmap:
1511// - add the main loop that checks for interestingness
1612// - add transformations
17// - gut function
18// - replace body with `@trap();`
19// - discard the parameters
2013// - add thread pool
2114// - add support for `@import` detection and other files
15// - reduce flags sent to the compiler
2216
2317pub fn main(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
2418 const file_path = args[2];
25 const transformation = std.meta.stringToEnum(Transformation, args[3]);
26
27 assert(transformation == .none);
19 const transformation_index = try std.fmt.parseInt(u32, args[3], 0);
2820
2921 const source_code = try std.fs.cwd().readFileAllocOptions(
3022 arena,
......@@ -46,8 +38,7 @@ pub fn main(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
4638 rendered.clearRetainingCapacity();
4739
4840 var gut_functions: std.AutoHashMapUnmanaged(u32, void) = .{};
49 try gut_functions.put(arena, 1, {});
50 try gut_functions.put(arena, 3, {});
41 try gut_functions.put(arena, transformation_index, {});
5142
5243 try tree.renderToArrayList(&rendered, .{
5344 .gut_functions = gut_functions,