From 8f945fa7875e822a81da2f0c514db78793b56961 Mon Sep 17 00:00:00 2001 From: imere <22460987+imere@users.noreply.github.com> Date: Wed, 20 Mar 2024 13:35:58 +0800 Subject: [PATCH] sync(BTCPP): 55a7b70b7ab6c1f2be811009e67f6e6630839947 --- src/Blackboard.ts | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Blackboard.ts b/src/Blackboard.ts index 09f4b3f..2a2fd45 100644 --- a/src/Blackboard.ts +++ b/src/Blackboard.ts @@ -26,7 +26,6 @@ export class Blackboard extends Map { if (!super.has(key)) { const entry = this.createEntry(key, new PortInfo(PortDirection.INOUT)); entry.value = value; - super.set(key, entry); } else { super.get(key)!.value = value; } @@ -61,19 +60,21 @@ export class Blackboard extends Map { createEntry(key: PropertyKey, info: PortInfo): Entry { if (super.has(key)) return super.get(key)!; - let entry: Entry = new Entry(info); - // manual remapping first if (this.internalToExternal.has(key)) { const remappedKey = this.internalToExternal.get(key)!; - if (this.parent) entry = this.parent.createEntry(remappedKey, info); - } else if (this.autoRemapping && !isPrivateKey(key)) { - if (this.parent) entry = this.parent.createEntry(key, info); - } else { - // not remapped, not found. Create locally. - entry = new Entry(info); - entry.value = info.defaultValue; + if (this.parent) return this.parent.createEntry(remappedKey, info); + throw new Error("Missing parent blackboard"); } + // autoremapping second (excluding private keys) + if (this.autoRemapping && !isPrivateKey(key)) { + if (this.parent) return this.parent.createEntry(key, info); + throw new Error("Missing parent blackboard"); + } + // not remapped, not found. Create locally. + const entry = new Entry(info); + entry.value = info.defaultValue; + super.set(key, entry); return entry; }