✓
Passing This code compiles and runs correctly.
Code
// PINS: a comptime transform at the ROOT of a store lifecycle arm body emits
// its expansion.
//
// The arm body is walked depth-first, so a transform sitting at its root fires
// BEFORE the store declaration transforms, and leaves its expansion on the
// invocation (`Invocation.inline_body`). The store then rebuilds that body as
// the root of a synthesized flow — and a flow root is emitted from
// `Flow.inline_body`, while only a nested continuation is emitted from the
// invocation's slot. The two slots are the shape this test guards: carry the
// expansion across the rebuild, or the emitter falls through to a plain handler
// call.
//
// `! discharge` is the IN-FILE CONTROL and pins the other position: its
// `print.ln` sits one link down a chain, so it is emitted from the nested slot.
// Both arms print, and each reaches the emitter by a different route.
//
// `std/io:print`/`print.ln` are the sharp probe for this because they reroute
// to `print.impl` for shape checking (io.kz:14). An unemitted expansion still
// leaves a real event and a real handler behind — so the failure mode this pins
// is SILENCE, not a diagnostic, and is indistinguishable at the source from an
// arm that ran.
import std/io
import std/store
import app/lib/src
std/store:new(batch, capacity: 2) { *app/lib/src:Src<live!> }
! inserted _ |> std/io:print.ln("arm inserted")
! discharge s |> app/lib/src:close(s): id |> std/io:print.ln("arm discharge {{ id:d }}")
std/io:print.ln("start")
app/lib/src:open(id: 9, work: 1): a |> std/store:insert(batch) { a }
| row _ |> std/io:print.ln("inserted")
| full f |> app/lib/src:close(s: f): id |> std/io:print.ln("full {{ id:d }}")
Supporting Files
// C# implementation facet for app/lib/src — the |cs twin of src.kz's |zig
// bodies.
//
// *Src is a mutable two-field handle — `step` decrements s.left in place —
// so the carrier is a declared class, not an anonymous object (C# anonymous
// members are read-only; same ruling as string.kcs's __KoruBox). GC is the
// allocator: `close` doesn't free, it only reads the id out.
public class SrcBox {
public dynamic id;
public dynamic left;
}
~proc open|cs {
return new SrcBox { id = id, left = work };
}
~proc step|cs {
if (s.left <= 0) return new Output { tag = "complete" };
s.left -= 1;
moved(s.id);
if (s.left == 0) return new Output { tag = "complete" };
return new Output { tag = "running" };
}
~proc close|cs {
return s.id;
}
// A synthetic PARTICIPANT with curl's exact contract, so the pump shape can be
// probed without libcurl or a terminal.
//
// open → mints *Src<live!> (curl: multi.start | started)
// step → BORROWS <live>, `| running` / `| complete` (curl: poll)
// close → CONSUMES <!live>, hands a value back (curl: finish/cancel)
//
// close returning a value is the load-bearing detail: it leaves the column with
// ZERO void dischargers, so a store holding one must be drained by an explicit
// `! discharge` arm rather than auto-discharged (690_109's shape).
const std = @import("std");
pub const Src = struct { id: i64, left: i64 };
~pub tor open { id: i64, work: i64 } -> *Src<live!>
~proc open|zig {
const s = std.heap.page_allocator.create($mod.Src) catch unreachable;
s.* = .{ .id = id, .left = work };
return s;
}
~pub tor step { s: *Src<live> }
! ?moved i64
| running
| complete
~proc step|zig {
if (s.left <= 0) return .{ .complete = .{} };
s.left -= 1;
moved(s.id);
if (s.left == 0) return .{ .complete = .{} };
return .{ .running = .{} };
}
~pub tor close { s: *Src<!live> } -> i64
~proc close|zig {
const id = s.id;
std.heap.page_allocator.destroy(s);
return id;
}
Actual
start
arm inserted
inserted
arm discharge 9
Expected output
✓ Zig✓ C#start
arm inserted
inserted
arm discharge 9
Emitted Zig source
// Access compiler flags via the per-user compiler_env module
const CompilerEnv = @import("compiler_env").CompilerEnv;
pub const panic = if (@import("builtin").mode == .Debug)
@import("std").debug.FullPanic(@import("std").debug.defaultPanic)
else
@import("std").debug.simple_panic;
const __koru_bare = struct {
extern fn posix_memalign(memptr: *?*anyopaque, alignment: usize, size: usize) c_int;
extern fn free(ptr: ?*anyopaque) void;
fn bareAlloc(_: *anyopaque, len: usize, alignment: @import("std").mem.Alignment, _: usize) ?[*]u8 {
var p: ?*anyopaque = null;
const a = @max(alignment.toByteUnits(), @sizeOf(usize));
if (posix_memalign(&p, a, len) != 0) return null;
return @ptrCast(p);
}
fn bareResize(_: *anyopaque, _: []u8, _: @import("std").mem.Alignment, _: usize, _: usize) bool { return false; }
fn bareRemap(_: *anyopaque, _: []u8, _: @import("std").mem.Alignment, _: usize, _: usize) ?[*]u8 { return null; }
fn bareFree(_: *anyopaque, memory: []u8, _: @import("std").mem.Alignment, _: usize) void { free(@ptrCast(memory.ptr)); }
const vtable = @import("std").mem.Allocator.VTable{ .alloc = bareAlloc, .resize = bareResize, .remap = bareRemap, .free = bareFree };
const allocator = @import("std").mem.Allocator{ .ptr = undefined, .vtable = &vtable };
};
const __koru_backing = if (@import("builtin").link_libc) @import("std").heap.c_allocator else if (@import("builtin").os.tag == .freestanding) __koru_bare.allocator else @import("std").heap.page_allocator;
var __koru_leak_count: usize = 0;
fn __koru_alloc(ctx: *anyopaque, len: usize, alignment: @import("std").mem.Alignment, ret_addr: usize) ?[*]u8 {
_ = ctx;
const r = __koru_backing.rawAlloc(len, alignment, ret_addr);
if (comptime @import("builtin").mode == .Debug) {
if (r != null) __koru_leak_count += 1;
}
return r;
}
fn __koru_resize(ctx: *anyopaque, memory: []u8, alignment: @import("std").mem.Alignment, new_len: usize, ret_addr: usize) bool {
_ = ctx;
return __koru_backing.rawResize(memory, alignment, new_len, ret_addr);
}
fn __koru_remap(ctx: *anyopaque, memory: []u8, alignment: @import("std").mem.Alignment, new_len: usize, ret_addr: usize) ?[*]u8 {
_ = ctx;
return __koru_backing.rawRemap(memory, alignment, new_len, ret_addr);
}
fn __koru_free(ctx: *anyopaque, memory: []u8, alignment: @import("std").mem.Alignment, ret_addr: usize) void {
_ = ctx;
__koru_backing.rawFree(memory, alignment, ret_addr);
if (comptime @import("builtin").mode == .Debug) {
__koru_leak_count -= 1;
}
}
const __koru_vtable = @import("std").mem.Allocator.VTable{ .alloc = __koru_alloc, .resize = __koru_resize, .remap = __koru_remap, .free = __koru_free };
pub fn koru_allocator() @import("std").mem.Allocator {
return .{ .ptr = undefined, .vtable = &__koru_vtable };
}
pub inline fn __koru_intcast(comptime T: type, x: anytype) T {
if (comptime (@import("builtin").mode == .Debug or @import("builtin").mode == .ReleaseSafe))
return @as(T, @intCast(x));
const dst = @typeInfo(T);
const src = @typeInfo(@TypeOf(x));
if (comptime (dst == .int and src == .int and dst.int.bits == src.int.bits and dst.int.signedness != src.int.signedness))
return @as(T, @bitCast(x));
return @as(T, @intCast(x));
}
pub fn koru_leak_check() void {
if (comptime @import("builtin").mode != .Debug) return;
if (__koru_leak_count == 0) return;
if (comptime @import("builtin").target.os.tag == .freestanding) {
if (comptime @import("builtin").cpu.arch == .wasm32 or @import("builtin").cpu.arch == .wasm64) {
@panic("KORU LEAK CHECK FAILED: the produced program leaked");
} else {
const __klc = struct { extern var stdout: ?*anyopaque; extern fn fputs(__s: [*:0]const u8, __st: ?*anyopaque) c_int; };
var __lb: [128]u8 = undefined;
const __lm = "KORU LEAK CHECK FAILED: allocations still outstanding at end of run: ";
@memcpy(__lb[0..__lm.len], __lm);
var __ln: usize = __lm.len;
var __lv = __koru_leak_count;
var __ld: [20]u8 = undefined;
var __lk: usize = 0;
while (__lv > 0) : (__lk += 1) { __ld[__lk] = @intCast('0' + __lv % 10); __lv /= 10; }
for (0..__lk) |__li| { __lb[__ln] = __ld[__lk - 1 - __li]; __ln += 1; }
__lb[__ln] = '\n'; __ln += 1; __lb[__ln] = 0;
_ = __klc.fputs(@as([*:0]const u8, @ptrCast(&__lb)), __klc.stdout);
@trap();
}
} else {
@import("std").debug.print("KORU LEAK CHECK FAILED: the produced program leaked (trace above)\n", .{});
@import("std").process.exit(1);
}
}
pub const main_module = struct {
// std/store: plural store 'batch' created (SoA cell + insert/query/write/take/stripe units); fields __koru_value: *app/lib/src:Src<live!>
// >>> FLOW: tests/regression/600_STDLIB/690_STORE/690_240_lifecycle_interceptor_body_runs_its_transforms/input.k:32 ~std.io:print.impl()
pub fn flow0() void {
(struct { fn __kout(__fd: i32, __b: []const u8) void { if (@import("builtin").os.tag == .freestanding) { const __kc = struct { extern var stdout: ?*anyopaque; extern var stderr: ?*anyopaque; extern fn fputs(__s: [*:0]const u8, __st: ?*anyopaque) c_int; }; var __kt: [4096]u8 = undefined; for (0..(__b.len + __kt.len - 2) / (__kt.len - 1)) |__ki| { const __kn = @min(__kt.len - 1, __b.len - __ki * (__kt.len - 1)); @memcpy(__kt[0..__kn], __b[__ki * (__kt.len - 1)..][0..__kn]); __kt[__kn] = 0; @import("std").mem.doNotOptimizeAway(__kc.fputs(@as([*:0]const u8, @ptrCast(&__kt)), if (__fd == 2) __kc.stderr else __kc.stdout)); } } else { @import("std").mem.doNotOptimizeAway(@import("std").posix.write(__fd, __b) catch @as(usize, 0)); } } fn __kw(comptime __f: []const u8, __a: anytype) void { var __kb: [65536]u8 = undefined; const __ks = @import("std").fmt.bufPrint(&__kb, __f, __a) catch __kb[0..0]; __kout(1, __ks); } }).__kw("start\n", .{});
}
// >>> FLOW: tests/regression/600_STDLIB/690_STORE/690_240_lifecycle_interceptor_body_runs_its_transforms/input.k:33 ~app.lib.src:open()
pub fn flow1() void {
const a = koru_app.koru_lib.koru_src.open_event.handler(.{ .id = 9, .work = 1 });
const result_1 = main_module.__store_insertf_batch_event.handler(.{ .__koru_value = a, .__site_line = 33 });
_ = &result_1;
switch (result_1) {
// >>> BRANCH: tests/regression/600_STDLIB/690_STORE/690_240_lifecycle_interceptor_body_runs_its_transforms/input.k:34 | row _auto_6 |>
.row => |_| {
(struct { fn __kout(__fd: i32, __b: []const u8) void { if (@import("builtin").os.tag == .freestanding) { const __kc = struct { extern var stdout: ?*anyopaque; extern var stderr: ?*anyopaque; extern fn fputs(__s: [*:0]const u8, __st: ?*anyopaque) c_int; }; var __kt: [4096]u8 = undefined; for (0..(__b.len + __kt.len - 2) / (__kt.len - 1)) |__ki| { const __kn = @min(__kt.len - 1, __b.len - __ki * (__kt.len - 1)); @memcpy(__kt[0..__kn], __b[__ki * (__kt.len - 1)..][0..__kn]); __kt[__kn] = 0; @import("std").mem.doNotOptimizeAway(__kc.fputs(@as([*:0]const u8, @ptrCast(&__kt)), if (__fd == 2) __kc.stderr else __kc.stdout)); } } else { @import("std").mem.doNotOptimizeAway(@import("std").posix.write(__fd, __b) catch @as(usize, 0)); } } fn __kw(comptime __f: []const u8, __a: anytype) void { var __kb: [65536]u8 = undefined; const __ks = @import("std").fmt.bufPrint(&__kb, __f, __a) catch __kb[0..0]; __kout(1, __ks); } }).__kw("inserted\n", .{});
},
// >>> BRANCH: tests/regression/600_STDLIB/690_STORE/690_240_lifecycle_interceptor_body_runs_its_transforms/input.k:35 | full f |>
.full => |f| {
const id = koru_app.koru_lib.koru_src.close_event.handler(.{ .s = f });
_ = &id;
(struct { fn __kout(__fd: i32, __b: []const u8) void { if (@import("builtin").os.tag == .freestanding) { const __kc = struct { extern var stdout: ?*anyopaque; extern var stderr: ?*anyopaque; extern fn fputs(__s: [*:0]const u8, __st: ?*anyopaque) c_int; }; var __kt: [4096]u8 = undefined; for (0..(__b.len + __kt.len - 2) / (__kt.len - 1)) |__ki| { const __kn = @min(__kt.len - 1, __b.len - __ki * (__kt.len - 1)); @memcpy(__kt[0..__kn], __b[__ki * (__kt.len - 1)..][0..__kn]); __kt[__kn] = 0; @import("std").mem.doNotOptimizeAway(__kc.fputs(@as([*:0]const u8, @ptrCast(&__kt)), if (__fd == 2) __kc.stderr else __kc.stdout)); } } else { @import("std").mem.doNotOptimizeAway(@import("std").posix.write(__fd, __b) catch @as(usize, 0)); } } fn __kw(comptime __f: []const u8, __a: anytype) void { var __kb: [65536]u8 = undefined; const __ks = @import("std").fmt.bufPrint(&__kb, __f, __a) catch __kb[0..0]; __kout(1, __ks); } }).__kw("full {d}\n", .{id});
},
}
}
pub fn koru_start_flow() void {
const result_0 = koru_koru.start_event.handler(.{ });
const result_0_done = result_0.done;
_ = &result_0_done;
}
pub fn koru_end_flow() void {
const result_0 = koru_koru.end_event.handler(.{ });
const result_0_done = result_0.done;
_ = &result_0_done;
}
const __KoruStoreT_batch = struct {
__koru_value: [2]*koru_app.koru_lib.koru_src.Src = undefined,
len: usize = 0,
};
var __koru_store_batch: __KoruStoreT_batch = .{};
const __KoruStoreRow_batch = struct { __koru_value: *koru_app.koru_lib.koru_src.Src };
pub const __store_insertf_batch_event = struct {
pub const Input = struct {
__koru_value: *koru_app.koru_lib.koru_src.Src,
__site_line: i64,
};
pub const Output = union(enum(u8)) {
row: i64,
full: *koru_app.koru_lib.koru_src.Src,
};
pub fn handler(__koru_event_input: @This().Input) @This().Output {
// >>> PROC: __store_insertf_batch [tests/regression/600_STDLIB/690_STORE/690_240_lifecycle_interceptor_body_runs_its_transforms/input.k:28]
const __koru_value = __koru_event_input.__koru_value;
const __site_line = __koru_event_input.__site_line;
_ = &__koru_value;
_ = &__site_line;
_ = &__koru_event_input;
if (__koru_store_batch.len >= 2) return .{ .full = __koru_value };
if (__koru_store_batch.len >= 2) @panic("std/store: store 'batch' is full (capacity 2) - declared capacity and the `| full` branch are pinned at 690_011");
const __koru_new_row = __koru_store_batch.len;
__koru_store_batch.__koru_value[__koru_new_row] = __koru_value;
__koru_store_batch.len += 1;
main_module.__store_inserted_batch_0_event.handler(.{ });
return .{ .row = @as(i64, @intCast(__koru_new_row)) };
}
};
pub const __store_inserted_batch_0_event = struct {
pub const Input = struct {
};
pub const Output = void;
pub fn handler(__koru_event_input: @This().Input) @This().Output {
// >>> SUBFLOW: tests/regression/600_STDLIB/690_STORE/690_240_lifecycle_interceptor_body_runs_its_transforms/input.k:28
_ = &__koru_event_input;
(struct { fn __kout(__fd: i32, __b: []const u8) void { if (@import("builtin").os.tag == .freestanding) { const __kc = struct { extern var stdout: ?*anyopaque; extern var stderr: ?*anyopaque; extern fn fputs(__s: [*:0]const u8, __st: ?*anyopaque) c_int; }; var __kt: [4096]u8 = undefined; for (0..(__b.len + __kt.len - 2) / (__kt.len - 1)) |__ki| { const __kn = @min(__kt.len - 1, __b.len - __ki * (__kt.len - 1)); @memcpy(__kt[0..__kn], __b[__ki * (__kt.len - 1)..][0..__kn]); __kt[__kn] = 0; @import("std").mem.doNotOptimizeAway(__kc.fputs(@as([*:0]const u8, @ptrCast(&__kt)), if (__fd == 2) __kc.stderr else __kc.stdout)); } } else { @import("std").mem.doNotOptimizeAway(@import("std").posix.write(__fd, __b) catch @as(usize, 0)); } } fn __kw(comptime __f: []const u8, __a: anytype) void { var __kb: [65536]u8 = undefined; const __ks = @import("std").fmt.bufPrint(&__kb, __f, __a) catch __kb[0..0]; __kout(1, __ks); } }).__kw("arm inserted\n", .{});
}
};
pub const __store_teardown_batch_event = struct {
pub const Input = struct {
};
pub const Output = void;
pub fn handler(__koru_event_input: @This().Input, comptime __H: type) @This().Output {
const discharge = __H.discharge;
_ = &discharge;
// >>> PROC: __store_teardown_batch [tests/regression/600_STDLIB/690_STORE/690_240_lifecycle_interceptor_body_runs_its_transforms/input.k:28]
_ = &__koru_event_input;
for (0..__koru_store_batch.len) |__koru_i| {
discharge(__koru_store_batch.__koru_value[__koru_i]);
}
__koru_store_batch.len = 0;
return;
}
};
// >>> FLOW: tests/regression/600_STDLIB/690_STORE/690_240_lifecycle_interceptor_body_runs_its_transforms/input.k:28 ~input:__store_teardown_batch()
pub fn flow2() void {
const __koru_eff_disc_0: main_module.__store_teardown_batch_event.Output = __koru_proc_0: {
for (0..__koru_store_batch.len) |__koru_i| {
{ const s = __koru_store_batch.__koru_value[__koru_i]; _ = &s; const id = koru_app.koru_lib.koru_src.close_event.handler(.{ .s = s });
_ = &id;
(struct { fn __kout(__fd: i32, __b: []const u8) void { if (@import("builtin").os.tag == .freestanding) { const __kc = struct { extern var stdout: ?*anyopaque; extern var stderr: ?*anyopaque; extern fn fputs(__s: [*:0]const u8, __st: ?*anyopaque) c_int; }; var __kt: [4096]u8 = undefined; for (0..(__b.len + __kt.len - 2) / (__kt.len - 1)) |__ki| { const __kn = @min(__kt.len - 1, __b.len - __ki * (__kt.len - 1)); @memcpy(__kt[0..__kn], __b[__ki * (__kt.len - 1)..][0..__kn]); __kt[__kn] = 0; @import("std").mem.doNotOptimizeAway(__kc.fputs(@as([*:0]const u8, @ptrCast(&__kt)), if (__fd == 2) __kc.stderr else __kc.stdout)); } } else { @import("std").mem.doNotOptimizeAway(@import("std").posix.write(__fd, __b) catch @as(usize, 0)); } } fn __kw(comptime __f: []const u8, __a: anytype) void { var __kb: [65536]u8 = undefined; const __ks = @import("std").fmt.bufPrint(&__kb, __f, __a) catch __kb[0..0]; __kout(1, __ks); } }).__kw("arm discharge {d}\n", .{id});
}
}
__koru_store_batch.len = 0;
break :__koru_proc_0;
};
_ = __koru_eff_disc_0;
}
};
pub const koru_app = struct {
pub const koru_lib = struct {
pub const koru_src = struct {
const std = @import("std");
pub const Src = struct { id: i64, left: i64 };
pub const open_event = struct {
pub const Input = struct {
id: i64,
work: i64,
};
pub const Output = *koru_app.koru_lib.koru_src.Src;
pub inline fn handler(__koru_event_input: @This().Input) @This().Output {
return __koru_handler_impl(__koru_event_input.id, __koru_event_input.work);
}
fn __koru_handler_impl(__koru_p_0: i64, __koru_p_1: i64) @This().Output {
const __koru_event_input: @This().Input = .{ .id = __koru_p_0, .work = __koru_p_1 };
// >>> PROC: open [/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_240_lifecycle_interceptor_body_runs_its_transforms/lib/src.kz:16]
const id = __koru_event_input.id;
const work = __koru_event_input.work;
_ = &id;
_ = &work;
_ = &__koru_event_input;
const s = std.heap.page_allocator.create(Src) catch unreachable;
s.* = .{ .id = id, .left = work };
return s;
}
};
pub const close_event = struct {
pub const Input = struct {
s: *koru_app.koru_lib.koru_src.Src,
};
pub const Output = i64;
pub fn handler(__koru_event_input: @This().Input) @This().Output {
// >>> PROC: close [/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_240_lifecycle_interceptor_body_runs_its_transforms/lib/src.kz:36]
const s = __koru_event_input.s;
_ = &s;
_ = &__koru_event_input;
const id = s.id;
std.heap.page_allocator.destroy(s);
return id;
}
};
};
};
};
pub const koru_koru = struct {
pub const start_event = struct {
pub const Input = struct {
};
pub const Output = union(enum(u8)) {
done: struct {
},
};
pub fn handler(__koru_event_input: @This().Input) @This().Output {
_ = &__koru_event_input;
return .{ .done = .{} };
}
};
pub const end_event = struct {
pub const Input = struct {
};
pub const Output = union(enum(u8)) {
done: struct {
},
};
pub fn handler(__koru_event_input: @This().Input) @This().Output {
_ = &__koru_event_input;
return .{ .done = .{} };
}
};
};
pub fn main() void {
main_module.koru_start_flow();
main_module.flow0();
main_module.flow1();
main_module.flow2();
main_module.koru_end_flow();
if (comptime @import("builtin").mode == .Debug) koru_leak_check();
}
test {
@import("std").testing.refAllDeclsRecursive(@This());
}
Emitted C# source
public class SrcBox {
public dynamic id;
public dynamic left;
}
static class main_module {
public static void __koru_stdout_write(dynamic s) => global::System.Console.Out.Write(s);
public static void __koru_stderr_write(dynamic s) => global::System.Console.Error.Write(s);
// The mutable handle carrier — `*String`-style resources are
// `new __KoruBox { data = … }` because C# anonymous types are
// read-only: `s.data = …` (std/string append/clear, handle
// mutation generally) needs a settable member.
public class __KoruBox { public dynamic data; }
// Textification for `{{ … }}` operands: C# bool ToStrings as
// `True` where Koru prints `true`, and the operand's static type
// is unknown at this boundary — a `(x) is bool` inline test would
// be a compile error on statically-typed operands instead. Generic
// on purpose: `dynamic` boxed every value-type operand — measured
// ~1s/10M elements on 012_threat_scanner — while T specializes to
// the operand's own ToString() with no box.
public static string __koru_str<T>(T v) => v is bool b ? (b ? "true" : "false") : v?.ToString();
// std/store: plural store 'batch' created (SoA cell + insert/query/write/take/stripe units); fields __koru_value: *app/lib/src:Src<live!>
static class __koru_store_batch {
public static dynamic[] __koru_value = new dynamic[2];
public static long len = 0;
public static long __koru_brand = -1;
}
public static class __store_insertf_batch_event {
public struct Input {
public dynamic __koru_value;
public long __site_line;
}
public struct Output {
public string tag;
public long row;
public dynamic full;
}
public static Output handler(Input __koru_input) {
var __koru_value = __koru_input.__koru_value;
var __site_line = __koru_input.__site_line;
if (__koru_store_batch.len >= 2) return new Output { tag = "full", full = __koru_value };
if (__koru_store_batch.len >= 2) throw new global::System.Exception("std/store: store 'batch' is full (capacity 2) - declared capacity and the `| full` branch are pinned at 690_011");
long __koru_new_row = __koru_store_batch.len;
__koru_store_batch.__koru_value[__koru_new_row] = __koru_value;
__koru_store_batch.len += 1;
main_module.__store_inserted_batch_0_event.handler(new main_module.__store_inserted_batch_0_event.Input { });
return new Output { tag = "row", row = __koru_new_row };
return default;
}
}
public static class __store_inserted_batch_0_event {
public struct Input {
}
public static dynamic handler(Input __koru_input) {
__koru_stdout_write("arm inserted" + "\n");
return default;
}
}
public static class __store_teardown_batch_event {
public struct Input {
}
public interface IOps {
void discharge(dynamic __koru_arg);
}
public static dynamic handler<H>(Input __koru_input, H ops) where H : struct, IOps {
void discharge(dynamic __koru_arg) => ops.discharge(__koru_arg);
for (var __koru_i = 0; __koru_i < __koru_store_batch.len; __koru_i++) {
discharge(__koru_store_batch.__koru_value[__koru_i]);
}
__koru_store_batch.len = 0;
return default;
}
}
public static class std_io_print_ln_event {
public struct Input {
public dynamic expr;
public dynamic invocation;
public dynamic item;
public dynamic program;
public dynamic reporter;
public dynamic allocator;
}
public static dynamic handler(Input __koru_input) {
var expr = __koru_input.expr;
var invocation = __koru_input.invocation;
var item = __koru_input.item;
var program = __koru_input.program;
var reporter = __koru_input.reporter;
var allocator = __koru_input.allocator;
throw new global::System.Exception("ln: [transform] tor is lowered at compile time and must never be called");
}
}
public static class std_io_print_impl_event {
public struct Input {
public dynamic expr;
}
public static dynamic handler(dynamic __koru_input) {
throw new global::System.Exception("std.io:impl has no C# implementation — its body resolves only to a non-cs target (|zig / [comptime]), directly or through a callee");
}
}
public static class app_lib_src_open_event {
public struct Input {
public long id;
public long work;
}
public static dynamic handler(Input __koru_input) {
var id = __koru_input.id;
var work = __koru_input.work;
return new SrcBox { id = id, left = work };
return default;
}
}
public static class app_lib_src_close_event {
public struct Input {
public dynamic s;
}
public static long handler(Input __koru_input) {
var s = __koru_input.s;
return s.id;
return default;
}
}
public static void flow0() {
__koru_stdout_write("start" + "\n");
}
public static void flow1() {
var a = main_module.app_lib_src_open_event.handler(new app_lib_src_open_event.Input { id = (long)(9), work = (long)(1)});
var result_0 = main_module.__store_insertf_batch_event.handler(new __store_insertf_batch_event.Input { __koru_value = a, __site_line = (long)(33)});
if (result_0.tag == "row") {
var _auto_6 = result_0.row;
__koru_stdout_write("inserted" + "\n");
}
if (result_0.tag == "full") {
var f = result_0.full;
var id = main_module.app_lib_src_close_event.handler(new app_lib_src_close_event.Input { s = f});
__koru_stdout_write("full " + __koru_str(id) + "\n");
}
}
public static void flow2() {
var __koru_handlers_1 = new __koru_handlers_1 { };
main_module.__store_teardown_batch_event.handler(new __store_teardown_batch_event.Input { }, __koru_handlers_1);
}
struct __koru_handlers_1 : __store_teardown_batch_event.IOps {
public void discharge(dynamic __koru_arm_2) {
var s = __koru_arm_2;
var id = main_module.app_lib_src_close_event.handler(new app_lib_src_close_event.Input { s = s});
__koru_stdout_write("arm discharge " + __koru_str(id) + "\n");
}
}
}
static class Program {
static void Main() {
main_module.flow0();
main_module.flow1();
main_module.flow2();
}
}
Flows
flow ~new click a branch to expand · @labels scroll to their anchor
new (batch, capacity: 2, source: *app/lib/src:Src<live!>)
flow ~print.ln click a branch to expand · @labels scroll to their anchor
print.ln (expr: "start")
flow ~open click a branch to expand · @labels scroll to their anchor
open (id: 9, work: 1)
Test Configuration
MUST_RUN LANGUAGES: zig cs