diff --git a/view/vtoplevel.js b/view/vtoplevel.js
index dd5623f66327badeed790501787202514db965a3..c443f617dec4abba46e717526cf0bc8bd805fef9 100644
--- a/view/vtoplevel.js
+++ b/view/vtoplevel.js
@@ -201,6 +201,9 @@ function makeTopLevel(view) {
//writeMessage('addprogram', 'ntlink')
} else if (evt.key === 'v' && evt.ctrlKey) {
//writeMessage('addprogram', 'llink')
+ } else if (evt.key === 'g' && evt.ctrlKey) {
+ // for the keystroke, debug
+ view.globalOrganize(true)
} else if (evt.keyCode === 27) {
// escapekey
console.log('escape!')
@@ -220,38 +223,54 @@ function makeTopLevel(view) {
// trace should return, for an output, the next input.
// if the input is a link, it should try to traverse
- let trace = (output) => {
+ let trace = (output, debug) => {
//console.log(`TRACE: tracing from ${output.name} in hunk ${output.parent.name} in view ${this.name}`)
// ok, traces through links / heirarchy, returning final destination
- // of *connected* links
- if (output.connections.length !== 1) {
- // no connections exist, er, we can only do this for singleton lines
- return false
- }
- let next = output.connections[0]
- //console.log(`TRACE: NEXT:`, next)
- if (next.parent.type === 'link') {
- // this is the heirarchy dive
- let thru = next.parent.reciprocalLink
- //console.log(`TRACE: NEXT: LINK`, thru)
- if (thru) {
- // a mirror,
- let otp = thru.outputs[next.ind]
- if (otp) {
- // return / recurse
- return trace(otp)
+ try {
+ if (debug) console.log(`TRACE: begin or recurse from ${output.name} in ${output.parent.name} from ${output.parent.parentView.name} of ${output.parent.parentView.interpreterName}`)
+ // of *connected* links
+ if (output.connections.length !== 1) {
+ // no connections exist, er, we can only do this for singleton lines
+ if (debug) console.log('TRACE: no connections...')
+ return false
+ }
+ let next = output.connections[0]
+ //console.log(`TRACE: NEXT:`, next)
+ if (next.parent.type === 'link') {
+ // this is the heirarchy dive
+ let thru = next.parent.reciprocalLink
+ if (thru) {
+ console.log(`TRACE: next link`, thru)
+ // a mirror,
+ try {
+ let otp = thru.outputs[next.ind]
+ if (otp) {
+ // return / recurse
+ if (debug) console.log(`TRACE: diving -> ${otp.name}`)
+ return trace(otp, debug)
+ } else {
+ if (debug) console.log(`TRACE: terminates at link, but no reciprocal to dive`)
+ console.warn('on trace, found link, but no output on the other side')
+ return false
+ }
+ } catch (err) {
+ console.error('TRACE: err...')
+ console.error(err)
+ return false
+ }
} else {
- console.warn('on trace, found link, but no output on the other side')
+ // could try doing a globalOrganize, or refresh ... cumbersome
+ if (debug) console.log(`TRACE: terminates at link, but no reciprocal to dive`)
+ console.warn('on trace, at link boundary, find no reciprocal link')
return false
}
} else {
- // could try doing a globalOrganize, or refresh ... cumbersome
- console.warn('on trace, at link boundary, find no reciprocal link')
- return false
+ if (debug) console.log(`TRACE: finally returns`, next)
+ return next
}
- } else {
- //console.log(`TRACE: RETURN:`, next)
- return next
+ } catch (err) {
+ console.error("yep")
+ console.error(err)
}
}
@@ -282,12 +301,16 @@ function makeTopLevel(view) {
let ipv = input.parent.parentView
if (opv === ipv) {
// we r on par
+ if (debug) console.log(`BR: inputs are the same to ${view.name}`)
opv.requestAddLink(output, input).then(() => {
resolve()
})
} else {
// ok, we have two views, and some string of links between them
// let's first see if we can just find the route,
+ // to find another bug (courtesy of the def-replace-polymorphism bugfarm)
+ // we should run a .go before this...
+ view.globalOrganize()
// we are the top level ... but we should hunt by link,
let recurse = (view, entrance, trace) => {
if (debug) console.log(`BR: recurse to ${view.name}`)
@@ -311,12 +334,16 @@ function makeTopLevel(view) {
} else {
return recurse(df.reciprocalLink.parentView, df.reciprocalLink, ntrace)
}
+ } else {
+ if (debug) console.log(`BR: no reciprocal link for ${df.name} within ${view.name}`)
+ reject("no reciprocal link")
} // no reciprocalLink
} // not a link
}
}
let route = recurse(opv, null, [])
- if(!route){
+ if (!route) {
+ if (debug) console.log(`BR: no route returned...`)
console.error("no route to build...")
reject()
}
@@ -343,7 +370,9 @@ function makeTopLevel(view) {
if (debug) console.log("BR: resolved to", route)
// OK: we gotem
// so!
- return view.constructRoute(output, input, route)
+ view.constructRoute(output, input, route).then(() => {
+ resolve()
+ })
} // end not-same-view case,
})
}
@@ -368,9 +397,9 @@ function makeTopLevel(view) {
entlink = entview.defs[entlink.ind]
await entview.requestAddLink(output, entlink.inputs[entlink.inputs.length - 1])
// cover insides,
- for(let rt = 0; rt < route.length - 1; rt ++){
+ for (let rt = 0; rt < route.length - 1; rt++) {
let midview = route[rt].exit.view
- if(midview !== route[rt + 1].entrance.view) throw new Error("these should bridge... ")
+ if (midview !== route[rt + 1].entrance.view) throw new Error("these should bridge... ")
// ok,
let from = route[rt].exit.link
let to = route[rt + 1].entrance.link
@@ -397,8 +426,9 @@ function makeTopLevel(view) {
await outview.requestStateChange(outlink.states[3], exitoplist)
// again, it new
outlink = outview.defs[outlink.ind]
- await outview.requestAddLink(outlink.outputs[entlink.outputs.length - 1], input)
+ await outview.requestAddLink(outlink.outputs[outlink.outputs.length - 1], input)
console.log("FIN")
+ resolve()
}
wrap()
})
@@ -422,14 +452,12 @@ function makeTopLevel(view) {
// order is nth- level down tree, with us (toplevel) at root 0
if (debug) console.log(`GO: scope defs, tl defs`)
for (let df of scope.defs) {
- if (debug) console.log(`GO: df over ${df.name} in ${scope.name}`)
- // edgecased is a block to not walk back-up heirarchy,
if (df.type === 'link' && df.grouptype !== 'edgecased') {
// find recirprocal view relationship via trace, which returns an input, thru links,
// given some output
- if (debug) console.log(`GO: TRACELOG FROM ${df.name}`)
- let rvi = trace(df.outputs[1])
- if (debug) console.log(`GO: TRACELOG RETURNS`, rvi)
+ if (debug) console.log(`GO: trace from ${df.name} in ${scope.name}`)
+ let rvi = trace(df.outputs[1], true)
+ if (debug) console.log(`GO: trace returns`, rvi)
if (rvi) {
// we have ah link definition, and ah view definition, connected by routing,
// so we are safe to do
@@ -448,7 +476,7 @@ function makeTopLevel(view) {
rvd.unwrap()
// find the dataport
let dtprt = trace(df.outputs[0])
- if(dtprt) {
+ if (dtprt) {
dtprt.parent.unwrap()
}
// now, if we have ll data,
@@ -521,25 +549,22 @@ function makeTopLevel(view) {
// and then,
view.requestAddHunk('view').then((viewDef) => {
// jquery moves automatically ?
- console.log('expanding link: the view', viewDef.name)
- console.log('expanding link: the link', linkDef.name)
+ console.log('EL: the view', viewDef.name)
+ console.log('EL: the link', linkDef.name)
// now we'd like to find a route from the view to the link
// since we're global, we could try to build the 1st link,
view.buildRoute(viewDef.outputs[0], linkDef.inputs[1]).then(() => {
- console.log("EXPANDING: Build Route Down Complete")
+ console.log("EL: Build Route Down Complete")
return view.buildRoute(linkDef.outputs[1], viewDef.inputs[0])
}).then(() => {
- console.log("EXPANDING: Build Route UP Complete")
+ console.log("EL: Build Route UP Complete")
view.globalOrganize()
resolve(viewDef)
}).catch((err) => {
- console.error('probable error during route')
+ console.error('EL: probable error during route construction')
reject(err)
})
})
- }).catch((err) => {
- console.log('err during link expansion', err)
- reject(err)
})
} // end expand recipe