Commit 7f70e5c
committed
BridgeJS: Hoist stack codecs into named module-scope helpers
Two sites described the same stack ABI twice. Container element positions
without a named codec emitted a local `const elemCodec = {lower, lift}`
literal, re-declared at every lower/lift site, and the generic type-handle
registration emitted an anonymous `{lower, lift}` literal per module type.
Emit one named `{lower, lift}` helper per type shape at module scope instead,
next to the combinators and the primitive codec table, and have both the
element positions and the registration table reference it. Helpers for `@JS`
structs and associated-value enums delegate to the existing
`structHelpers`/`enumHelpers` entries rather than re-emitting their
marshalling; the thin adapter is what lets a helper be a module-scope const
even though those tables are populated later, in `createExports`. The
associated-value enum combinator is gone: its adapter is now the type's
helper.
Composed codecs (`[T]`, `T?`, `[String: T]` and their nestings) are hoisted
the same way and deduplicated across the whole glue, so a generated thunk no
longer builds a codec on every call — previously each call ran e.g.
`__bjs_dictCodec(__bjs_optionalCodec(__bjs_primitiveCodecs.Int)).lower(...)`.
Helper names derived from type names are qualified with the declaring module,
and composed names inherit that qualification from their element, so two
modules declaring same-named `@JS` types cannot mint the same identifier.1 parent db10037 commit 7f70e5c
23 files changed
Lines changed: 1039 additions & 1228 deletions
File tree
- Plugins/BridgeJS
- Sources/BridgeJSLink
- Tests/BridgeJSToolTests
- __Snapshots__/BridgeJSLinkTests
Lines changed: 67 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
420 | 420 | | |
421 | 421 | | |
422 | 422 | | |
423 | | - | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | | - | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
439 | 430 | | |
440 | 431 | | |
441 | 432 | | |
| |||
509 | 500 | | |
510 | 501 | | |
511 | 502 | | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
512 | 506 | | |
513 | | - | |
514 | | - | |
515 | | - | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
516 | 510 | | |
517 | 511 | | |
518 | 512 | | |
| |||
1303 | 1297 | | |
1304 | 1298 | | |
1305 | 1299 | | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
1306 | 1312 | | |
1307 | 1313 | | |
1308 | 1314 | | |
| |||
1406 | 1412 | | |
1407 | 1413 | | |
1408 | 1414 | | |
| 1415 | + | |
1409 | 1416 | | |
1410 | 1417 | | |
1411 | 1418 | | |
1412 | 1419 | | |
1413 | 1420 | | |
1414 | 1421 | | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
1415 | 1463 | | |
1416 | 1464 | | |
1417 | 1465 | | |
| |||
0 commit comments