DoxigAlpha

getParamBody

Function parameters

Parameters

#
fn_inst:Inst.Index

The data stored at byte offset 0 when ZIR is stored in a file.

Types

#
Header
The data stored at byte offset 0 when ZIR is stored in a file.
Inst
These are untyped instructions generated from an Abstract Syntax Tree.
DeclContents
`DeclContents` contains all "interesting" instructions found within a declaration by `findTrackable`.

Returns the requested data, as well as the new index which is at the start of the

Functions

#
extraData
Returns the requested data, as well as the new index which is at the start of the
nullTerminatedString
Given an index into `string_bytes` returns the null-terminated string found there.
findTrackable
Find all tracked ZIR instructions, recursively, within a `declaration` instruction.
findTrackableRoot
Like `findTrackable`, but only considers the `main_struct_inst` instruction.
assertTrackable
Asserts that a ZIR instruction is tracked across incremental updates, and

When the ZIR update tracking logic must be modified to consider new instructions,

Values

#
inst_tracking_version
When the ZIR update tracking logic must be modified to consider new instructions,

Source

Implementation

#
pub fn getParamBody(zir: Zir, fn_inst: Inst.Index) []const Zir.Inst.Index {
    const tags = zir.instructions.items(.tag);
    const datas = zir.instructions.items(.data);
    const inst_data = datas[@intFromEnum(fn_inst)].pl_node;

    const param_block_index = switch (tags[@intFromEnum(fn_inst)]) {
        .func, .func_inferred => blk: {
            const extra = zir.extraData(Inst.Func, inst_data.payload_index);
            break :blk extra.data.param_block;
        },
        .func_fancy => blk: {
            const extra = zir.extraData(Inst.FuncFancy, inst_data.payload_index);
            break :blk extra.data.param_block;
        },
        else => unreachable,
    };

    switch (tags[@intFromEnum(param_block_index)]) {
        .block, .block_comptime, .block_inline => {
            const param_block = zir.extraData(Inst.Block, datas[@intFromEnum(param_block_index)].pl_node.payload_index);
            return zir.bodySlice(param_block.end, param_block.data.body_len);
        },
        .declaration => {
            return zir.getDeclaration(param_block_index).value_body.?;
        },
        else => unreachable,
    }
}