Simplify
This commit is contained in:
parent
63270a97b4
commit
78662a0d77
12
actor.ts
12
actor.ts
|
@ -131,9 +131,7 @@ export class Turn {
|
|||
assert(ref: Ref, assertion: Assertion): Handle {
|
||||
const h = nextHandle++;
|
||||
this.enqueue(ref.relay, t => {
|
||||
const a = ref.attenuation === void 0
|
||||
? assertion
|
||||
: runRewrites(ref.attenuation, assertion);
|
||||
const a = runRewrites(ref.attenuation, assertion);
|
||||
if (a !== null) {
|
||||
this.actor.outbound.set(h, ref);
|
||||
ref.target.assert?.(t, a, h);
|
||||
|
@ -167,9 +165,7 @@ export class Turn {
|
|||
}
|
||||
|
||||
message(ref: Ref, assertion: Assertion): void {
|
||||
const a = ref.attenuation === void 0
|
||||
? assertion
|
||||
: runRewrites(ref.attenuation, assertion);
|
||||
const a = runRewrites(ref.attenuation, assertion);
|
||||
if (a !== null) this.enqueue(ref.relay, t => ref.target.message?.(t, assertion));
|
||||
}
|
||||
|
||||
|
@ -261,12 +257,14 @@ export function rewrite(r: Rewrite, v: Assertion): Assertion | null {
|
|||
return instantiate(r.template, bindings);
|
||||
}
|
||||
|
||||
export function runRewrites(a: Attenuation, v: Assertion): Assertion | null {
|
||||
export function runRewrites(a: Attenuation | undefined, v: Assertion): Assertion | null {
|
||||
if (a !== void 0) {
|
||||
for (const r of a) {
|
||||
const w = rewrite(r, v);
|
||||
if (w === null) return null;
|
||||
v = w;
|
||||
}
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue