Test a table cell through tableSite.isCell, and trace no row outside a table

This commit is contained in:
2026-09-29 12:13:33 +02:00
committed by Lillem4n
parent 4fcf45b5d0
commit 8793681d8a
6 changed files with 16 additions and 15 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ type readValue struct {
} }
// renderTrace is a test's view of the fields a render reads; nil outside a test. // 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 // 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. // test's trace of its reads.
+4
View File
@@ -71,6 +71,10 @@ type tableSite struct {
const formatRow = -1 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. // templateLink is what a template resolves to in the assembled tree.
type templateLink struct { type templateLink struct {
refs map[string]refBinding // each reference the format reads -> what it resolves to refs map[string]refBinding // each reference the format reads -> what it resolves to
+3 -3
View File
@@ -88,12 +88,12 @@ func (s *readSurvey) walk(n node, at surveyAt) {
} }
for _, e := range renderEdges(n) { for _, e := range renderEdges(n) {
to, isTemplate := e.to.(*template) to, isTemplate := e.to.(*template)
cell := tableSite{} var cell tableSite
if isTemplate && to.site.row != formatRow { if isTemplate {
cell = to.site cell = to.site
} }
switch { switch {
case cell.table == nil: case !cell.isCell():
s.edge(n, e, at) s.edge(n, e, at)
case cell.table == at.wholeTable: case cell.table == at.wholeTable:
in := at in := at
+1 -1
View File
@@ -81,7 +81,7 @@ func linkRefs(root map[string]node) error {
// linkTemplate resolves t's references in category, "" for an inline template, and // linkTemplate resolves t's references in category, "" for an inline template, and
// compiles its format against them. // compiles its format against them.
func linkTemplate(folder []string, path, category string, t *template, root map[string]node) error { 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) path = fmt.Sprintf("%s, line %d", path, t.site.row+2)
} }
link, err := t.resolveLink(folder, path, category, root) link, err := t.resolveLink(folder, path, category, root)
+7 -8
View File
@@ -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) { func traceRead(trace renderTrace, t *template, sc renderScope, a arm) {
var table string var row renderedRow
row := t.site.row switch {
if t.site.table != nil { case t.site.isCell():
table = t.site.table.path 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 { trace(strings.Clone(sc.group), row, a)
row = sc.rowOf(t.site.table)
}
trace(strings.Clone(sc.group), strings.Clone(table), row, a)
} }
// renderLeaf draws and renders what a read lands on: null on a null item, or on a column of one // renderLeaf draws and renders what a read lands on: null on a null item, or on a column of one
-2
View File
@@ -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: 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 - Rename `ftoken` to `scanUnit`, beside `formatToken`, and `session` to
`generatorState`: three seats confused the token types, and both architects read `generatorState`: three seats confused the token types, and both architects read
`session` as per-render state. `session` as per-render state.