refactor(B8.3): move lambdas + captures to lower/closure.zig

Verbatim relocation of the 5-method closure cluster (lowerLambda,
bare-fn trampoline, closure-to-bare-fn adapter, capture collection, env
sizing) into src/ir/lower/closure.zig. 5 aliases on Lowering keep all
call sites unchanged. Method pub-flip: typeAlignBytes.

Resolves the B7.1 flag: CaptureInfo relocates from lower/call.zig to
lower/closure.zig (its domain home, next to collectCaptures); the
Lowering type alias is repointed so external references are unchanged.

Gate: zig build OK; zig build test 426/426; run_examples 541/0; zero
expected/ snapshot churn.
This commit is contained in:
agra
2026-06-10 14:43:04 +03:00
parent 35e35adb0a
commit 89b3789973
3 changed files with 743 additions and 688 deletions

View File

@@ -43,7 +43,6 @@ const Function = inst_mod.Function;
const Module = mod_mod.Module;
const Builder = mod_mod.Builder;
const lower = @import("../lower.zig");
const Lowering = lower.Lowering;
const Scope = lower.Scope;
@@ -1206,13 +1205,6 @@ pub fn resolveBuiltin(name: []const u8) ?inst_mod.BuiltinId {
// ── Lambda/closure ────────────────────────────────────────────
pub const CaptureInfo = struct {
name: []const u8,
ty: TypeId,
ref: Ref, // alloca or value ref in the parent scope
is_alloca: bool,
};
/// Build `tp.name -> TypeId` bindings for a generic call.
/// `args_ast` must be parallel to `fd.params`; for dot-calls the caller
/// prepends the receiver's AST node so positions align with `fd.params[0] = self`.