@scriptc/compiler 0.0.5 → 0.0.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.
@@ -5132,6 +5132,10 @@ export function emitExpr(E, e) {
5132
5132
  return finish(`scr_assert_eq_dyn(${arg(0)}, ${arg(1)}, ${arg(2)}, ${arg(3)}, ${arg(4)}, ${arg(5)})`);
5133
5133
  case "assert.deepResult":
5134
5134
  return finish(`scr_assert_deep_result(${arg(0)}, ${arg(1)}, ${arg(2)}, ${arg(3)})`);
5135
+ case "assert.deqEnter":
5136
+ return finish(`scr_assert_deq_enter(${arg(0)}, ${arg(1)})`);
5137
+ case "assert.deqLeave":
5138
+ return finish(`scr_assert_deq_leave()`);
5135
5139
  case "assert.sameValue":
5136
5140
  return finish(`scr_assert_same_value_f64(${arg(0)}, ${arg(1)})`);
5137
5141
  case "assert.match":
@@ -5213,6 +5217,16 @@ export function emitExpr(E, e) {
5213
5217
  return finish(`scr_insp_jsval(${arg(0)}, ${arg(1)}, ${arg(2)})`);
5214
5218
  case "insp.begin":
5215
5219
  return finish(`scr_insp_begin(${arg(0)})`);
5220
+ // Circular references over cycle-capable composites: check/push/
5221
+ // wrap drive Node's seen/circular machinery (scr_inspect.c).
5222
+ case "insp.circCheck":
5223
+ return finish(`scr_insp_circ_check(${arg(0)})`);
5224
+ case "insp.seenPush":
5225
+ return finish(`scr_insp_seen_push(${arg(0)})`);
5226
+ case "insp.refWrap":
5227
+ return finish(`scr_insp_ref_wrap(${arg(0)}, ${arg(1)})`);
5228
+ case "insp.circular":
5229
+ return finish(`scr_insp_circular(${arg(0)})`);
5216
5230
  case "insp.entry":
5217
5231
  return finish(`scr_insp_entry(${arg(0)}, ${arg(1)})`);
5218
5232
  case "insp.key":
@@ -5381,7 +5395,9 @@ export function emitExpr(E, e) {
5381
5395
  // Type-directed serialization: the STATIC type picks an emitted
5382
5396
  // serializer (interned per type) — no DOM, no runtime dispatch. The
5383
5397
  // value temp is BORROWED (released with this statement's frame);
5384
- // the result string is owned (+1). Never throws.
5398
+ // the result string is owned (+1). Throws only over CYCLE-CAPABLE
5399
+ // types (recursive records — the circular-structure TypeError) and
5400
+ // dyn roots; everything else keeps the throw-free path.
5385
5401
  const v = E.emitExpr(e.value);
5386
5402
  // A dyn root: the runtime's DOM walker (scr_dyn_format_j — the %j
5387
5403
  // serializer IS JSON.stringify over the DOM: number/string/bool/
@@ -5395,7 +5411,14 @@ export function emitExpr(E, e) {
5395
5411
  const buf = `sc_t${E.tempCounter++}`;
5396
5412
  E.line(`ScrJsonBuf ${buf}; scr_jb_init(&${buf});${E.srcComment(e.loc)}`);
5397
5413
  E.line(`${helper}(&${buf}, ${v.name});`);
5398
- return E.newTemp(e.type, `scr_jb_finish(&${buf})`);
5414
+ const t = E.newTemp(e.type, `scr_jb_finish(&${buf})`);
5415
+ // A cycle-capable root can throw the circular-structure
5416
+ // TypeError mid-walk: finish still runs (frees the buffer,
5417
+ // the partial string joins the frame and releases on
5418
+ // unwind), then the pending check unwinds.
5419
+ if (E.traceAdapterC(e.value.type) !== null)
5420
+ E.emitPendingCheck();
5421
+ return t;
5399
5422
  })();
5400
5423
  // A pretty-print form (`stringify(v, null, 2)`): the frontend
5401
5424
  // resolved the space to a compile-time indent string (Node's