|
1 |
| -import {ex,C_,i_,o_,VA_ip,detect_type} from '$lib/St' |
| 1 | +import {ex,C_,i_,o_,VA_ip,detect_type,inlace,TheC,TheA} from '$lib/St' |
2 | 2 | //#region toCon a dumper for the A** tree
|
3 | 3 | export function toCon (d) {
|
4 | 4 | if (d.t == null) d.t = 'toCon'
|
@@ -49,18 +49,109 @@ function toCon_resolve (d) {
|
49 | 49 | let names = d.resolving.map(
|
50 | 50 | d => d.t + (d.C.c.Cont && d.C.c.Cont.sc.Ct ? ':'+d.C.c.Cont.sc.Ct : '')
|
51 | 51 | )
|
52 |
| - console.log("seen "+d.t+": "+names.join("\t")) |
| 52 | + //console.log("seen "+d.t+": "+names.join("\t")) |
| 53 | + |
| 54 | + let C = d.C |
| 55 | + let D = d.D |
53 | 56 |
|
| 57 | + DCresolve({D,C,til:C => C.c.pi == 'Con'}) |
| 58 | + // export to d.D what they (Con//Con) resolved to |
| 59 | + d.resolving.map(d => { |
| 60 | + d.D = d.C.y.D |
| 61 | + }) |
54 | 62 |
|
| 63 | + if (C.t == 'toCon') console.log("Given:\n"+threelevelprint(C)) |
55 | 64 | }
|
56 | 65 |
|
57 |
| - |
58 |
| - |
59 | 66 | // now we have d.resolving[d+]
|
60 | 67 | for (let dd of d.resolving) {
|
61 | 68 | toCon_resolve(dd)
|
62 | 69 | }
|
63 | 70 | }
|
| 71 | + |
| 72 | +// the q pile visits all C**, wrt D** |
| 73 | +// including C between those in the d pile (which are only the -Con) |
| 74 | +function DCresolve (c) { |
| 75 | + inlace(c.C,{ |
| 76 | + all:(C,q) => { |
| 77 | + if (q.d == 0) { |
| 78 | + // d.D -> C.y.D, a given fact |
| 79 | + // given from resolving or simply an other branch (eg last time of toCon) |
| 80 | + C.y.D = c.D |
| 81 | + } |
| 82 | + else if (c.til) { |
| 83 | + if (c.til(C,q)) q.not = 1 |
| 84 | + } |
| 85 | + }, |
| 86 | + climbs:(C,q,N) => { |
| 87 | + let D = C.y.D |
| 88 | + if (!D) return C.c.el = 2 |
| 89 | + // D options (past), C given |
| 90 | + let Dtz = i_tz(o_(D)) |
| 91 | + let Ctz = i_tz(N) |
| 92 | + // have all t in Dtz |
| 93 | + for (let t in Ctz) { |
| 94 | + Dtz[t] ||= [] |
| 95 | + } |
| 96 | + for (let t in Dtz) { |
| 97 | + let Dz = Dtz[t] || [] |
| 98 | + let Cz = Ctz[t] || [] |
| 99 | + let Do = Dz.shift() |
| 100 | + let Co = Cz.shift() |
| 101 | + if (Do && Co) { |
| 102 | + // continuation |
| 103 | + Co.y.D = Do |
| 104 | + } |
| 105 | + else if (Co) { |
| 106 | + // coming - it will have no .y.D |
| 107 | + // so the rest of q will just C.c.el = 2 everything |
| 108 | + } |
| 109 | + else if (Do) { |
| 110 | + // going - tell most recent still-present thing |
| 111 | + C.c.removals ||= [] |
| 112 | + C.c.removals.push(Do) |
| 113 | + } |
| 114 | + !Dz.length && delete Dtz[t] |
| 115 | + !Cz.length && delete Ctz[t] |
| 116 | + } |
| 117 | + Object.keys(Dtz).length && console.log("Dtz left: "+Object.keys(Dtz).join(',')) |
| 118 | + Object.keys(Ctz).length && console.log("Ctz left: "+Object.keys(Ctz).join(',')) |
| 119 | + } |
| 120 | + }) |
| 121 | +} |
| 122 | +// indexes a list of C by their .t |
| 123 | +function i_tz (N) { |
| 124 | + let tz = {} |
| 125 | + for (let C of N) { |
| 126 | + let t = C.t |
| 127 | + tz[t] ||= [] |
| 128 | + tz[t].push(C) |
| 129 | + } |
| 130 | + return tz |
| 131 | +} |
| 132 | +function threelevelprint (C) { |
| 133 | + if (!C) return "null" |
| 134 | + let N = [] |
| 135 | + let sip = C => C.c.ip ? C.c.ip.join('.') : '' |
| 136 | + inlace(C,{all:(C,d) => { |
| 137 | + let sipdom = d.up && sip(d.up.s) |
| 138 | + let sipsay = sip(C) |
| 139 | + if (sipsay && sipdom && sipsay.startsWith(sipdom)) sipsay = sipsay.slice(sipdom.length) |
| 140 | + if (C.c.removals) { |
| 141 | + sipsay += " --"+C.c.removals.map(C => C.t).join(',') |
| 142 | + } |
| 143 | + let scsay = C.sc.Ct ? "%Ct="+C.sc.Ct : '' |
| 144 | + if (C.y.D) scsay += '%D' |
| 145 | + N.push( |
| 146 | + new Array(d.d).fill(' ').join('') |
| 147 | + + |
| 148 | + C.t+"\t-"+C.c.pi+"\t"+sipsay+"\t"+scsay |
| 149 | + ) |
| 150 | + if (d.d > 2) return 1 |
| 151 | + }}) |
| 152 | + return N.join("\n") |
| 153 | +} |
| 154 | + |
64 | 155 | // defines an adder of d.C or its C.c.$pi=C/*
|
65 | 156 | function DCpartor (nodepi) {
|
66 | 157 | // arrow functions don't provide their own this binding
|
|
0 commit comments