fixpoint algorithm: parameterize the Map to use
This commit is contained in:
parent
ea878975be
commit
47786ae792
3 changed files with 58 additions and 10 deletions
|
|
@ -4,10 +4,12 @@
|
|||
// FRANCOIS POTTIER,<a href="https://gallium.inria.fr/~fpottier/publis/fpottier-fix.pdf"> Lazy Least Fixed Points in ML</a>
|
||||
// <a href="https://gitlab.inria.fr/fpottier/fix">OCAML Code</a>
|
||||
|
||||
export const fixer = (eqsFunction, lattice) => {
|
||||
const mFixed = new Map();
|
||||
const mTransient = new Map();
|
||||
const mParents = new Map();
|
||||
// eqsFunction: V -> (V -> P) -> P
|
||||
// elemCmp: (V -> V -> Ordering)
|
||||
export const fixer = (eqsFunction, dictType, lattice) => {
|
||||
const mFixed = dictType();
|
||||
const mTransient = dictType();
|
||||
const mParents = dictType();
|
||||
|
||||
const mWorkset = []; // Note: we use a Stack (LIFO), but FIFO queue or any other collection would also work.
|
||||
|
||||
|
|
@ -16,7 +18,6 @@ export const fixer = (eqsFunction, lattice) => {
|
|||
const ensureTransient = node => {
|
||||
if (mTransient.has(node)) return;
|
||||
mTransient.set(node, lattice.bottom());
|
||||
mParents.set(node, []);
|
||||
mWorkset.push(node);
|
||||
}
|
||||
|
||||
|
|
@ -47,7 +48,7 @@ export const fixer = (eqsFunction, lattice) => {
|
|||
}
|
||||
|
||||
if (!lattice.equality(mTransient.get(current), newProperty)) {
|
||||
mTransient.put(current, newProperty);
|
||||
mTransient.set(current, newProperty);
|
||||
mWorkset.push(...(mParents.get(current) || []));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue