Skip to content

Commit

Permalink
sync(BTCPP): 55a7b70b7ab6c1f2be811009e67f6e6630839947
Browse files Browse the repository at this point in the history
  • Loading branch information
imere committed Mar 20, 2024
1 parent df6d5e0 commit 8f945fa
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/Blackboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export class Blackboard extends Map<PropertyKey, Entry> {
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;
}
Expand Down Expand Up @@ -61,19 +60,21 @@ export class Blackboard extends Map<PropertyKey, Entry> {
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;
}
Expand Down

0 comments on commit 8f945fa

Please sign in to comment.