From 73b96ac114c74a2167fdc0ae0332a5087eab5c74 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 2 Nov 2023 16:14:57 -0700 Subject: [PATCH] accept a transformation index --- src/reduce.zig | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/reduce.zig b/src/reduce.zig index 2888f3f191f5cf5ff783b6e6d16d4c8135a877c5..e50817503abec71d7f16126f5f0e516ac3846ae4 100644 --- a/src/reduce.zig +++ b/src/reduce.zig @@ -7,24 +7,16 @@ const usage = \\ ; -const Transformation = enum { - none, -}; - // Roadmap: // - add the main loop that checks for interestingness // - add transformations -// - gut function -// - replace body with `@trap();` -// - discard the parameters // - add thread pool // - add support for `@import` detection and other files +// - reduce flags sent to the compiler pub fn main(gpa: Allocator, arena: Allocator, args: []const []const u8) !void { const file_path = args[2]; - const transformation = std.meta.stringToEnum(Transformation, args[3]); - - assert(transformation == .none); + const transformation_index = try std.fmt.parseInt(u32, args[3], 0); const source_code = try std.fs.cwd().readFileAllocOptions( arena, @@ -46,8 +38,7 @@ pub fn main(gpa: Allocator, arena: Allocator, args: []const []const u8) !void { rendered.clearRetainingCapacity(); var gut_functions: std.AutoHashMapUnmanaged(u32, void) = .{}; - try gut_functions.put(arena, 1, {}); - try gut_functions.put(arena, 3, {}); + try gut_functions.put(arena, transformation_index, {}); try tree.renderToArrayList(&rendered, .{ .gut_functions = gut_functions, -- 2.54.0