@@ -114,10 +114,10 @@ pub fn main() !void {
114114 interestingness_argv .appendAssumeCapacity (checker_path );
115115 interestingness_argv .appendSliceAssumeCapacity (argv );
116116
117- var rendered = std .array_list . Managed ( u8 ) .init (gpa );
117+ var rendered : std.Io.Writer.Allocating = .init (gpa );
118118 defer rendered .deinit ();
119119
120- var astgen_input = std .array_list . Managed ( u8 ) .init (gpa );
120+ var astgen_input : std.Io.Writer.Allocating = .init (gpa );
121121 defer astgen_input .deinit ();
122122
123123 var tree = try parse (gpa , root_source_file_path );
@@ -138,10 +138,10 @@ pub fn main() !void {
138138 }
139139 }
140140
141- var fixups : Ast.Fixups = .{};
141+ var fixups : Ast.Render. Fixups = .{};
142142 defer fixups .deinit (gpa );
143143
144- var more_fixups : Ast.Fixups = .{};
144+ var more_fixups : Ast.Render. Fixups = .{};
145145 defer more_fixups .deinit (gpa );
146146
147147 var rng = std .Random .DefaultPrng .init (seed );
@@ -188,15 +188,14 @@ pub fn main() !void {
188188 try transformationsToFixups (gpa , arena , root_source_file_path , this_set , & fixups );
189189
190190 rendered .clearRetainingCapacity ();
191- try tree .renderToArrayList ( & rendered , fixups );
191+ try tree .render ( gpa , & rendered . writer , fixups );
192192
193193 // The transformations we applied may have resulted in unused locals,
194194 // in which case we would like to add the respective discards.
195195 {
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 ];
200199 var astgen_tree = try Ast .parse (gpa , source_with_null , .zig );
201200 defer astgen_tree .deinit (gpa );
202201 if (astgen_tree .errors .len != 0 ) {
@@ -228,12 +227,12 @@ pub fn main() !void {
228227 }
229228 if (more_fixups .count () != 0 ) {
230229 rendered .clearRetainingCapacity ();
231- try astgen_tree .renderToArrayList ( & rendered , more_fixups );
230+ try astgen_tree .render ( gpa , & rendered . writer , more_fixups );
232231 }
233232 }
234233 }
235234
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 () });
237236 // std.debug.print("trying this code:\n{s}\n", .{rendered.items});
238237
239238 const interestingness = try runCheck (arena , interestingness_argv .items );
@@ -273,8 +272,8 @@ pub fn main() !void {
273272 // Revert the source back to not be transformed.
274273 fixups .clearRetainingCapacity ();
275274 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 () });
278277
279278 return std .process .cleanExit ();
280279 }
@@ -318,7 +317,7 @@ fn transformationsToFixups(
318317 arena : Allocator ,
319318 root_source_file_path : []const u8 ,
320319 transforms : []const Walk.Transformation ,
321- fixups : * Ast.Fixups ,
320+ fixups : * Ast.Render. Fixups ,
322321) ! void {
323322 fixups .clearRetainingCapacity ();
324323
@@ -359,7 +358,7 @@ fn transformationsToFixups(
359358 other_file_ast .deinit (gpa );
360359 }
361360
362- var inlined_fixups : Ast.Fixups = .{};
361+ var inlined_fixups : Ast.Render. Fixups = .{};
363362 defer inlined_fixups .deinit (gpa );
364363 if (std .fs .path .dirname (inline_imported_file .imported_string )) | dirname | {
365364 inlined_fixups .rebase_imported_paths = dirname ;
@@ -382,16 +381,16 @@ fn transformationsToFixups(
382381 }
383382 }
384383
385- var other_source = std .array_list . Managed ( u8 ) .init (gpa );
384+ var other_source : std.io.Writer.Allocating = .init (gpa );
386385 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 ("}" );
390389
391390 try fixups .replace_nodes_with_string .put (
392391 gpa ,
393392 inline_imported_file .builtin_call_node ,
394- try arena .dupe (u8 , other_source .items ),
393+ try arena .dupe (u8 , other_source .written () ),
395394 );
396395 },
397396 };
0 commit comments