Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

getModuleList

Returned pointer expires upon next call to getModuleList.

Compile.getModuleList
fn getModuleList(
    arena: Allocator,
    module_graph: *ModuleGraph,
    root_module: Configuration.Module.Index,
    conf: *const Configuration,
) !*ModuleList

File

lib/compiler/Maker/Step/Compile.zig:1192

Code

fn getModuleList(
    arena: Allocator,
    module_graph: *ModuleGraph,
    root_module: Configuration.Module.Index,
    conf: *const Configuration,
) !*ModuleList {
    const gop = try module_graph.getOrPutAdapted(arena, root_module, @as(ModuleListContext.Adapter, .{}));
    const modules = gop.key_ptr;

    if (gop.found_existing) return modules;
    modules.* = .empty;
    try modules.putNoClobber(arena, root_module, .root);

    var i: usize = 0;

    while (i < modules.entries.len) : (i += 1) {
        const dep_index = modules.keys()[i];
        const dep = dep_index.get(conf);
        const imports = dep.import_table.get(conf).imports;
        try modules.ensureUnusedCapacity(arena, imports.mal.len);
        for (imports.mal.items(.name), imports.mal.items(.module)) |import_name, other_mod|
            modules.putAssumeCapacity(other_mod, import_name);
    }

    return modules;
}