(attachments: UnknownAttachmentsInput, $: BaseScope)
| 508 | } |
| 509 | |
| 510 | constructor(attachments: UnknownAttachmentsInput, $: BaseScope) { |
| 511 | const shell = attachments.shell |
| 512 | const cache: NodeCache = shell ? (shell.c as never) : new NodeCache() |
| 513 | cache.metaJson = attachments.metaJson |
| 514 | cache.onFail = attachments.meta.onFail ?? $.cfg.onFail |
| 515 | super((shell?.fn as never) ?? callableOf(cache), { bind: null }) |
| 516 | if (attachments.kind !== "intersection") { |
| 517 | for (const k in attachments.impl.keys) { |
| 518 | // only a prop with a default has the key |
| 519 | if (k !== "default" || "default" in attachments.inner) |
| 520 | (this as {} as dict)[k] = attachments.inner[k] |
| 521 | } |
| 522 | } |
| 523 | this.c = cache |
| 524 | const self: mutable<UnknownAttachments> = this |
| 525 | self.id = attachments.id |
| 526 | self.kind = attachments.kind |
| 527 | self.impl = attachments.impl |
| 528 | self.inner = attachments.inner |
| 529 | self.meta = attachments.meta |
| 530 | self.children = attachments.children |
| 531 | this.$ = $ |
| 532 | // own, so jit can replace them |
| 533 | const { tAllows, tApply, tTransform } = this |
| 534 | this.tAllows = tAllows |
| 535 | this.tApply = tApply |
| 536 | if (tTransform) this.tTransform = tTransform |
| 537 | |
| 538 | let bits = 0 |
| 539 | if (this.is("morph")) { |
| 540 | bits = flagBits.hasMorph | flagBits.alters | flagBits.userCode |
| 541 | // a node first is its input, not one it pipes to |
| 542 | if ( |
| 543 | this.inner.morphs.some((morph, i) => |
| 544 | isNode(morph) ? i !== 0 : arityOf(morph) !== 1 |
| 545 | ) |
| 546 | ) |
| 547 | bits |= flagBits.ctxMorph |
| 548 | } else if (this.is("sequence")) { |
| 549 | if (this.inner.defaultables !== undefined) bits = flagBits.alters |
| 550 | } else if (this.is("predicate")) { |
| 551 | if (this.meta.keyword === undefined) bits = flagBits.userCode |
| 552 | // if a predicate accepts exactly one arg, we can safely skip passing context |
| 553 | // technically, a predicate could be written like `(data, ...[ctx]) => ctx.mustBe("malicious")` |
| 554 | // that would break here, but it feels like a pathological case and is better to let people optimize |
| 555 | if (arityOf(this.inner.predicate) !== 1) { |
| 556 | bits |= |
| 557 | returnsReports.has(this.inner.predicate) ? |
| 558 | flagBits.reportsPred |
| 559 | : flagBits.ctxPred |
| 560 | } |
| 561 | } else if (this.is("alias")) |
| 562 | bits = flagBits.isCyclic | flagBits.hasAlias | flagBits.topAlias |
| 563 | |
| 564 | // an alias belongs in a structural value, so one there doesn't make its parent shallow |
| 565 | const inherited = this.isStructural() ? ~flagBits.topAlias : ~0 |
| 566 | for (let i = 0; i < this.children.length; i++) |
| 567 | bits |= this.children[i].bits & inherited |
nothing calls this directly
no test coverage detected