| ... | ... | @@ -114,10 +114,10 @@ pub fn main() !void { |
| 114 | 114 | interestingness_argv.appendAssumeCapacity(checker_path); |
| 115 | 115 | interestingness_argv.appendSliceAssumeCapacity(argv); |
| 116 | 116 | |
| 117 | | var rendered = std.array_list.Managed(u8).init(gpa); |
| 117 | var rendered: std.Io.Writer.Allocating = .init(gpa); |
| 118 | 118 | defer rendered.deinit(); |
| 119 | 119 | |
| 120 | | var astgen_input = std.array_list.Managed(u8).init(gpa); |
| 120 | var astgen_input: std.Io.Writer.Allocating = .init(gpa); |
| 121 | 121 | defer astgen_input.deinit(); |
| 122 | 122 | |
| 123 | 123 | var tree = try parse(gpa, root_source_file_path); |
| ... | ... | @@ -138,10 +138,10 @@ pub fn main() !void { |
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | | var fixups: Ast.Fixups = .{}; |
| 141 | var fixups: Ast.Render.Fixups = .{}; |
| 142 | 142 | defer fixups.deinit(gpa); |
| 143 | 143 | |
| 144 | | var more_fixups: Ast.Fixups = .{}; |
| 144 | var more_fixups: Ast.Render.Fixups = .{}; |
| 145 | 145 | defer more_fixups.deinit(gpa); |
| 146 | 146 | |
| 147 | 147 | var rng = std.Random.DefaultPrng.init(seed); |
| ... | ... | @@ -188,15 +188,14 @@ pub fn main() !void { |
| 188 | 188 | try transformationsToFixups(gpa, arena, root_source_file_path, this_set, &fixups); |
| 189 | 189 | |
| 190 | 190 | rendered.clearRetainingCapacity(); |
| 191 | | try tree.renderToArrayList(&rendered, fixups); |
| 191 | try tree.render(gpa, &rendered.writer, fixups); |
| 192 | 192 | |
| 193 | 193 | // The transformations we applied may have resulted in unused locals, |
| 194 | 194 | // in which case we would like to add the respective discards. |
| 195 | 195 | { |
| 196 | | try astgen_input.resize(rendered.items.len); |
| 197 | | @memcpy(astgen_input.items, rendered.items); |
| 198 | | try astgen_input.append(0); |
| 199 | | const source_with_null = astgen_input.items[0 .. astgen_input.items.len - 1 :0]; |
| 196 | try astgen_input.writer.writeAll(rendered.written()); |
| 197 | try astgen_input.writer.writeByte(0); |
| 198 | const source_with_null = astgen_input.written()[0..(astgen_input.written().len - 1) :0]; |
| 200 | 199 | var astgen_tree = try Ast.parse(gpa, source_with_null, .zig); |
| 201 | 200 | defer astgen_tree.deinit(gpa); |
| 202 | 201 | if (astgen_tree.errors.len != 0) { |
| ... | ... | @@ -228,12 +227,12 @@ pub fn main() !void { |
| 228 | 227 | } |
| 229 | 228 | if (more_fixups.count() != 0) { |
| 230 | 229 | rendered.clearRetainingCapacity(); |
| 231 | | try astgen_tree.renderToArrayList(&rendered, more_fixups); |
| 230 | try astgen_tree.render(gpa, &rendered.writer, more_fixups); |
| 232 | 231 | } |
| 233 | 232 | } |
| 234 | 233 | } |
| 235 | 234 | |
| 236 | | try std.fs.cwd().writeFile(.{ .sub_path = root_source_file_path, .data = rendered.items }); |
| 235 | try std.fs.cwd().writeFile(.{ .sub_path = root_source_file_path, .data = rendered.written() }); |
| 237 | 236 | // std.debug.print("trying this code:\n{s}\n", .{rendered.items}); |
| 238 | 237 | |
| 239 | 238 | const interestingness = try runCheck(arena, interestingness_argv.items); |
| ... | ... | @@ -273,8 +272,8 @@ pub fn main() !void { |
| 273 | 272 | // Revert the source back to not be transformed. |
| 274 | 273 | fixups.clearRetainingCapacity(); |
| 275 | 274 | rendered.clearRetainingCapacity(); |
| 276 | | try tree.renderToArrayList(&rendered, fixups); |
| 277 | | try std.fs.cwd().writeFile(.{ .sub_path = root_source_file_path, .data = rendered.items }); |
| 275 | try tree.render(gpa, &rendered.writer, fixups); |
| 276 | try std.fs.cwd().writeFile(.{ .sub_path = root_source_file_path, .data = rendered.written() }); |
| 278 | 277 | |
| 279 | 278 | return std.process.cleanExit(); |
| 280 | 279 | } |
| ... | ... | @@ -318,7 +317,7 @@ fn transformationsToFixups( |
| 318 | 317 | arena: Allocator, |
| 319 | 318 | root_source_file_path: []const u8, |
| 320 | 319 | transforms: []const Walk.Transformation, |
| 321 | | fixups: *Ast.Fixups, |
| 320 | fixups: *Ast.Render.Fixups, |
| 322 | 321 | ) !void { |
| 323 | 322 | fixups.clearRetainingCapacity(); |
| 324 | 323 | |
| ... | ... | @@ -359,7 +358,7 @@ fn transformationsToFixups( |
| 359 | 358 | other_file_ast.deinit(gpa); |
| 360 | 359 | } |
| 361 | 360 | |
| 362 | | var inlined_fixups: Ast.Fixups = .{}; |
| 361 | var inlined_fixups: Ast.Render.Fixups = .{}; |
| 363 | 362 | defer inlined_fixups.deinit(gpa); |
| 364 | 363 | if (std.fs.path.dirname(inline_imported_file.imported_string)) |dirname| { |
| 365 | 364 | inlined_fixups.rebase_imported_paths = dirname; |
| ... | ... | @@ -382,16 +381,16 @@ fn transformationsToFixups( |
| 382 | 381 | } |
| 383 | 382 | } |
| 384 | 383 | |
| 385 | | var other_source = std.array_list.Managed(u8).init(gpa); |
| 384 | var other_source: std.io.Writer.Allocating = .init(gpa); |
| 386 | 385 | defer other_source.deinit(); |
| 387 | | try other_source.appendSlice("struct {\n"); |
| 388 | | try other_file_ast.renderToArrayList(&other_source, inlined_fixups); |
| 389 | | try other_source.appendSlice("}"); |
| 386 | try other_source.writer.writeAll("struct {\n"); |
| 387 | try other_file_ast.render(gpa, &other_source.writer, inlined_fixups); |
| 388 | try other_source.writer.writeAll("}"); |
| 390 | 389 | |
| 391 | 390 | try fixups.replace_nodes_with_string.put( |
| 392 | 391 | gpa, |
| 393 | 392 | inline_imported_file.builtin_call_node, |
| 394 | | try arena.dupe(u8, other_source.items), |
| 393 | try arena.dupe(u8, other_source.written()), |
| 395 | 394 | ); |
| 396 | 395 | }, |
| 397 | 396 | }; |