✓
Passing This code compiles and runs correctly.
Code
// PINS: `[id]` — a sweep can name the HANDLE of the row it is visiting.
//
// `[ordinal]` is WHERE the visit is. `[id]` is WHICH ROW it is standing on.
// Both are needed and neither substitutes for the other, which is why they are
// two annotations rather than one:
//
// - a cell that names a row names it by HANDLE, never by position (ruled).
// A take swap-removes the last row into the freed slot, so an ordinal
// written to a column outlives its meaning by exactly one removal;
// - so a body that wants to STORE a reference to itself needs the handle,
// and until now the only place a handle was minted was `| row` at insert.
// A sweep could address its row (`store[e]`) but could not name it.
//
// Both requests are synthesized ONLY when asked for — the demand-driven rule
// `[ordinal]` already carried.
//
// The consumer's spelling, and the reason this was built: an INTRUSIVE CHAIN.
// Each visited row reads the current head, writes it to its own `next`, then
// writes ITSELF as the new head — a bucket rebuild, the classic no-allocation
// spatial hash, needing no nested collection, no positional addressing and no
// verb beyond this annotation. Rows are visited 10, 20, 30, so the chain comes
// out 30 -> 20 -> 10, walked back through the handle reads 690_245 pins.
//
// `ordsum` rides alongside to pin that the two requests stay DISTINCT: the
// ordinals are 0, 1, 2 and sum to 3, while the same rows' ids are branded
// handles that address rows correctly. One value could not do both jobs.
//
// Found by the ECS benchmark's spatial grid (tests/benchmarks/003_ecs_reactive),
// which is the workload the vocabulary was waiting for before growing.
import std/io
import std/store
std/store:new(cells, capacity: 8) { v: i64, next: -1[i64] }
std/store:new(head) { h: -1[i64] }
std/store:new(acc) { ordsum: 0[i64] }
std/store:new(probe) { v1: 0[i64], v2: 0[i64], v3: 0[i64] }
std/store:insert(cells) { v: 10, next: -1 }
std/store:insert(cells) { v: 20, next: -1 }
std/store:insert(cells) { v: 30, next: -1 }
std/store:query(cells)
! query { [row]e, [ordinal]n, [id]h } |> std/store:stored { e.next: head.h }
|> std/store:stored { head.h: h }
|> std/store:stored { acc.ordsum: acc.ordsum + n }
std/store:stored { probe.v1: cells[head.h].v, probe.v2: cells[cells[head.h].next].v }
std/store:stored { probe.v3: cells[cells[cells[head.h].next].next].v }
std/io:print.ln("chain {{ probe.v1:d }} -> {{ probe.v2:d }} -> {{ probe.v3:d }} ordsum {{ acc.ordsum:d }}")
Supporting Files
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v8.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v8.0": {
"a_cs_equiv/1.0.0": {
"runtime": {
"a_cs_equiv.dll": {}
}
}
}
},
"libraries": {
"a_cs_equiv/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}{
"runtimeOptions": {
"tfm": "net8.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "8.0.0"
},
"configProperties": {
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}chain 30 -> 20 -> 10 ordsum 3
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable>
<AssemblyName>a_cs_equiv</AssemblyName>
<WarningLevel>0</WarningLevel>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
</PropertyGroup>
<ItemGroup>
<Compile Include="output_emitted.cs" />
</ItemGroup>
</Project>
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("a_cs_equiv")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+73ba11db56be006bccd0e336c10b98e84afb8a8a")]
[assembly: System.Reflection.AssemblyProductAttribute("a_cs_equiv")]
[assembly: System.Reflection.AssemblyTitleAttribute("a_cs_equiv")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Generated by the MSBuild WriteCodeFragment class.
781bcb8eb7f6067e092418577e860799fe5cda0e2c63b7711dbb724cd1e01e1a
is_global = true
build_property.TargetFramework = net8.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = koru
build_property.ProjectDir = /Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_246_sweep_names_its_own_row_handle/
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
build_property.EffectiveAnalysisLevelStyle = 8.0
build_property.EnableCodeStyleSeverity =
5be0995b741828a5c320155d1f80abdffa79d05541ea191d12e3a61e37fca459
/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_246_sweep_names_its_own_row_handle/obj/Debug/net8.0/koru.GeneratedMSBuildEditorConfig.editorconfig
/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_246_sweep_names_its_own_row_handle/obj/Debug/net8.0/koru.AssemblyInfoInputs.cache
/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_246_sweep_names_its_own_row_handle/obj/Debug/net8.0/koru.AssemblyInfo.cs
/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_246_sweep_names_its_own_row_handle/obj/Debug/net8.0/koru.csproj.CoreCompileInputs.cache
/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_246_sweep_names_its_own_row_handle/obj/Debug/net8.0/koru.sourcelink.json
/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_246_sweep_names_its_own_row_handle/a_cs_equiv
/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_246_sweep_names_its_own_row_handle/obj/Debug/net8.0/a_cs_equiv.dll
/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_246_sweep_names_its_own_row_handle/obj/Debug/net8.0/refint/a_cs_equiv.dll
/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_246_sweep_names_its_own_row_handle/obj/Debug/net8.0/a_cs_equiv.pdb
/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_246_sweep_names_its_own_row_handle/a_cs_equiv.deps.json
/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_246_sweep_names_its_own_row_handle/obj/Debug/net8.0/koru.genruntimeconfig.cache
/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_246_sweep_names_its_own_row_handle/a_cs_equiv.runtimeconfig.json
/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_246_sweep_names_its_own_row_handle/a_cs_equiv.dll
/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_246_sweep_names_its_own_row_handle/obj/Debug/net8.0/ref/a_cs_equiv.dll
/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_246_sweep_names_its_own_row_handle/a_cs_equiv.pdb
2aa69e5170a12d97a978b6d1c280d17029065d469d937cc0aebe806be50f1c6f
{"documents":{"/Users/larsde/src/koru/*":"https://raw.githubusercontent.com/korulang/koru/73ba11db56be006bccd0e336c10b98e84afb8a8a/*"}}{
"format": 1,
"restore": {
"/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_246_sweep_names_its_own_row_handle/koru.csproj": {}
},
"projects": {
"/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_246_sweep_names_its_own_row_handle/koru.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_246_sweep_names_its_own_row_handle/koru.csproj",
"projectName": "a_cs_equiv",
"projectPath": "/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_246_sweep_names_its_own_row_handle/koru.csproj",
"packagesPath": "/Users/larsde/.nuget/packages/",
"outputPath": "/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_246_sweep_names_its_own_row_handle/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/Users/larsde/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"net8.0"
],
"sources": {
"/opt/homebrew/Cellar/dotnet/9.0.0/libexec/library-packs": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "all"
},
"SdkAnalysisLevel": "9.0.100"
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"downloadDependencies": [
{
"name": "Microsoft.AspNetCore.App.Ref",
"version": "[8.0.11, 8.0.11]"
},
{
"name": "Microsoft.NETCore.App.Host.osx-arm64",
"version": "[8.0.11, 8.0.11]"
},
{
"name": "Microsoft.NETCore.App.Ref",
"version": "[8.0.11, 8.0.11]"
}
],
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/opt/homebrew/Cellar/dotnet/9.0.0/libexec/sdk/9.0.100/PortableRuntimeIdentifierGraph.json"
}
}
}
}
}<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/Users/larsde/.nuget/packages/</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/Users/larsde/.nuget/packages/</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.12.0</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="/Users/larsde/.nuget/packages/" />
</ItemGroup>
</Project><?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />{
"version": 3,
"targets": {
"net8.0": {}
},
"libraries": {},
"projectFileDependencyGroups": {
"net8.0": []
},
"packageFolders": {
"/Users/larsde/.nuget/packages/": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_246_sweep_names_its_own_row_handle/koru.csproj",
"projectName": "a_cs_equiv",
"projectPath": "/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_246_sweep_names_its_own_row_handle/koru.csproj",
"packagesPath": "/Users/larsde/.nuget/packages/",
"outputPath": "/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_246_sweep_names_its_own_row_handle/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/Users/larsde/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"net8.0"
],
"sources": {
"/opt/homebrew/Cellar/dotnet/9.0.0/libexec/library-packs": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "all"
},
"SdkAnalysisLevel": "9.0.100"
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"downloadDependencies": [
{
"name": "Microsoft.AspNetCore.App.Ref",
"version": "[8.0.11, 8.0.11]"
},
{
"name": "Microsoft.NETCore.App.Host.osx-arm64",
"version": "[8.0.11, 8.0.11]"
},
{
"name": "Microsoft.NETCore.App.Ref",
"version": "[8.0.11, 8.0.11]"
}
],
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/opt/homebrew/Cellar/dotnet/9.0.0/libexec/sdk/9.0.100/PortableRuntimeIdentifierGraph.json"
}
}
}
}{
"version": 2,
"dgSpecHash": "TF2pVUtUDR0=",
"success": true,
"projectFilePath": "/Users/larsde/src/koru/tests/regression/600_STDLIB/690_STORE/690_246_sweep_names_its_own_row_handle/koru.csproj",
"expectedPackageFiles": [
"/Users/larsde/.nuget/packages/microsoft.netcore.app.ref/8.0.11/microsoft.netcore.app.ref.8.0.11.nupkg.sha512",
"/Users/larsde/.nuget/packages/microsoft.aspnetcore.app.ref/8.0.11/microsoft.aspnetcore.app.ref.8.0.11.nupkg.sha512",
"/Users/larsde/.nuget/packages/microsoft.netcore.app.host.osx-arm64/8.0.11/microsoft.netcore.app.host.osx-arm64.8.0.11.nupkg.sha512"
],
"logs": []
}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 'cells' created (SoA cell + insert/query/write/take/stripe units); fields v: i64, next: i64
// std/store: 'head' created (cell + write-subflow at module scope); fields h: i64
// std/store: 'acc' created (cell + write-subflow at module scope); fields ordsum: i64
// std/store: 'probe' created (cell + write-subflow at module scope); fields v1: i64, v2: i64, v3: i64
static class __koru_store_cells {
public static long[] v = new long[8];
public static dynamic __koru_read_v(long __h) { long __r = __koru_resolve(__h); return v[(int)__r]; }
public static long[] next = new long[8];
public static dynamic __koru_read_next(long __h) { long __r = __koru_resolve(__h); return next[(int)__r]; }
public static long len = 0;
public static long[] __koru_hslot_row = new long[8];
public static long[] __koru_hslot_gen = new long[8];
public static long[] __koru_row_hslot = new long[8];
public static long[] __koru_hslot_free = new long[8];
public static long __koru_hslot_free_len = 0;
public static long __koru_hslot_next = 0;
public static long __koru_brand = 1;
public static bool __koru_ident = true;
public static bool __koru_gen0 = true;
public static void __koru_materialize() {
if (!__koru_ident) return;
for (long __i = 0; __i < len; __i++) { __koru_hslot_row[__i] = __i; __koru_row_hslot[__i] = __i; }
__koru_ident = false;
}
public static long __koru_row_of(long h) {
if (h < 0) return -1;
ulong __u = (ulong)h;
long __slot32 = (long)(__u & 0xFFFFFFFFUL);
if ((__slot32 >> 24) != __koru_brand) return -1;
long __slot = __slot32 & 0xFFFFFF;
if (__slot >= __koru_hslot_next) return -1;
if (__koru_gen0) { if ((__u >> 32) != 0) return -1; return __slot; }
if ((long)(__u >> 32) != __koru_hslot_gen[__slot]) return -1;
if (__koru_ident) return __slot;
long __r = __koru_hslot_row[__slot];
if (__r >= len) return -1;
return __r;
}
public static long __koru_resolve(long h) {
if (h >= 0) {
ulong __u = (ulong)h;
long __slot32 = (long)(__u & 0xFFFFFFFFUL);
if ((__slot32 >> 24) != __koru_brand) throw new global::System.Exception("std/store: 'cells[...]' does not address a row - the value is not a handle this store issued (handles come from `| row` and row cursors)");
long __slot = __slot32 & 0xFFFFFF;
if (__koru_gen0) {
if ((__u >> 32) != 0 && __slot < __koru_hslot_next) throw new global::System.Exception("std/store: stale row handle into store 'cells' - the row it addressed was removed (stale-handle trap pinned at 690_115)");
} else if (__slot < __koru_hslot_next && (long)(__u >> 32) != __koru_hslot_gen[__slot]) throw new global::System.Exception("std/store: stale row handle into store 'cells' - the row it addressed was removed (stale-handle trap pinned at 690_115)");
}
long __r = __koru_row_of(h);
if (__r < 0) throw new global::System.Exception("std/store: 'cells[...]' does not address a row - the value is not a handle this store issued (handles come from `| row` and row cursors)");
return __r;
}
public static long __koru_handle_of(long dense) {
if (__koru_gen0) return dense | (__koru_brand << 24);
long __slot = dense;
if (!__koru_ident) __slot = __koru_row_hslot[dense];
return (__slot | (__koru_brand << 24)) | (__koru_hslot_gen[__slot] << 32);
}
}
static class __koru_store_head {
public static long h = -1;
public static long __koru_brand = -1;
}
static class __koru_store_acc {
public static long ordsum = 0;
public static long __koru_brand = -1;
}
static class __koru_store_probe {
public static long v1 = 0;
public static long v2 = 0;
public static long v3 = 0;
public static long __koru_brand = -1;
}
public static class __store_insert_cells_event {
public struct Input {
public long v;
public long next;
public long __site_line;
}
public static dynamic handler(Input __koru_input) {
var v = __koru_input.v;
var next = __koru_input.next;
var __site_line = __koru_input.__site_line;
if (__koru_store_cells.len >= 8) throw new global::System.Exception("std/store: store 'cells' is full (capacity 8) - declared capacity and the `| full` branch are pinned at 690_011");
long __koru_new_row = __koru_store_cells.len;
long __koru_hslot;
if (__koru_store_cells.__koru_hslot_free_len > 0) {
__koru_store_cells.__koru_hslot_free_len -= 1;
__koru_hslot = __koru_store_cells.__koru_hslot_free[__koru_store_cells.__koru_hslot_free_len];
} else {
__koru_hslot = __koru_store_cells.__koru_hslot_next;
__koru_store_cells.__koru_hslot_next += 1;
}
if (!__koru_store_cells.__koru_ident) {
__koru_store_cells.__koru_hslot_row[__koru_hslot] = __koru_new_row;
__koru_store_cells.__koru_row_hslot[__koru_new_row] = __koru_hslot;
}
__koru_store_cells.v[__koru_new_row] = v;
__koru_store_cells.next[__koru_new_row] = next;
__koru_store_cells.len += 1;
return default;
}
}
public static class __store_apply_cells_event {
public struct Input {
public long row;
public long field;
public long value_0;
public long value_1;
}
public struct Output {
public string tag;
public long v;
public long next;
}
public static Output handler(Input __koru_input) {
var row = __koru_input.row;
var field = __koru_input.field;
var value_0 = __koru_input.value_0;
var value_1 = __koru_input.value_1;
var __koru_r = row;
switch (field) {
case 0: { __koru_store_cells.v[__koru_r] = value_0; return new Output { tag = "v", v = value_0 }; }
case 1: { __koru_store_cells.next[__koru_r] = value_1; return new Output { tag = "next", next = value_1 }; }
}
throw new global::System.Exception("__store_apply_cells: field index " + field + " is not a column of store 'cells'");
return default;
}
}
public static class __store_write_cells_event {
public struct Input {
public long row;
public long field;
public long value_0;
public long value_1;
}
public static dynamic handler(Input __koru_input) {
var row = __koru_input.row;
var field = __koru_input.field;
var value_0 = __koru_input.value_0;
var value_1 = __koru_input.value_1;
var result_0 = main_module.__store_apply_cells_event.handler(new __store_apply_cells_event.Input { row = (long)(row), field = (long)(field), value_0 = (long)(value_0), value_1 = (long)(value_1)});
if (result_0.tag == "v") {
var _auto_6 = result_0.v;
}
if (result_0.tag == "next") {
var _auto_7 = result_0.next;
}
return default;
}
}
public static class __store_apply_head_event {
public struct Input {
public long field;
public long value;
}
public struct Output {
public string tag;
public long h;
}
public static Output handler(Input __koru_input) {
var field = __koru_input.field;
var value = __koru_input.value;
switch (field) {
case 0: { __koru_store_head.h = value; return new Output { tag = "h", h = value }; }
}
throw new global::System.Exception("__store_apply_head: field index " + field + " is not a column of store 'head'");
return default;
}
}
public static class __store_write_head_event {
public struct Input {
public long field;
public long value;
}
public static dynamic handler(Input __koru_input) {
var field = __koru_input.field;
var value = __koru_input.value;
var result_1 = main_module.__store_apply_head_event.handler(new __store_apply_head_event.Input { field = (long)(field), value = (long)(value)});
var _auto_8 = result_1.h;
return default;
}
}
public static class __store_announce_head_event {
public struct Input {
public long field;
}
public static dynamic handler(Input __koru_input) {
var field = __koru_input.field;
return default;
}
}
public static class __store_apply_acc_event {
public struct Input {
public long field;
public long value;
}
public struct Output {
public string tag;
public long ordsum;
}
public static Output handler(Input __koru_input) {
var field = __koru_input.field;
var value = __koru_input.value;
switch (field) {
case 0: { __koru_store_acc.ordsum = value; return new Output { tag = "ordsum", ordsum = value }; }
}
throw new global::System.Exception("__store_apply_acc: field index " + field + " is not a column of store 'acc'");
return default;
}
}
public static class __store_write_acc_event {
public struct Input {
public long field;
public long value;
}
public static dynamic handler(Input __koru_input) {
var field = __koru_input.field;
var value = __koru_input.value;
var result_2 = main_module.__store_apply_acc_event.handler(new __store_apply_acc_event.Input { field = (long)(field), value = (long)(value)});
var _auto_9 = result_2.ordsum;
return default;
}
}
public static class __store_announce_acc_event {
public struct Input {
public long field;
}
public static dynamic handler(Input __koru_input) {
var field = __koru_input.field;
return default;
}
}
public static class __store_apply_probe_event {
public struct Input {
public long field;
public long value;
}
public struct Output {
public string tag;
public long v1;
public long v2;
public long v3;
}
public static Output handler(Input __koru_input) {
var field = __koru_input.field;
var value = __koru_input.value;
switch (field) {
case 0: { __koru_store_probe.v1 = value; return new Output { tag = "v1", v1 = value }; }
case 1: { __koru_store_probe.v2 = value; return new Output { tag = "v2", v2 = value }; }
case 2: { __koru_store_probe.v3 = value; return new Output { tag = "v3", v3 = value }; }
}
throw new global::System.Exception("__store_apply_probe: field index " + field + " is not a column of store 'probe'");
return default;
}
}
public static class __store_write_probe_event {
public struct Input {
public long field;
public long value;
}
public static dynamic handler(Input __koru_input) {
var field = __koru_input.field;
var value = __koru_input.value;
var result_3 = main_module.__store_apply_probe_event.handler(new __store_apply_probe_event.Input { field = (long)(field), value = (long)(value)});
if (result_3.tag == "v1") {
var _auto_10 = result_3.v1;
}
if (result_3.tag == "v2") {
var _auto_11 = result_3.v2;
}
if (result_3.tag == "v3") {
var _auto_12 = result_3.v3;
}
return default;
}
}
public static class __store_announce_probe_event {
public struct Input {
public long field;
}
public static dynamic handler(Input __koru_input) {
var field = __koru_input.field;
return default;
}
}
public static class __store_envwrite_probe_event {
public struct Input {
public long field;
public long value;
}
public static dynamic handler(Input __koru_input) {
var field = __koru_input.field;
var value = __koru_input.value;
var __koru_mask = (ulong)field;
if ((__koru_mask & (1UL << 0)) != 0) __koru_store_probe.v1 = value;
if ((__koru_mask & (1UL << 1)) != 0) __koru_store_probe.v2 = value;
if ((__koru_mask & (1UL << 2)) != 0) __koru_store_probe.v3 = value;
return default;
}
}
public static class __store_sweepbody_cells_L44_690_246_sweep_names_its_own_row_handle_input_d3a0cd_event {
public struct Input {
public long n;
public long h;
public long __koru_sdix_e_L44;
}
public static dynamic handler(Input __koru_input) {
var n = __koru_input.n;
var h = __koru_input.h;
var __koru_sdix_e_L44 = __koru_input.__koru_sdix_e_L44;
main_module.__store_write_cells_event.handler(new __store_write_cells_event.Input { row = (long)(__koru_sdix_e_L44), field = (long)(1), value_0 = (long)(0), value_1 = (long)(__koru_store_head.h)});
main_module.__store_write_head_event.handler(new __store_write_head_event.Input { field = (long)(0), value = (long)(h)});
main_module.__store_write_acc_event.handler(new __store_write_acc_event.Input { field = (long)(0), value = (long)(__koru_store_acc.ordsum + n)});
return default;
}
}
public static class __store_sweeprun_cells_L44_690_246_sweep_names_its_own_row_handle_input_d3a0cd_event {
public struct Input {
}
public static dynamic handler(Input __koru_input) {
{
for (var __koru_si = 0; __koru_si < __koru_store_cells.len; __koru_si++) {
main_module.__store_sweepbody_cells_L44_690_246_sweep_names_its_own_row_handle_input_d3a0cd_event.handler(new main_module.__store_sweepbody_cells_L44_690_246_sweep_names_its_own_row_handle_input_d3a0cd_event.Input { n = (long)(__koru_si), h = __koru_store_cells.__koru_handle_of(__koru_si), __koru_sdix_e_L44 = __koru_si });
}
}
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 void flow0() {
{
var __koru_p_v = (long)(10);
var __koru_p_next = (long)(-1);
var __koru_p___site_line = (long)(39);
if (__koru_store_cells.len >= 8) throw new global::System.Exception("std/store: store 'cells' is full (capacity 8) - declared capacity and the `| full` branch are pinned at 690_011");
long __koru_new_row = __koru_store_cells.len;
long __koru_hslot;
if (__koru_store_cells.__koru_hslot_free_len > 0) {
__koru_store_cells.__koru_hslot_free_len -= 1;
__koru_hslot = __koru_store_cells.__koru_hslot_free[__koru_store_cells.__koru_hslot_free_len];
} else {
__koru_hslot = __koru_store_cells.__koru_hslot_next;
__koru_store_cells.__koru_hslot_next += 1;
}
if (!__koru_store_cells.__koru_ident) {
__koru_store_cells.__koru_hslot_row[__koru_hslot] = __koru_new_row;
__koru_store_cells.__koru_row_hslot[__koru_new_row] = __koru_hslot;
}
__koru_store_cells.v[__koru_new_row] = __koru_p_v;
__koru_store_cells.next[__koru_new_row] = __koru_p_next;
__koru_store_cells.len += 1;
}
}
public static void flow1() {
{
var __koru_p_v = (long)(20);
var __koru_p_next = (long)(-1);
var __koru_p___site_line = (long)(40);
if (__koru_store_cells.len >= 8) throw new global::System.Exception("std/store: store 'cells' is full (capacity 8) - declared capacity and the `| full` branch are pinned at 690_011");
long __koru_new_row = __koru_store_cells.len;
long __koru_hslot;
if (__koru_store_cells.__koru_hslot_free_len > 0) {
__koru_store_cells.__koru_hslot_free_len -= 1;
__koru_hslot = __koru_store_cells.__koru_hslot_free[__koru_store_cells.__koru_hslot_free_len];
} else {
__koru_hslot = __koru_store_cells.__koru_hslot_next;
__koru_store_cells.__koru_hslot_next += 1;
}
if (!__koru_store_cells.__koru_ident) {
__koru_store_cells.__koru_hslot_row[__koru_hslot] = __koru_new_row;
__koru_store_cells.__koru_row_hslot[__koru_new_row] = __koru_hslot;
}
__koru_store_cells.v[__koru_new_row] = __koru_p_v;
__koru_store_cells.next[__koru_new_row] = __koru_p_next;
__koru_store_cells.len += 1;
}
}
public static void flow2() {
{
var __koru_p_v = (long)(30);
var __koru_p_next = (long)(-1);
var __koru_p___site_line = (long)(41);
if (__koru_store_cells.len >= 8) throw new global::System.Exception("std/store: store 'cells' is full (capacity 8) - declared capacity and the `| full` branch are pinned at 690_011");
long __koru_new_row = __koru_store_cells.len;
long __koru_hslot;
if (__koru_store_cells.__koru_hslot_free_len > 0) {
__koru_store_cells.__koru_hslot_free_len -= 1;
__koru_hslot = __koru_store_cells.__koru_hslot_free[__koru_store_cells.__koru_hslot_free_len];
} else {
__koru_hslot = __koru_store_cells.__koru_hslot_next;
__koru_store_cells.__koru_hslot_next += 1;
}
if (!__koru_store_cells.__koru_ident) {
__koru_store_cells.__koru_hslot_row[__koru_hslot] = __koru_new_row;
__koru_store_cells.__koru_row_hslot[__koru_new_row] = __koru_hslot;
}
__koru_store_cells.v[__koru_new_row] = __koru_p_v;
__koru_store_cells.next[__koru_new_row] = __koru_p_next;
__koru_store_cells.len += 1;
}
}
public static void flow3() {
{
{
for (var __koru_si = 0; __koru_si < __koru_store_cells.len; __koru_si++) {
main_module.__store_sweepbody_cells_L44_690_246_sweep_names_its_own_row_handle_input_d3a0cd_event.handler(new main_module.__store_sweepbody_cells_L44_690_246_sweep_names_its_own_row_handle_input_d3a0cd_event.Input { n = (long)(__koru_si), h = __koru_store_cells.__koru_handle_of(__koru_si), __koru_sdix_e_L44 = __koru_si });
}
}
}
}
public static void flow4() {
{
var __koru_p_field = (long)((long)((long)((ulong)((ulong)(1) << 0))));
var __koru_p_value = (long)(__koru_store_cells.__koru_read_v(__koru_store_head.h));
var __koru_mask = (ulong)__koru_p_field;
if ((__koru_mask & (1UL << 0)) != 0) __koru_store_probe.v1 = __koru_p_value;
if ((__koru_mask & (1UL << 1)) != 0) __koru_store_probe.v2 = __koru_p_value;
if ((__koru_mask & (1UL << 2)) != 0) __koru_store_probe.v3 = __koru_p_value;
}
{
var __koru_p_field = (long)((long)((long)((ulong)((ulong)(1) << 1))));
var __koru_p_value = (long)(__koru_store_cells.__koru_read_v(__koru_store_cells.__koru_read_next(__koru_store_head.h)));
var __koru_mask = (ulong)__koru_p_field;
if ((__koru_mask & (1UL << 0)) != 0) __koru_store_probe.v1 = __koru_p_value;
if ((__koru_mask & (1UL << 1)) != 0) __koru_store_probe.v2 = __koru_p_value;
if ((__koru_mask & (1UL << 2)) != 0) __koru_store_probe.v3 = __koru_p_value;
}
{
var __koru_p_field = (long)(0);
}
{
var __koru_p_field = (long)(1);
}
}
public static void flow5() {
main_module.__store_write_probe_event.handler(new __store_write_probe_event.Input { field = (long)(2), value = (long)(__koru_store_cells.__koru_read_v(__koru_store_cells.__koru_read_next(__koru_store_cells.__koru_read_next(__koru_store_head.h))))});
}
public static void flow6() {
__koru_stdout_write("chain " + __koru_str(__koru_store_probe.v1) + " -> " + __koru_str(__koru_store_probe.v2) + " -> " + __koru_str(__koru_store_probe.v3) + " ordsum " + __koru_str(__koru_store_acc.ordsum) + "\n");
}
}
static class Program {
static void Main() {
main_module.flow0();
main_module.flow1();
main_module.flow2();
main_module.flow3();
main_module.flow4();
main_module.flow5();
main_module.flow6();
}
}
Actual
chain 30 -> 20 -> 10 ordsum 3
Expected output
✓ Zig✓ C#chain 30 -> 20 -> 10 ordsum 3
Flows
flow ~new click a branch to expand · @labels scroll to their anchor
new (cells, capacity: 8, source: v: i64, next: -1[i64])
flow ~new click a branch to expand · @labels scroll to their anchor
new (head, source: h: -1[i64])
flow ~new click a branch to expand · @labels scroll to their anchor
new (acc, source: ordsum: 0[i64])
flow ~new click a branch to expand · @labels scroll to their anchor
new (probe, source: v1: 0[i64], v2: 0[i64], v3: 0[i64])
flow ~insert click a branch to expand · @labels scroll to their anchor
insert (cells, source: v: 10, next: -1)
flow ~insert click a branch to expand · @labels scroll to their anchor
insert (cells, source: v: 20, next: -1)
flow ~insert click a branch to expand · @labels scroll to their anchor
insert (cells, source: v: 30, next: -1)
flow ~query click a branch to expand · @labels scroll to their anchor
query (cells)
flow ~stored click a branch to expand · @labels scroll to their anchor
stored (source: probe.v1: cells[head.h].v, probe.v2: cells[cells[head.h].next].v)
flow ~stored click a branch to expand · @labels scroll to their anchor
stored (source: probe.v3: cells[cells[cells[head.h].next].next].v)
flow ~print.ln click a branch to expand · @labels scroll to their anchor
print.ln (expr: "chain {{ probe.v1:d }} -> {{ probe.v2:d }} -> {{ probe.v3:d }} ordsum {{ acc.ordsum:d }}")
Test Configuration
MUST_RUN LANGUAGES: zig cs