struct Fixups [src]
Alias for std.zig.render.Fixups
Fields
unused_var_decls: std.AutoHashMapUnmanaged(Ast.TokenIndex, void) = .emptyThe key is the mut token (var/const) of the variable declaration
that should have a _ = foo; inserted afterwards.
gut_functions: std.AutoHashMapUnmanaged(Ast.Node.Index, void) = .emptyThe functions in this unordered set of AST fn decl nodes will render
with a function body of @trap() instead, with all parameters
discarded.
omit_nodes: std.AutoHashMapUnmanaged(Ast.Node.Index, void) = .emptyThese global declarations will be omitted.
replace_nodes_with_string: std.AutoHashMapUnmanaged(Ast.Node.Index, []const u8) = .emptyThese expressions will be replaced with the string value.
append_string_after_node: std.AutoHashMapUnmanaged(Ast.Node.Index, []const u8) = .emptyThe string value will be inserted directly after the node.
replace_nodes_with_node: std.AutoHashMapUnmanaged(Ast.Node.Index, Ast.Node.Index) = .emptyThese nodes will be replaced with a different node.
rename_identifiers: std.StringArrayHashMapUnmanaged([]const u8) = .emptyChange all identifier names matching the key to be value instead.
rebase_imported_paths: ?[]const u8 = nullAll @import builtin calls which refer to a file path will be prefixed
with this path.
Members
- clearRetainingCapacity (Function)
- count (Function)
- deinit (Function)
Source
pub const Fixups = struct {
/// The key is the mut token (`var`/`const`) of the variable declaration
/// that should have a `_ = foo;` inserted afterwards.
unused_var_decls: std.AutoHashMapUnmanaged(Ast.TokenIndex, void) = .empty,
/// The functions in this unordered set of AST fn decl nodes will render
/// with a function body of `@trap()` instead, with all parameters
/// discarded.
gut_functions: std.AutoHashMapUnmanaged(Ast.Node.Index, void) = .empty,
/// These global declarations will be omitted.
omit_nodes: std.AutoHashMapUnmanaged(Ast.Node.Index, void) = .empty,
/// These expressions will be replaced with the string value.
replace_nodes_with_string: std.AutoHashMapUnmanaged(Ast.Node.Index, []const u8) = .empty,
/// The string value will be inserted directly after the node.
append_string_after_node: std.AutoHashMapUnmanaged(Ast.Node.Index, []const u8) = .empty,
/// These nodes will be replaced with a different node.
replace_nodes_with_node: std.AutoHashMapUnmanaged(Ast.Node.Index, Ast.Node.Index) = .empty,
/// Change all identifier names matching the key to be value instead.
rename_identifiers: std.StringArrayHashMapUnmanaged([]const u8) = .empty,
/// All `@import` builtin calls which refer to a file path will be prefixed
/// with this path.
rebase_imported_paths: ?[]const u8 = null,
pub fn count(f: Fixups) usize {
return f.unused_var_decls.count() +
f.gut_functions.count() +
f.omit_nodes.count() +
f.replace_nodes_with_string.count() +
f.append_string_after_node.count() +
f.replace_nodes_with_node.count() +
f.rename_identifiers.count() +
@intFromBool(f.rebase_imported_paths != null);
}
pub fn clearRetainingCapacity(f: *Fixups) void {
f.unused_var_decls.clearRetainingCapacity();
f.gut_functions.clearRetainingCapacity();
f.omit_nodes.clearRetainingCapacity();
f.replace_nodes_with_string.clearRetainingCapacity();
f.append_string_after_node.clearRetainingCapacity();
f.replace_nodes_with_node.clearRetainingCapacity();
f.rename_identifiers.clearRetainingCapacity();
f.rebase_imported_paths = null;
}
pub fn deinit(f: *Fixups, gpa: Allocator) void {
f.unused_var_decls.deinit(gpa);
f.gut_functions.deinit(gpa);
f.omit_nodes.deinit(gpa);
f.replace_nodes_with_string.deinit(gpa);
f.append_string_after_node.deinit(gpa);
f.replace_nodes_with_node.deinit(gpa);
f.rename_identifiers.deinit(gpa);
f.* = undefined;
}
}