Answer stability round 1: the readField comment names both directions of the shared value, and readName drops what namedPick states
This commit is contained in:
@@ -141,11 +141,11 @@ func (sc renderScope) frameOf(scope *nameScope) *pickFrame {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// readName reads a from its name's pick in the frame rendering the name's scope. Every read of
|
// readName reads a from its name's pick in the frame rendering the name's scope. A read entering
|
||||||
// one pick stays on it: the pick keeps each path's value and variant in its memo and its rows in
|
// another category takes the frames of the name scopes there from the pick's memo (enter), and
|
||||||
// its pins. A read entering another category takes the frames of the name scopes there from the
|
// renderFrame finds them and opens none, so every read of the pick reads one pick of each name
|
||||||
// memo too (enter), and renderFrame finds them and opens none. So {a.street} and {a.postal-code} in
|
// bound there: {a.street} and {a.postal-code} in data/sv_SE/address.json read one pick of the
|
||||||
// data/sv_SE/address.json read one pick of the name l that data/geo/SE/address.json binds.
|
// name l that data/geo/SE/address.json binds.
|
||||||
func readName(s *drawstate.State, sc renderScope, a arm) readValue {
|
func readName(s *drawstate.State, sc renderScope, a arm) readValue {
|
||||||
f := sc.frameOf(a.named.scope)
|
f := sc.frameOf(a.named.scope)
|
||||||
if f == nil {
|
if f == nil {
|
||||||
|
|||||||
+1
-1
@@ -333,7 +333,7 @@ func TestAColumnReadingABoundColumnIsThatColumn(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAFreshReadInsideANamedPickReadsNoneOfThePick(t *testing.T) {
|
func TestAFreshReadInsideANamedPickSharesNoValueWithIt(t *testing.T) {
|
||||||
f := engine(5)
|
f := engine(5)
|
||||||
src := `{"format":"{w as p}{p.a}|{p.a.b}","w":{"format":"{a}","a":{"format":"{c}|{b}","b":["1","2","3"],"c":{"format":"{b}","b":["x","y","z"]}}}}`
|
src := `{"format":"{w as p}{p.a}|{p.a.b}","w":{"format":"{a}","a":{"format":"{c}|{b}","b":["1","2","3"],"c":{"format":"{b}","b":["x","y","z"]}}}}`
|
||||||
want := regexp.MustCompile(`^[xyz]\|([123])\|([123])$`)
|
want := regexp.MustCompile(`^[xyz]\|([123])\|([123])$`)
|
||||||
|
|||||||
@@ -145,8 +145,8 @@ func expand(s *drawstate.State, t *template, sc renderScope) string {
|
|||||||
// readField renders one arm of a token. A read of a name, or of a level a read of the name
|
// readField renders one arm of a token. A read of a name, or of a level a read of the name
|
||||||
// rendering addresses, is kept in that name's pick; every other read draws afresh, so {word}
|
// rendering addresses, is kept in that name's pick; every other read draws afresh, so {word}
|
||||||
// {word} draws twice and {p.a} {p.b} reads two draws of p. A fresh read leaves the pick: a read
|
// {word} draws twice and {p.a} {p.b} reads two draws of p. A fresh read leaves the pick: a read
|
||||||
// below it would key the pick's memo by sc.pickKey, the level the pick rendered, and read the
|
// below it would key the pick's memo by sc.pickKey, the level the pick rendered, so it and the
|
||||||
// pick's value for a node the pick never drew.
|
// pick would read one value for two nodes.
|
||||||
func readField(s *drawstate.State, t *template, sc renderScope, a arm) readValue {
|
func readField(s *drawstate.State, t *template, sc renderScope, a arm) readValue {
|
||||||
switch {
|
switch {
|
||||||
case a.kind == namedRead:
|
case a.kind == namedRead:
|
||||||
|
|||||||
Reference in New Issue
Block a user