merge contexts
This commit is contained in:
parent
4bea071071
commit
508767278f
1 changed files with 15 additions and 6 deletions
21
strudel.mjs
21
strudel.mjs
|
|
@ -396,7 +396,11 @@ class Pattern {
|
||||||
const new_whole = hap_func.whole
|
const new_whole = hap_func.whole
|
||||||
const new_part = hap_func.part.intersection_e(hap_val.part)
|
const new_part = hap_func.part.intersection_e(hap_val.part)
|
||||||
const new_value = hap_func.value(hap_val.value)
|
const new_value = hap_func.value(hap_val.value)
|
||||||
const hap = new Hap(new_whole, new_part, new_value, hap_val.context)
|
const hap = new Hap(new_whole, new_part, new_value, {
|
||||||
|
...hap_val.context,
|
||||||
|
...hap_func.context,
|
||||||
|
locations: (hap_val.context.locations || []).concat(hap_func.context.locations || []),
|
||||||
|
});
|
||||||
haps.push(hap)
|
haps.push(hap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -416,7 +420,11 @@ class Pattern {
|
||||||
const new_whole = hap_val.whole
|
const new_whole = hap_val.whole
|
||||||
const new_part = hap_func.part.intersection_e(hap_val.part)
|
const new_part = hap_func.part.intersection_e(hap_val.part)
|
||||||
const new_value = hap_func.value(hap_val.value)
|
const new_value = hap_func.value(hap_val.value)
|
||||||
const hap = new Hap(new_whole, new_part, new_value, hap_val.context)
|
const hap = new Hap(new_whole, new_part, new_value, {
|
||||||
|
...hap_func.context,
|
||||||
|
...hap_val.context,
|
||||||
|
locations: (hap_val.context.locations || []).concat(hap_func.context.locations || []),
|
||||||
|
})
|
||||||
haps.push(hap)
|
haps.push(hap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -461,10 +469,11 @@ class Pattern {
|
||||||
const pat_val = this
|
const pat_val = this
|
||||||
const query = function(state) {
|
const query = function(state) {
|
||||||
const withWhole = function(a, b) {
|
const withWhole = function(a, b) {
|
||||||
// TODO: what to do with a.context here?
|
return new Hap(choose_whole(a.whole, b.whole), b.part, b.value, {
|
||||||
return new Hap(choose_whole(a.whole, b.whole), b.part,
|
...a.context,
|
||||||
b.value, b.context
|
...b.context,
|
||||||
)
|
locations: (a.context.locations || []).concat(b.context.locations || []),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
const match = function (a) {
|
const match = function (a) {
|
||||||
return func(a.value).query(state.setSpan(a.part)).map(b => withWhole(a, b))
|
return func(a.value).query(state.setSpan(a.part)).map(b => withWhole(a, b))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue