Function init [src]

Prototype

pub fn init(builder: *Builder, options: struct { function: Function.Index, strip: bool, }) Allocator.Error!WipFunction

Parameters

builder: *Builderoptions: struct { function: Function.Index, strip: bool, }

Source

pub fn init(builder: *Builder, options: struct { function: Function.Index, strip: bool, }) Allocator.Error!WipFunction { var self: WipFunction = .{ .builder = builder, .function = options.function, .prev_debug_location = .no_location, .debug_location = .no_location, .cursor = undefined, .blocks = .{}, .instructions = .{}, .names = .{}, .strip = options.strip, .debug_locations = .{}, .debug_values = .{}, .extra = .{}, }; errdefer self.deinit(); const params_len = options.function.typeOf(self.builder).functionParameters(self.builder).len; try self.ensureUnusedExtraCapacity(params_len, NoExtra, 0); try self.instructions.ensureUnusedCapacity(self.builder.gpa, params_len); if (!self.strip) { try self.names.ensureUnusedCapacity(self.builder.gpa, params_len); } for (0..params_len) |param_index| { self.instructions.appendAssumeCapacity(.{ .tag = .arg, .data = @intCast(param_index) }); if (!self.strip) { self.names.appendAssumeCapacity(.empty); // TODO: param names } } return self; }