progress with versioning
This commit is contained in:
parent
e106ced1ec
commit
d30f1312b6
2 changed files with 15 additions and 19 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { emptySet, add, length, forEach, union, has } from "../structures/set.js";
|
||||
import { getDepth, Slot, Value, Write } from "./value_slot.js";
|
||||
import { emptySet, add, length, forEach, has, remove } from "../structures/set.js";
|
||||
import { getDepth, Slot } from "./value_slot.js";
|
||||
import { compareSlot } from "./compare.js";
|
||||
import { makeTypeParser } from "../parser/type_parser.js";
|
||||
import { newDynamic } from "../primitives/dynamic.js";
|
||||
|
|
@ -20,6 +20,10 @@ export const findLCA = slotA => slotB => {
|
|||
}
|
||||
};
|
||||
|
||||
// returns
|
||||
// {slotA} if slotA is younger
|
||||
// {slotB} if slotB is younger
|
||||
// {slotA, slotB} if they are concurrent (conflicting)
|
||||
export const merge = slotA => slotB => {
|
||||
const lca = findLCA(slotA)(slotB);
|
||||
if (compareSlot(lca)(slotA) === 0) {
|
||||
|
|
@ -34,7 +38,7 @@ export const merge = slotA => slotB => {
|
|||
};
|
||||
|
||||
export const mergeN = slots => {
|
||||
let toDelete = emptySetOfSlots;
|
||||
let result = slots;
|
||||
forEach(slots)(slotA => {
|
||||
forEach(slots)(slotB => {
|
||||
// compare all non-identical pairs
|
||||
|
|
@ -44,26 +48,18 @@ export const mergeN = slots => {
|
|||
// if in the pair, one is an ancestor of the other,
|
||||
// only keep the other
|
||||
if (has(m)(slotA)) {
|
||||
toDelete = add(toDelete)(slotB);
|
||||
result = remove(result)(slotB);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
let result = emptySetOfSlots;
|
||||
forEach(slots)(slot => {
|
||||
if (!has(toDelete)(slot)) {
|
||||
result = add(result)(slot);
|
||||
}
|
||||
})
|
||||
return result;
|
||||
};
|
||||
|
||||
const mkType = makeTypeParser({
|
||||
extraPrimitives: [
|
||||
["Value", Value],
|
||||
["Slot" , Slot ],
|
||||
["Write", Write],
|
||||
["Slot" , Slot],
|
||||
],
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue