-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(swingset): refactor reachable flag handling
The c-list kernel-to-vat direction uses a value that holds a composite of a "isReachable" flag and the actual vref. This refactors the handling of this composite value to make it easier for upcoming code to query the isReachable status. refs #3108
- Loading branch information
Showing
3 changed files
with
60 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { assert, details as X } from '@agoric/assert'; | ||
|
||
export function parseReachableAndVatSlot(value) { | ||
assert.typeof(value, 'string', X`non-string value: ${value}`); | ||
const flag = value.slice(0, 1); | ||
assert.equal(value.slice(1, 2), ' '); | ||
const vatSlot = value.slice(2); | ||
let isReachable; | ||
if (flag === 'R') { | ||
isReachable = true; | ||
} else if (flag === '_') { | ||
isReachable = false; | ||
} else { | ||
assert(`flag (${flag}) must be 'R' or '_'`); | ||
} | ||
return { isReachable, vatSlot }; | ||
} | ||
harden(parseReachableAndVatSlot); | ||
|
||
export function buildReachableAndVatSlot(isReachable, vatSlot) { | ||
return `${isReachable ? 'R' : '_'} ${vatSlot}`; | ||
} | ||
harden(buildReachableAndVatSlot); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters