behavior-contracts 0.2.5 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,380 @@
1
+ import { GeneratorFailure } from "./core.js";
2
+ import { buildTypePlan, deriveTypeRef } from "./typed.js";
3
+ import { buildComponentPlan } from "./straightline.js";
4
+ import { rustTypedInternals } from "./emit-straightline-typed-rust.js";
5
+ const PORT_SCOPE = "port_scope()";
6
+ const { sanitize, rustFieldName, rustStrLit, renderTypeRef, rustScalar, typedCell, isTypedComponent, hasAnyTypeAnnotation, collectTypedNodes, emitTypeDecls, emitDefaults, emitSerializers, emitMarshallers, emitMarshalHelpers, serializeTyped, emitTypedValue, indentBlock, emitOpsLiteral, emitPlanLiteral, rustStraightlineEmitter, setRustForceRunPlanImports, } = rustTypedInternals;
7
+ // ── RAW marshallers (the de-box): read a RawValue field-by-field into a concrete struct ──
8
+ function emitRawMarshallers(plan) {
9
+ if (plan.decls.length === 0)
10
+ return "";
11
+ return plan.decls.map((d) => emitOneRawMarshaller(d, plan)).join("\n\n");
12
+ }
13
+ function emitOneRawMarshaller(d, plan) {
14
+ const lines = [];
15
+ lines.push(`#[allow(dead_code)]`);
16
+ lines.push(`fn marshal_raw_${d.name}(raw: &RawValue) -> Result<${d.name}, BehaviorError> {`);
17
+ // The row seam: a RawRow (native accessor), NOT a Value::Obj. This IS the de-box.
18
+ lines.push(` let row = match raw {`);
19
+ lines.push(` RawValue::Row(r) => r,`);
20
+ lines.push(` other => return Err(raw_type_mismatch(${rustStrLit("obj")}, other.type_name())),`);
21
+ lines.push(` };`);
22
+ const fieldInits = [];
23
+ for (const f of d.fields) {
24
+ const fieldVar = `field_${rustFieldName(f.name).replace(/^r#/, "")}`;
25
+ const keyLit = rustStrLit(f.name);
26
+ lines.push(` let ${fieldVar} = {`);
27
+ lines.push(` let fv = match row.field(${keyLit}) {`);
28
+ lines.push(` Some(v) => v,`);
29
+ lines.push(` None => return Err(raw_missing_prop(${rustStrLit(d.name)}, ${keyLit})),`);
30
+ lines.push(` };`);
31
+ lines.push(indentBlock(emitRawFieldMaterialize("fv", f.type, plan), 2));
32
+ lines.push(` };`);
33
+ fieldInits.push(` ${rustFieldName(f.name)}: ${fieldVar},`);
34
+ }
35
+ lines.push(` Ok(${d.name} {`);
36
+ lines.push(...fieldInits);
37
+ lines.push(` })`);
38
+ lines.push(`}`);
39
+ return lines.join("\n");
40
+ }
41
+ /**
42
+ * emitRawFieldMaterialize — materialize `src` (a `&RawValue` expr) into a concrete typed value
43
+ * per `ref` (a value-returning block). scalar -> RawValue match, named -> marshal_raw_T*, arr
44
+ * -> RawValue::Arr loop, opt -> RawValue::Null branch. No Value::Obj/Value ever built.
45
+ */
46
+ function emitRawFieldMaterialize(src, ref, plan) {
47
+ switch (ref.kind) {
48
+ case "scalar": {
49
+ if (ref.scalar === "null") {
50
+ // null-only field stays a Value::Null (the struct field type is Value for null-only).
51
+ return `Value::Null`;
52
+ }
53
+ const variant = ref.scalar === "int" ? "Int" : ref.scalar === "float" ? "Float" : ref.scalar === "bool" ? "Bool" : "Str";
54
+ const bind = ref.scalar === "string" ? "s.clone()" : "*s";
55
+ return [
56
+ `match ${src} {`,
57
+ ` RawValue::${variant}(s) => ${bind},`,
58
+ ` other => return Err(raw_type_mismatch(${rustStrLit(ref.scalar)}, other.type_name())),`,
59
+ `}`,
60
+ ].join("\n");
61
+ }
62
+ case "named": {
63
+ return `marshal_raw_${ref.name}(${src})?`;
64
+ }
65
+ case "arr": {
66
+ const elemTy = renderTypeRef(ref.elem);
67
+ const inner = emitRawFieldMaterialize("elem_raw", ref.elem, plan);
68
+ return [
69
+ `match ${src} {`,
70
+ ` RawValue::Arr(items) => {`,
71
+ ` let mut out: Vec<${elemTy}> = Vec::with_capacity(items.len());`,
72
+ ` for elem_raw in items.iter() {`,
73
+ ` let elem_out = ${indentBlock(inner, 3).trimStart()};`,
74
+ ` out.push(elem_out);`,
75
+ ` }`,
76
+ ` out`,
77
+ ` }`,
78
+ ` other => return Err(raw_type_mismatch(${rustStrLit("arr")}, other.type_name())),`,
79
+ `}`,
80
+ ].join("\n");
81
+ }
82
+ case "opt": {
83
+ const inner = emitRawFieldMaterialize("inner_raw", ref.inner, plan);
84
+ return [
85
+ `match ${src} {`,
86
+ ` RawValue::Null => None,`,
87
+ ` inner_raw => {`,
88
+ ` let inner_out = ${indentBlock(inner, 2).trimStart()};`,
89
+ ` Some(inner_out)`,
90
+ ` }`,
91
+ `}`,
92
+ ].join("\n");
93
+ }
94
+ }
95
+ }
96
+ /** scalar/arr/opt node RAW materializer name. */
97
+ function rawNodeMaterializerName(nodeId) {
98
+ return `materialize_raw_node_${typedCell(nodeId)}`;
99
+ }
100
+ function emitRawNodeMaterializers(comp, typedNodes, plan) {
101
+ const parts = [];
102
+ for (const [id, ref] of typedNodes.entries()) {
103
+ if (ref.kind === "named")
104
+ continue;
105
+ const ty = renderTypeRef(ref);
106
+ const body = emitRawFieldMaterialize("raw", ref, plan);
107
+ parts.push(`#[allow(dead_code)]\nfn ${rawNodeMaterializerName(id)}(raw: &RawValue) -> Result<${ty}, BehaviorError> {\n Ok(${indentBlock(body, 1).trimStart()})\n}`);
108
+ }
109
+ return parts.join("\n\n");
110
+ }
111
+ // ── RAW runner ────────────────────────────────────────────────────────────────────────
112
+ function assertRawSupported(comp) {
113
+ for (const n of comp.body) {
114
+ if ("map" in n || "cond" in n) {
115
+ const ot = n.outType;
116
+ if (ot !== undefined) {
117
+ throw new GeneratorFailure("UNSUPPORTED_NODE_STRAIGHTLINE", `rust raw ABI (bc#76): component '${comp.name}' node '${n.id}' is a typed ${"map" in n ? "map" : "cond"} node. The raw handler ABI de-box currently covers the componentRef read-handler shape (graphddb's row hydrator). Regenerate this component on the boxed typed path (rust-typed) — do NOT emit a raw module that re-boxes map/cond results.`);
118
+ }
119
+ }
120
+ }
121
+ }
122
+ function emitStoreRawNode(nodeId, srcExpr, ref, indent, producedCell) {
123
+ const pad = " ".repeat(indent);
124
+ if (ref === undefined)
125
+ return `${pad}let _ = ${srcExpr};`;
126
+ const call = ref.kind === "named" ? `marshal_raw_${ref.name}(${srcExpr})` : `${rawNodeMaterializerName(nodeId)}(${srcExpr})`;
127
+ const prod = ` ${producedCell(nodeId)}.set(true);`;
128
+ return `${pad}match ${call} {
129
+ ${pad} Ok(tv) => { *${typedCell(nodeId)}.borrow_mut() = tv;${prod} }
130
+ ${pad} Err(e) => {
131
+ ${pad} *err_cell = Some(e);
132
+ ${pad} return ExecOutcome::Error("aborted".to_string());
133
+ ${pad} }
134
+ ${pad}}`;
135
+ }
136
+ function producedCellName(id) {
137
+ return `produced_${typedCell(id)}`;
138
+ }
139
+ function emitRawExecArm(op, typedNodes, plan) {
140
+ if (op.kind !== "componentRef") {
141
+ throw new GeneratorFailure("UNSUPPORTED_NODE_STRAIGHTLINE", `rust raw ABI (bc#76): node '${op.id}' kind '${op.kind}' is not supported on the raw path (componentRef only). Regenerate on rust-typed.`);
142
+ }
143
+ const portRows = op.ports.length === 0
144
+ ? " Ok(Vec::new())"
145
+ : ` Ok(vec![\n${op.ports
146
+ .map((pt) => ` (${rustStrLit(pt.name)}.to_string(), (${pt.expr})?),`)
147
+ .join("\n")}\n ])`;
148
+ const ref = typedNodes.get(op.id);
149
+ const materialize = emitStoreRawNode(op.id, "v", ref, 4, producedCellName);
150
+ return ` if i == ${op.index} {
151
+ let eval_ports = || -> Result<Vec<(String, Value)>, behavior_contracts::ExprFailure> {
152
+ ${portRows}
153
+ };
154
+ let ports = match eval_ports() {
155
+ Ok(p) => p,
156
+ Err(e) => {
157
+ *err_cell = Some(e.into());
158
+ return ExecOutcome::Error("aborted".to_string());
159
+ }
160
+ };
161
+ let outcome = match handlers.exec_raw_ctx(${rustStrLit(op.id)}, ${rustStrLit(op.component ?? "")}, &ports, None) {
162
+ Some(o) => o,
163
+ None => {
164
+ *err_cell = Some(BehaviorError::new("UNKNOWN_COMPONENT", format!("component '{}' has no handler (fail-closed)", ${rustStrLit(op.component ?? "")})));
165
+ return ExecOutcome::Error("aborted".to_string());
166
+ }
167
+ };
168
+ let v = match &outcome {
169
+ RawOutcome::Ok(v) => v,
170
+ RawOutcome::Error(e) => {
171
+ *err_cell = Some(BehaviorError::new("OP_FAILED", e.clone()));
172
+ return ExecOutcome::Error("aborted".to_string());
173
+ }
174
+ };
175
+ ${materialize}
176
+ return ExecOutcome::Ok(Value::Null);
177
+ }`;
178
+ }
179
+ function emitRawRunner(comp, plan) {
180
+ assertRawSupported(comp);
181
+ const fn = sanitize(comp.name);
182
+ const plans = buildComponentPlan(comp, rustTypedInternals.rustStraightlineInternals.dialect, PORT_SCOPE);
183
+ const typedNodes = collectTypedNodes(comp, plan);
184
+ const cellDecls = [...typedNodes.entries()]
185
+ .map(([id, ref]) => ` let ${typedCell(id)}: RefCell<${renderTypeRef(ref)}> = RefCell::new(Default::default());`)
186
+ .join("\n");
187
+ const producedDecls = [...typedNodes.keys()]
188
+ .map((id) => ` let ${producedCellName(id)} = std::cell::Cell::new(false);`)
189
+ .join("\n");
190
+ const portScopeNodeInjections = [...typedNodes.entries()]
191
+ .map(([id, ref]) => {
192
+ const isBareCopyScalar = ref.kind === "scalar" && (ref.scalar === "int" || ref.scalar === "float" || ref.scalar === "bool");
193
+ const owned = isBareCopyScalar ? `*${typedCell(id)}.borrow()` : `${typedCell(id)}.borrow().clone()`;
194
+ const ser = serializeTyped(owned, ref, plan);
195
+ return ` if ${producedCellName(id)}.get() {\n s.push((${rustStrLit(id)}.to_string(), ${ser}));\n }`;
196
+ })
197
+ .join("\n");
198
+ const arms = plans.ops.map((op) => emitRawExecArm(op, typedNodes, plan)).join("\n");
199
+ const planExpr = comp.plan ? emitPlanLiteral(comp.plan) : "None";
200
+ const outRef = comp.outputType !== undefined ? deriveTypeRef(comp.outputType, plan) : undefined;
201
+ const out = emitTypedValue(comp.output, outRef, typedNodes, plan);
202
+ const outRefFinal = out.ref ?? outRef;
203
+ const serialized = outRefFinal ? serializeTyped("__typed_out", outRefFinal, plan) : "__typed_out";
204
+ const opsLiteral = emitOpsLiteral(plans);
205
+ return `// run_typed_raw_${fn} — RAW-ABI STRUCT-NATIVE exec (bc#76 de-box): the run_plan primitive drives the
206
+ // plan (plan SSoT); per-node arms call the RAW handler (exec_raw_ctx -> RawValue, NOT a boxed Value) and
207
+ // materialize the node's outType struct DIRECTLY from the RawValue via marshal_raw_T*. The dynamic
208
+ // Value/Value::Obj tree is NEVER built on the row data plane — that is the de-box the boxed typed path
209
+ // only LAYERED. Output is assembled as a struct and serialized to a Value ONLY at the final return
210
+ // boundary (the equivalence pin), so the OBSERVED result equals run_behavior. Called by bind_raw.
211
+ fn run_typed_raw_${fn}<H: RawComponentExec>(
212
+ handlers: &mut H,
213
+ input: &[(String, Value)],
214
+ ) -> Result<Value, BehaviorError> {
215
+ let ops: Vec<OpSpec> = ${opsLiteral};
216
+ ${cellDecls ? cellDecls + "\n" : ""}${producedDecls ? producedDecls + "\n" : ""} let port_scope = || -> Vec<(String, Value)> {
217
+ let mut s = input.to_vec();
218
+ ${portScopeNodeInjections ? portScopeNodeInjections + "\n" : ""} s
219
+ };
220
+ let _ = &port_scope;
221
+ let mut pending_err: Option<BehaviorError> = None;
222
+
223
+ let run = {
224
+ let err_cell = &mut pending_err;
225
+ let exec = |op: &OpSpec, _bound: Option<&Value>| -> ExecOutcome {
226
+ if err_cell.is_some() {
227
+ return ExecOutcome::Error("aborted".to_string());
228
+ }
229
+ let i = match ops.iter().position(|o| o.id == op.id) {
230
+ Some(i) => i,
231
+ None => {
232
+ *err_cell = Some(no_typed_exec_arm(&op.id));
233
+ return ExecOutcome::Error("aborted".to_string());
234
+ }
235
+ };
236
+ let _ = i;
237
+ ${arms}
238
+ *err_cell = Some(BehaviorError::new("UNKNOWN_NODE_KIND", format!("op '{}' has no generated raw exec arm (fail-closed)", op.id)));
239
+ ExecOutcome::Error("aborted".to_string())
240
+ };
241
+ run_plan(${planExpr}, &ops, exec)
242
+ };
243
+
244
+ if let Some(e) = pending_err {
245
+ return Err(e);
246
+ }
247
+ let _run = run?;
248
+
249
+ let __typed_out = ${out.expr};
250
+ Ok(${serialized})
251
+ }`;
252
+ }
253
+ // ── bind_raw dispatch surface ───────────────────────────────────────────────────────
254
+ function emitBindRaw(ctx) {
255
+ const typedComps = ctx.ir.components.filter((c) => isTypedComponent(c));
256
+ const names = typedComps.map((c) => rustStrLit(c.name));
257
+ const arms = typedComps
258
+ .map((c) => ` ${rustStrLit(c.name)} => run_typed_raw_${sanitize(c.name)}(&mut self.handlers, input),`)
259
+ .join("\n");
260
+ return `// COMPONENT_NAMES_RAW — typed components exposed on the RAW-ABI de-boxed path.
261
+ pub const COMPONENT_NAMES_RAW: [&str; ${names.length}] = [${names.join(", ")}];
262
+
263
+ // bind_raw / BoundRaw — the RAW-ABI dispatch surface (bc#76): binds a RawComponentExec (native-backed
264
+ // handler results) to the de-boxed struct-native runners. Mirrors bind/Bound::call but drives the raw
265
+ // runner. Untyped components stay on the boxed bind.
266
+ pub fn bind_raw<H: RawComponentExec>(handlers: H) -> BoundRaw<H> {
267
+ BoundRaw { handlers }
268
+ }
269
+
270
+ pub struct BoundRaw<H: RawComponentExec> {
271
+ handlers: H,
272
+ }
273
+
274
+ impl<H: RawComponentExec> BoundRaw<H> {
275
+ pub fn call(&mut self, name: &str, input: &[(String, Value)]) -> Result<Value, BehaviorError> {
276
+ match name {
277
+ ${arms}
278
+ other => Err(BehaviorError::new("UNKNOWN_ENTRY", format!("component '{other}' is not a raw-typed entry (fail-closed)"))),
279
+ }
280
+ }
281
+ }`;
282
+ }
283
+ // ── module assembly ──────────────────────────────────────────────────────────────────
284
+ function emit(ctx) {
285
+ const typed = hasAnyTypeAnnotation(ctx);
286
+ if (!typed) {
287
+ throw new GeneratorFailure("UNSUPPORTED_NODE_STRAIGHTLINE", "rust raw ABI (bc#76): the IR has no outType/outputType annotations — there is nothing to de-box. Use rust-straightline for untyped IR.");
288
+ }
289
+ const plan = buildTypePlan(ctx.ir);
290
+ const decls = emitTypeDecls(plan);
291
+ const defaults = emitDefaults(plan);
292
+ const rawMarshallers = emitRawMarshallers(plan);
293
+ const serializers = emitSerializers(plan);
294
+ // Boxed marshallers + helpers exist ONLY for the Value-space output-assembly fallback
295
+ // (materializeExpr on an output that directly refs an input param of a named type — a Value
296
+ // boundary read, NOT the row data plane). The ROW data plane is de-boxed via marshal_raw_* in
297
+ // the runner (asserted by the anti-sham gate).
298
+ const boxedMarshallers = emitMarshallers(plan);
299
+ const marshalHelpers = emitMarshalHelpers();
300
+ const nodeMaterializers = [];
301
+ for (const comp of ctx.ir.components) {
302
+ if (!isTypedComponent(comp))
303
+ continue;
304
+ const typedNodes = new Map();
305
+ for (const n of comp.body) {
306
+ if ("map" in n)
307
+ continue;
308
+ const ot = n.outType;
309
+ if (ot !== undefined)
310
+ typedNodes.set(n.id, deriveTypeRef(ot, plan));
311
+ }
312
+ const nm = emitRawNodeMaterializers(comp, typedNodes, plan);
313
+ if (nm)
314
+ nodeMaterializers.push(nm);
315
+ }
316
+ const runners = ctx.ir.components
317
+ .filter((c) => isTypedComponent(c))
318
+ .map((c) => emitRawRunner(c, plan))
319
+ .join("\n\n");
320
+ const bindRaw = emitBindRaw(ctx);
321
+ const banner = `// ── RAW handler ABI layer (bc#76 — Rust de-box: struct materialized DIRECTLY from the wire payload) ──
322
+ // This layer is ADDITIVE to the straight-line body above. A RawComponentExec handler returns a RawValue
323
+ // (native-backed, NOT a Value::Obj tree — see rust/src/rawabi.rs). marshal_raw_T* matches on it straight
324
+ // into the concrete struct: the dynamic Value tree the boxed typed path built and then re-walked NEVER
325
+ // exists here. bind_raw drives the de-boxed runners.
326
+ use std::cell::RefCell;
327
+ use behavior_contracts::{RawComponentExec, RawOutcome, RawValue, raw_missing_prop, raw_type_mismatch};`;
328
+ const sections = [
329
+ banner,
330
+ decls || undefined,
331
+ defaults || undefined,
332
+ rawMarshallers
333
+ ? `// RAW marshallers (§4.4, de-box): materialize a concrete struct field-by-field from a native RawValue.\n// NO Value::Obj on this data plane — that is the whole point of #76.\n${rawMarshallers}`
334
+ : undefined,
335
+ marshalHelpers,
336
+ boxedMarshallers
337
+ ? `// Value-space output-assembly fallback (marshal_*): reached ONLY when an output directly refs an\n// input param of a named type (a Value boundary read, not the row data plane). Off the de-box hot path.\n${boxedMarshallers}`
338
+ : undefined,
339
+ nodeMaterializers.length
340
+ ? `// scalar/arr/opt node RAW materializers: FAIL-CLOSED de-box (TYPE_MISMATCH/MISSING_PROP) from RawValue.\n${nodeMaterializers.join("\n\n")}`
341
+ : undefined,
342
+ serializers
343
+ ? `// typed -> Value serializers (final return boundary only): canonical observation for the equivalence pin.\n${serializers}`
344
+ : undefined,
345
+ `// RAW-ABI struct-native runners: the REAL de-box exec path (called by bind_raw).\n${runners}`,
346
+ bindRaw,
347
+ ];
348
+ const typedBody = sections.filter((s) => !!s).join("\n\n");
349
+ // Force the RunPlan-path imports the raw runner needs (run_plan/OpSpec/ExecOutcome). Ports are
350
+ // Value-space, so the straight-line body's expression helpers are reused unchanged. relationKind
351
+ // is needed when a raw op literal carries a relationKind (parent-field child/relation nodes, #74).
352
+ setRustForceRunPlanImports({
353
+ runPlan: true,
354
+ relationKind: /\bRelationKind\b/.test(typedBody),
355
+ json: /\bjson!\(/.test(typedBody),
356
+ });
357
+ const straightlineCode = rustStraightlineEmitter.emit(ctx);
358
+ setRustForceRunPlanImports(null);
359
+ // The RAW module reuses the straight-line body as a SUBSTRATE (its expression helpers drive the
360
+ // Value-space ports), but drives dispatch through bind_raw — so the boxed bind/Bound/run_* and the
361
+ // boxed-only marshal helpers are unused in this artifact. A module-level allow keeps the generated
362
+ // RAW module clippy -D warnings clean without hand-editing the shared straight-line emitter. This
363
+ // is a GENERATED-TOOLKIT allowance on dead SUBSTRATE, not a blanket allow on the de-box path: the
364
+ // de-box (marshal_raw_*, run_typed_raw_*, bind_raw) is exercised and asserted by the anti-sham gate.
365
+ const moduleAllow = `#![allow(dead_code, unused_imports)]\n`;
366
+ return `${moduleAllow}${straightlineCode.replace(/\n+$/, "\n")}\n${typedBody}\n`;
367
+ }
368
+ /**
369
+ * rustRawAbiEmitter — language id `rust-typed-raw` (bc#76). Emits the straight-line body (for
370
+ * untyped components / helpers) plus the RAW-ABI de-boxed layer (struct materialized directly from
371
+ * RawValue) and the bind_raw surface. Requires at least one outType/outputType annotation.
372
+ */
373
+ export const rustRawAbiEmitter = {
374
+ language: "rust-typed-raw",
375
+ fileExtension: ".rs",
376
+ defaultRuntimeImport: "behavior_contracts",
377
+ filenameHint: "behaviors_typed_raw_generated.rs",
378
+ emit,
379
+ };
380
+ //# sourceMappingURL=emit-raw-abi-rust.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emit-raw-abi-rust.js","sourceRoot":"","sources":["../../src/generator/emit-raw-abi-rust.ts"],"names":[],"mappings":"AAsCA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,aAAa,EAA8C,MAAM,YAAY,CAAC;AACtG,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAGvE,MAAM,UAAU,GAAG,cAAc,CAAC;AAElC,MAAM,EACJ,QAAQ,EACR,aAAa,EACb,UAAU,EACV,aAAa,EACb,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,WAAW,EACX,cAAc,EACd,eAAe,EACf,uBAAuB,EACvB,0BAA0B,GAC3B,GAAG,kBAAkB,CAAC;AAEvB,4FAA4F;AAE5F,SAAS,kBAAkB,CAAC,IAAc;IACxC,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACvC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CA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AAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAExE,+FAA+F;IAC/F,iGAAiG;IACjG,mGAAmG;IACnG,0BAA0B,CAAC;QACzB,OAAO,EAAE,IAAI;QACb,YAAY,EAAE,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC;QAChD,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC;KAClC,CAAC,CAAC;IACH,MAAM,gBAAgB,GAAG,uBAAuB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3D,0BAA0B,CAAC,IAAI,CAAC,CAAC;IAEjC,gGAAgG;IAChG,mGAAmG;IACnG,mGAAmG;IACnG,kGAAkG;IAClG,kGAAkG;IAClG,qGAAqG;IACrG,MAAM,WAAW,GAAG,wCAAwC,CAAC;IAC7D,OAAO,GAAG,WAAW,GAAG,gBAAgB,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC;AACnF,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAkB;IAC9C,QAAQ,EAAE,gBAAgB;IAC1B,aAAa,EAAE,KAAK;IACpB,oBAAoB,EAAE,oBAAoB;IAC1C,YAAY,EAAE,kCAAkC;IAChD,IAAI;CACL,CAAC"}
@@ -27,13 +27,106 @@
27
27
  * `outType`/`outputType` が IR のどこにも無ければ typed 層は emit されず、出力は `go-straightline` と
28
28
  * byte-identical(後方互換 pin)。
29
29
  */
30
- import type { EmitterPlugin } from "./core.js";
31
- import { type TypedMaterializer } from "./typed.js";
30
+ import type { EmitContext, EmitterPlugin } from "./core.js";
31
+ import { type TypePlan, type TypeRef, type TypedMaterializer } from "./typed.js";
32
+ import { setGoForceRunPlanHelpers } from "./emit-straightline-go.js";
33
+ import type { Component } from "../behavior.js";
34
+ /** 可搬スカラ → Go の具体型名(de-box 後の struct field 型)。int/float は int64/float64 で区別。 */
35
+ declare function goScalar(scalar: "string" | "int" | "float" | "bool" | "null"): string;
36
+ /** TypeRef を Go の具体型名へ(named→struct 名、arr→slice、opt→ポインタ、scalar→具体型)。 */
37
+ declare function renderTypeRef(ref: TypeRef): string;
38
+ /** 型プランの named obj を Go struct 宣言へ(decls 順=決定的)。field は宣言順・export 名。gofmt と同じ
39
+ * 列アラインで綴じる(field 名列・型列を最大幅に揃える — 生成物が gofmt clean になるよう)。 */
40
+ declare function emitTypeDecls(plan: TypePlan): string;
41
+ /** wire field 名 → Go の export struct field 名(決定的・一意)。元名は struct コメント/marshaller で保持。 */
42
+ declare function goFieldName(wire: string): string;
43
+ /**
44
+ * emitMarshallers — 各 named struct の raw→typed marshaller(§4.4)。動的 Value(`*Obj` 期待)を受け、
45
+ * 各 field を typed に読み出して具体 struct を組む。generic Value 走査を exec 経路から除去する de-box の実体。
46
+ * field 型ごとに再帰: named→marshal_T*、arr→要素ループ、opt→null 分岐、scalar→型 assert。
47
+ */
48
+ declare function emitMarshallers(plan: TypePlan): string;
49
+ /**
50
+ * serializeTyped — 具体 typed 値式を canonical 直列化用の動的 Value へ戻す式(観測等価 pin)。exec は
51
+ * typed のまま進み、component 境界でだけ Value 化して golden と突き合わせる。named→ser_T*、scalar は
52
+ * そのまま Value、arr→要素 ser ループ helper、opt→null 分岐 helper。式一発で返せるよう helper を通す。
53
+ */
54
+ declare function serializeTyped(typedExpr: string, ref: TypeRef, _plan: TypePlan): string;
32
55
  export declare const goTypedMaterializer: TypedMaterializer;
56
+ /** 各 named struct を canonical Value(*Obj, field は宣言順)へ戻す `ser_T*` + 汎用 arr/opt helper を emit。 */
57
+ declare function emitSerializers(plan: TypePlan): string;
58
+ /** component 名 → Go 関数名(straight-line と同規律)。 */
59
+ declare function sanitize(name: string): string;
60
+ /** 生成コード内の typed ローカル変数名(materialize 済み struct)。 */
61
+ declare function typedLocal(nodeId: string): string;
62
+ /**
63
+ * emitTypedValue — output(Φ 合流式)IR を、期待型 `expected` の **具体 Go typed 値**式へ再帰 lower し、
64
+ * `{ expr, ref }` を返す。これが AC2 の「exec が具体 struct を保持」の実体:
65
+ * - `{ref:[typedNode, …fields]}` → typed struct field 直参照(typedFieldAccess — map lookup でない)。
66
+ * - `{ref:[input/非 typed node]}` → 型付け不能な生 Value。expected があれば materialize(de-box)。
67
+ * - `{obj:{…}}` → 具体 struct literal(expected が named のとき各 field を期待型で lower)。
68
+ * - `{arr:[…]}` → 具体 slice literal(要素は要素型で lower)。
69
+ * - scalar literal → 具体 Go 値。
70
+ * - 演算子(concat/…)→ straight-line 生値を expected へ materialize(意味論は SSoT が持つ)。
71
+ */
72
+ declare function emitTypedValue(node: unknown, expected: TypeRef | undefined, typedNodes: Map<string, TypeRef>, plan: TypePlan): {
73
+ expr: string;
74
+ ref: TypeRef | undefined;
75
+ };
76
+ /**
77
+ * collectTypedNodes — component の body ノードで outType を持つもの(componentRef / map / cond)を
78
+ * id → 結果 TypeRef に index 化する。map/cond も struct 空間で結果を保持する(#66 de-box 拡張)。
79
+ */
80
+ declare function collectTypedNodes(comp: Component, plan: TypePlan): Map<string, TypeRef>;
81
+ /** arr/opt helper 名の決定的キー(要素型で一意化)。 */
82
+ declare function arrHelperKey(ref: TypeRef): string;
83
+ declare function hasAnyTypeAnnotation(ctx: EmitContext): boolean;
84
+ /** typed component(typedView 経路で駆動するもの)か。 */
85
+ declare function isTypedComponent(comp: Component): boolean;
86
+ /** must 系 helper(struct-native exec の scalar/arr/opt/named de-box を単一式で使う)を emit。 */
87
+ declare function emitMustHelpers(plan: TypePlan): string;
88
+ /**
89
+ * emitArrOptNodeHelpers — arr/opt を outType に持つ **node**(named でない node)用の materialize helper
90
+ * `mustArr_*` / `mustOpt_*` を、IR に現れる arr/opt node outType 集合から決定的に emit する。要素/inner が
91
+ * named なら marshaller を、scalar なら型 assert を、ネスト arr/opt なら再帰 helper を呼ぶ(具体 slice/ptr へ de-box)。
92
+ */
93
+ declare function emitArrOptNodeHelpers(ctx: EmitContext, plan: TypePlan): string;
33
94
  /**
34
95
  * goTypedEmitter — 言語識別子 `go-typed` の emitter plugin(bc#47 B2, 実 de-box)。
35
96
  * go-straightline 本体(byte 同一)+ typed 層(struct/marshaller/serializer/typedView)。
36
97
  * `outType` 無し IR は go-straightline と byte-identical(後方互換)。
37
98
  */
38
99
  export declare const goTypedEmitter: EmitterPlugin;
100
+ /**
101
+ * goTypedInternals — shared Go typed-emit helpers the RAW-ABI emitter (bc#76,
102
+ * emit-raw-abi-go.ts) reuses so boxed and raw paths keep one implementation of the
103
+ * type-plan/naming/serializer discipline (only the marshaller data plane and the handler
104
+ * dispatch differ between them).
105
+ */
106
+ export declare const goTypedInternals: {
107
+ PKG: string;
108
+ sanitize: typeof sanitize;
109
+ goFieldName: typeof goFieldName;
110
+ renderTypeRef: typeof renderTypeRef;
111
+ goScalar: typeof goScalar;
112
+ typedLocal: typeof typedLocal;
113
+ isTypedComponent: typeof isTypedComponent;
114
+ collectTypedNodes: typeof collectTypedNodes;
115
+ hasAnyTypeAnnotation: typeof hasAnyTypeAnnotation;
116
+ emitTypeDecls: typeof emitTypeDecls;
117
+ emitSerializers: typeof emitSerializers;
118
+ emitMarshallers: typeof emitMarshallers;
119
+ serializeTyped: typeof serializeTyped;
120
+ emitTypedValue: typeof emitTypedValue;
121
+ arrHelperKey: typeof arrHelperKey;
122
+ emitMustHelpers: typeof emitMustHelpers;
123
+ emitArrOptNodeHelpers: typeof emitArrOptNodeHelpers;
124
+ buildComponentPlanForTyped: (comp: Component) => import("./straightline.js").ComponentPlan;
125
+ emitOpsLiteral: (plan: import("./straightline.js").ComponentPlan) => string;
126
+ emitBehaviorPlanLiteral: (plan: unknown) => string;
127
+ goPortVar: (name: string) => string;
128
+ setGoForceRunPlanHelpers: typeof setGoForceRunPlanHelpers;
129
+ goStraightlineEmitter: EmitterPlugin;
130
+ };
131
+ export {};
39
132
  //# sourceMappingURL=emit-straightline-typed-go.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"emit-straightline-typed-go.d.ts","sourceRoot":"","sources":["../../src/generator/emit-straightline-typed-go.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,WAAW,CAAC;AAE5D,OAAO,EAOL,KAAK,iBAAiB,EACvB,MAAM,YAAY,CAAC;AAiPpB,eAAO,MAAM,mBAAmB,EAAE,iBAOjC,CAAC;AA03BF;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,aAM5B,CAAC"}
1
+ {"version":3,"file":"emit-straightline-typed-go.d.ts","sourceRoot":"","sources":["../../src/generator/emit-straightline-typed-go.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE5D,OAAO,EAIL,KAAK,QAAQ,EACb,KAAK,OAAO,EAEZ,KAAK,iBAAiB,EACvB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAkD,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAGrH,OAAO,KAAK,EAAE,SAAS,EAAkC,MAAM,gBAAgB,CAAC;AAOhF,gFAAgF;AAChF,iBAAS,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAc9E;AAED,yEAAyE;AACzE,iBAAS,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAY3C;AAED;8DAC8D;AAC9D,iBAAS,aAAa,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAc7C;AAED,wFAAwF;AACxF,iBAAS,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAOzC;AAED;;;;GAIG;AACH,iBAAS,eAAe,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAG/C;AA0ID;;;;GAIG;AACH,iBAAS,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,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,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;uCAkBQ,SAAS;;;;;;CAO7C,CAAC"}
@@ -1077,4 +1077,35 @@ export const goTypedEmitter = {
1077
1077
  filenameHint: "behaviors.typed.generated.go",
1078
1078
  emit,
1079
1079
  };
1080
+ /**
1081
+ * goTypedInternals — shared Go typed-emit helpers the RAW-ABI emitter (bc#76,
1082
+ * emit-raw-abi-go.ts) reuses so boxed and raw paths keep one implementation of the
1083
+ * type-plan/naming/serializer discipline (only the marshaller data plane and the handler
1084
+ * dispatch differ between them).
1085
+ */
1086
+ export const goTypedInternals = {
1087
+ PKG,
1088
+ sanitize,
1089
+ goFieldName,
1090
+ renderTypeRef,
1091
+ goScalar,
1092
+ typedLocal,
1093
+ isTypedComponent,
1094
+ collectTypedNodes,
1095
+ hasAnyTypeAnnotation,
1096
+ emitTypeDecls,
1097
+ emitSerializers,
1098
+ emitMarshallers,
1099
+ serializeTyped,
1100
+ emitTypedValue,
1101
+ arrHelperKey,
1102
+ emitMustHelpers,
1103
+ emitArrOptNodeHelpers,
1104
+ buildComponentPlanForTyped: (comp) => buildComponentPlan(comp, goStraightlineInternals.dialect, PORT_SCOPE),
1105
+ emitOpsLiteral: goStraightlineInternals.emitOpsLiteral,
1106
+ emitBehaviorPlanLiteral: goStraightlineInternals.emitBehaviorPlanLiteral,
1107
+ goPortVar: goStraightlineInternals.goPortVar,
1108
+ setGoForceRunPlanHelpers,
1109
+ goStraightlineEmitter,
1110
+ };
1080
1111
  //# sourceMappingURL=emit-straightline-typed-go.js.map