Test a table cell through tableSite.isCell, and trace no row outside a table
This commit is contained in:
@@ -24,7 +24,7 @@ type readValue struct {
|
||||
}
|
||||
|
||||
// renderTrace is a test's view of the fields a render reads; nil outside a test.
|
||||
type renderTrace func(group, table string, row int, a arm)
|
||||
type renderTrace func(group string, row renderedRow, a arm)
|
||||
|
||||
// holdSet is one render's reference draws: the unnamed draw group's, and each named one's; and a
|
||||
// test's trace of its reads.
|
||||
|
||||
@@ -71,6 +71,10 @@ type tableSite struct {
|
||||
|
||||
const formatRow = -1
|
||||
|
||||
func (s tableSite) isCell() bool {
|
||||
return s.table != nil && s.row != formatRow
|
||||
}
|
||||
|
||||
// templateLink is what a template resolves to in the assembled tree.
|
||||
type templateLink struct {
|
||||
refs map[string]refBinding // each reference the format reads -> what it resolves to
|
||||
|
||||
+3
-3
@@ -88,12 +88,12 @@ func (s *readSurvey) walk(n node, at surveyAt) {
|
||||
}
|
||||
for _, e := range renderEdges(n) {
|
||||
to, isTemplate := e.to.(*template)
|
||||
cell := tableSite{}
|
||||
if isTemplate && to.site.row != formatRow {
|
||||
var cell tableSite
|
||||
if isTemplate {
|
||||
cell = to.site
|
||||
}
|
||||
switch {
|
||||
case cell.table == nil:
|
||||
case !cell.isCell():
|
||||
s.edge(n, e, at)
|
||||
case cell.table == at.wholeTable:
|
||||
in := at
|
||||
|
||||
+1
-1
@@ -81,7 +81,7 @@ func linkRefs(root map[string]node) error {
|
||||
// linkTemplate resolves t's references in category, "" for an inline template, and
|
||||
// compiles its format against them.
|
||||
func linkTemplate(folder []string, path, category string, t *template, root map[string]node) error {
|
||||
if t.site.table != nil && t.site.row != formatRow {
|
||||
if t.site.isCell() {
|
||||
path = fmt.Sprintf("%s, line %d", path, t.site.row+2)
|
||||
}
|
||||
link, err := t.resolveLink(folder, path, category, root)
|
||||
|
||||
@@ -203,15 +203,14 @@ func readHeld(s *session, t *template, held *hold, pins *pinSet, sc renderScope,
|
||||
}
|
||||
|
||||
func traceRead(trace renderTrace, t *template, sc renderScope, a arm) {
|
||||
var table string
|
||||
row := t.site.row
|
||||
if t.site.table != nil {
|
||||
table = t.site.table.path
|
||||
var row renderedRow
|
||||
switch {
|
||||
case t.site.isCell():
|
||||
row = renderedRow{t.site.table, t.site.row}
|
||||
case t.site.table != nil:
|
||||
row = renderedRow{t.site.table, sc.rowOf(t.site.table)}
|
||||
}
|
||||
if row == formatRow {
|
||||
row = sc.rowOf(t.site.table)
|
||||
}
|
||||
trace(strings.Clone(sc.group), strings.Clone(table), row, a)
|
||||
trace(strings.Clone(sc.group), row, a)
|
||||
}
|
||||
|
||||
// renderLeaf draws and renders what a read lands on: null on a null item, or on a column of one
|
||||
|
||||
@@ -31,8 +31,6 @@ on 2026-09-29 a third time (Navigation 7.0, Locality 5.6, Shape 6.3, Self-suffic
|
||||
|
||||
This round, in order:
|
||||
|
||||
- Give `tableSite` one test for a cell, and have `traceRead` report no row outside a
|
||||
table: the zero value reads as row 0, a real cell, so each reader tests `table` first.
|
||||
- Rename `ftoken` to `scanUnit`, beside `formatToken`, and `session` to
|
||||
`generatorState`: three seats confused the token types, and both architects read
|
||||
`session` as per-render state.
|
||||
|
||||
Reference in New Issue
Block a user