diff --git a/d2ir/compile.go b/d2ir/compile.go index bd6719e32..661d36027 100644 --- a/d2ir/compile.go +++ b/d2ir/compile.go @@ -14,21 +14,17 @@ func (c *compiler) errorf(n d2ast.Node, f string, v ...interface{}) { } func Compile(ast *d2ast.Map) (*Map, error) { - l := &Layer{} - l.Map = &Map{ - parent: l, - } - + m := &Map{} c := &compiler{} - c.compile(l) + c.compile(m, ast) if !c.err.Empty() { return nil, c.err } - return l, nil + return m, nil } -func (c *compiler) compile(l *Layer) { - c.compileMap(l.Map, l.AST) +func (c *compiler) compile(dst *Map, ast *d2ast.Map) { + c.compileMap(dst, ast) } func (c *compiler) compileMap(dst *Map, ast *d2ast.Map) { diff --git a/d2ir/compile_test.go b/d2ir/compile_test.go index ff66dc61e..42d0ec32d 100644 --- a/d2ir/compile_test.go +++ b/d2ir/compile_test.go @@ -38,23 +38,23 @@ func runa(t *testing.T, tca []testCase) { } } -func compile(t testing.TB, text string) (*d2ir.Layer, error) { +func compile(t testing.TB, text string) (*d2ir.Map, error) { t.Helper() d2Path := fmt.Sprintf("%v.d2", t.Name()) ast, err := d2parser.Parse(d2Path, strings.NewReader(text), nil) assert.Success(t, err) - l, err := d2ir.Compile(ast) + m, err := d2ir.Compile(ast) if err != nil { return nil, err } - err = diff.TestdataJSON(filepath.Join("..", "testdata", "d2ir", t.Name()), l) + err = diff.TestdataJSON(filepath.Join("..", "testdata", "d2ir", t.Name()), m) if err != nil { return nil, err } - return l, nil + return m, nil } func assertField(t testing.TB, n d2ir.Node, nfields, nedges int, primary interface{}, ida ...string) *d2ir.Field { @@ -153,42 +153,42 @@ func testCompileFields(t *testing.T) { { name: "root", run: func(t testing.TB) { - l, err := compile(t, `x`) + m, err := compile(t, `x`) assert.Success(t, err) - assertField(t, l, 1, 0, nil) + assertField(t, m, 1, 0, nil) - assertField(t, l, 0, 0, nil, "x") + assertField(t, m, 0, 0, nil, "x") }, }, { name: "label", run: func(t testing.TB) { - l, err := compile(t, `x: yes`) + m, err := compile(t, `x: yes`) assert.Success(t, err) - assertField(t, l, 1, 0, nil) + assertField(t, m, 1, 0, nil) - assertField(t, l, 0, 0, "yes", "x") + assertField(t, m, 0, 0, "yes", "x") }, }, { name: "nested", run: func(t testing.TB) { - l, err := compile(t, `x.y: yes`) + m, err := compile(t, `x.y: yes`) assert.Success(t, err) - assertField(t, l, 2, 0, nil) + assertField(t, m, 2, 0, nil) - assertField(t, l, 1, 0, nil, "x") - assertField(t, l, 0, 0, "yes", "x", "y") + assertField(t, m, 1, 0, nil, "x") + assertField(t, m, 0, 0, "yes", "x", "y") }, }, { name: "array", run: func(t testing.TB) { - l, err := compile(t, `x: [1;2;3;4]`) + m, err := compile(t, `x: [1;2;3;4]`) assert.Success(t, err) - assertField(t, l, 1, 0, nil) + assertField(t, m, 1, 0, nil) - f := assertField(t, l, 0, 0, nil, "x") + f := assertField(t, m, 0, 0, nil, "x") assert.String(t, `[1; 2; 3; 4]`, f.Composite.String()) }, }, @@ -202,24 +202,24 @@ func testCompileFieldPrimary(t *testing.T) { { name: "root", run: func(t testing.TB) { - l, err := compile(t, `x: yes { pqrs }`) + m, err := compile(t, `x: yes { pqrs }`) assert.Success(t, err) - assertField(t, l, 2, 0, nil) + assertField(t, m, 2, 0, nil) - assertField(t, l, 1, 0, "yes", "x") - assertField(t, l, 0, 0, nil, "x", "pqrs") + assertField(t, m, 1, 0, "yes", "x") + assertField(t, m, 0, 0, nil, "x", "pqrs") }, }, { name: "nested", run: func(t testing.TB) { - l, err := compile(t, `x.y: yes { pqrs }`) + m, err := compile(t, `x.y: yes { pqrs }`) assert.Success(t, err) - assertField(t, l, 3, 0, nil) + assertField(t, m, 3, 0, nil) - assertField(t, l, 2, 0, nil, "x") - assertField(t, l, 1, 0, "yes", "x", "y") - assertField(t, l, 0, 0, nil, "x", "y", "pqrs") + assertField(t, m, 2, 0, nil, "x") + assertField(t, m, 1, 0, "yes", "x", "y") + assertField(t, m, 0, 0, nil, "x", "y", "pqrs") }, }, } @@ -232,42 +232,42 @@ func testCompileEdges(t *testing.T) { { name: "root", run: func(t testing.TB) { - l, err := compile(t, `x -> y`) + m, err := compile(t, `x -> y`) assert.Success(t, err) - assertField(t, l, 2, 1, nil) - assertEdge(t, l, 0, nil, `(x -> y)[0]`) + assertField(t, m, 2, 1, nil) + assertEdge(t, m, 0, nil, `(x -> y)[0]`) - assertField(t, l, 0, 0, nil, "x") - assertField(t, l, 0, 0, nil, "y") + assertField(t, m, 0, 0, nil, "x") + assertField(t, m, 0, 0, nil, "y") }, }, { name: "nested", run: func(t testing.TB) { - l, err := compile(t, `x.y -> z.p`) + m, err := compile(t, `x.y -> z.p`) assert.Success(t, err) - assertField(t, l, 4, 1, nil) + assertField(t, m, 4, 1, nil) - assertField(t, l, 1, 0, nil, "x") - assertField(t, l, 0, 0, nil, "x", "y") + assertField(t, m, 1, 0, nil, "x") + assertField(t, m, 0, 0, nil, "x", "y") - assertField(t, l, 1, 0, nil, "z") - assertField(t, l, 0, 0, nil, "z", "p") + assertField(t, m, 1, 0, nil, "z") + assertField(t, m, 0, 0, nil, "z", "p") - assertEdge(t, l, 0, nil, "(x.y -> z.p)[0]") + assertEdge(t, m, 0, nil, "(x.y -> z.p)[0]") }, }, { name: "underscore", run: func(t testing.TB) { - l, err := compile(t, `p: { _.x -> z }`) + m, err := compile(t, `p: { _.x -> z }`) assert.Success(t, err) - assertField(t, l, 3, 1, nil) + assertField(t, m, 3, 1, nil) - assertField(t, l, 0, 0, nil, "x") - assertField(t, l, 1, 0, nil, "p") + assertField(t, m, 0, 0, nil, "x") + assertField(t, m, 1, 0, nil, "p") - assertEdge(t, l, 0, nil, "(x -> p.z)[0]") + assertEdge(t, m, 0, nil, "(x -> p.z)[0]") }, }, } @@ -280,19 +280,19 @@ func testCompileLayers(t *testing.T) { { name: "root", run: func(t testing.TB) { - l, err := compile(t, `x -> y + m, err := compile(t, `x -> y layers: { bingo: { p.q.z } }`) assert.Success(t, err) - assertField(t, l, 5, 1, nil) - assertEdge(t, l, 0, nil, `(x -> y)[0]`) + assertField(t, m, 7, 1, nil) + assertEdge(t, m, 0, nil, `(x -> y)[0]`) - assertField(t, l, 0, 0, nil, "x") - assertField(t, l, 0, 0, nil, "y") + assertField(t, m, 0, 0, nil, "x") + assertField(t, m, 0, 0, nil, "y") - assertField(t, l, 0, 0, nil, "layers", "bingo") + assertField(t, m, 3, 0, nil, "layers", "bingo") }, }, } diff --git a/d2ir/d2ir.go b/d2ir/d2ir.go index f5030e839..caf819019 100644 --- a/d2ir/d2ir.go +++ b/d2ir/d2ir.go @@ -630,10 +630,6 @@ func (m *Map) CreateEdge(eid *EdgeID, refctx *RefContext) (*Edge, error) { return e, nil } -func (l *Layer) ast() d2ast.Node { - return l.Map.ast() -} - func (s *Scalar) ast() d2ast.Node { return s.Value } @@ -778,14 +774,17 @@ func ParentField(n Node) *Field { return nil } -func ParentLayer(n Node) *Layer { - for n.Parent() != nil { - n = n.Parent() - if n_f, ok := n.(*Layer); ok { - return n_f +func ParentLayer(n Node) *Map { + for { + m := ParentMap(n) + if m == nil { + return nil } + if m.Layer() { + return m + } + n = m } - return nil } func countUnderscores(p []string) int { diff --git a/testdata/d2ir/TestCompile/edges/nested.exp.json b/testdata/d2ir/TestCompile/edges/nested.exp.json index 2bf781919..c843d9b44 100644 --- a/testdata/d2ir/TestCompile/edges/nested.exp.json +++ b/testdata/d2ir/TestCompile/edges/nested.exp.json @@ -1,12 +1,288 @@ { - "ast": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", - "nodes": [ - { - "map_key": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", - "edges": [ - { + "fields": [ + { + "name": "x", + "composite": { + "fields": [ + { + "name": "y", + "references": [ + { + "string": { + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + }, + "key_path": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", + "edges": [ + { + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", + "edges": [ + { + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", "src": { "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", @@ -65,33 +341,232 @@ }, "dst_arrow": ">" } - ], - "primary": {}, - "value": {} + } } - } - ] - }, - "base": { - "fields": [ - { - "name": "x", - "composite": { - "fields": [ - { - "name": "y", - "references": [ - { - "string": { - "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" + ] + }, + { + "name": "z", + "composite": { + "fields": [ + { + "name": "p", + "references": [ + { + "string": { + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + }, + "key_path": { + "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] } - ] + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", + "edges": [ + { + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} }, - "key_path": { + "edge": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + }, + "key_path": { + "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", + "edges": [ + { + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", + "src": { "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", "path": [ { @@ -118,325 +593,8 @@ } ] }, - "context": { - "key": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", - "edges": [ - { - "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", - "src": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } - } - ] - }, - "dst_arrow": ">" - } - ], - "primary": {}, - "value": {} - }, - "edge": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", - "src": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } - } - ] - }, - "dst_arrow": ">" - } - } - } - ] - } - ], - "edges": null - }, - "references": [ - { - "string": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - }, - "key_path": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "context": { - "key": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", - "edges": [ - { - "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", - "src": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } - } - ] - }, - "dst_arrow": ">" - } - ], - "primary": {}, - "value": {} - }, - "edge": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", - "src": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } - } - ] - }, - "dst_arrow": ">" - } - } - } - ] - }, - { - "name": "z", - "composite": { - "fields": [ - { - "name": "p", - "references": [ - { - "string": { - "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - }, - "key_path": { + "src_arrow": "", + "dst": { "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", "path": [ { @@ -463,455 +621,222 @@ } ] }, - "context": { - "key": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", - "edges": [ - { - "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", - "src": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } - } - ] - }, - "dst_arrow": ">" - } - ], - "primary": {}, - "value": {} - }, - "edge": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", - "src": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } - } - ] - }, - "dst_arrow": ">" - } - } + "dst_arrow": ">" } - ] - } - ], - "edges": null - }, - "references": [ - { - "string": { - "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] + ], + "primary": {}, + "value": {} }, - "key_path": { - "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } - } - ] - }, - "context": { - "key": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", - "edges": [ + "edge": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", + "path": [ { - "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", - "src": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", - "path": [ + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", + "value": [ { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } + "string": "x", + "raw_string": "x" } ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", - "path": [ + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", + "value": [ { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } + "string": "y", + "raw_string": "y" } ] - }, - "dst_arrow": ">" + } } - ], - "primary": {}, - "value": {} + ] }, - "edge": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", - "src": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] } - ] - }, - "dst_arrow": ">" - } + } + ] + }, + "dst_arrow": ">" } } - ] - } - ], - "edges": [ - { - "edge_id": { - "src_path": [ - "x", - "y" - ], - "src_arrow": false, - "dst_path": [ - "z", - "p" - ], - "dst_arrow": true, - "index": 0 - }, - "references": [ - { - "context": { - "key": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", - "edges": [ + } + ] + } + ], + "edges": [ + { + "edge_id": { + "src_path": [ + "x", + "y" + ], + "src_arrow": false, + "dst_path": [ + "z", + "p" + ], + "dst_arrow": true, + "index": 0 + }, + "references": [ + { + "context": { + "key": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", + "edges": [ + { + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", + "src": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", + "path": [ { - "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", - "src": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", - "path": [ + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", + "value": [ { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } + "string": "x", + "raw_string": "x" } ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", - "path": [ + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", + "value": [ { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } + "string": "y", + "raw_string": "y" } ] - }, - "dst_arrow": ">" + } } - ], - "primary": {}, - "value": {} + ] }, - "edge": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:10:10", - "src": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:4:4", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/nested.d2,0:6:6-0:10:10", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:7:7-0:8:8", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/nested.d2,0:9:9-0:10:10", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] } - ] - }, - "dst_arrow": ">" - } + } + ] + }, + "dst_arrow": ">" } } - ] - } - ] - } + } + ] + } + ] } diff --git a/testdata/d2ir/TestCompile/edges/root.exp.json b/testdata/d2ir/TestCompile/edges/root.exp.json index f8b7f0552..2dd443a34 100644 --- a/testdata/d2ir/TestCompile/edges/root.exp.json +++ b/testdata/d2ir/TestCompile/edges/root.exp.json @@ -1,12 +1,80 @@ { - "ast": { - "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", - "nodes": [ - { - "map_key": { - "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", - "edges": [ - { + "fields": [ + { + "name": "x", + "references": [ + { + "string": { + "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", "src": { "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", @@ -43,347 +111,226 @@ }, "dst_arrow": ">" } - ], - "primary": {}, - "value": {} + } } - } - ] - }, - "base": { - "fields": [ - { - "name": "x", - "references": [ - { - "string": { - "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" + ] + }, + { + "name": "y", + "references": [ + { + "string": { + "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + }, + "key_path": { + "range": "TestCompile/edges/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] } - ] - }, - "key_path": { - "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", - "path": [ + } + ] + }, + "context": { + "key": { + "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", + "edges": [ { - "unquoted_string": { - "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", - "value": [ + "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", + "path": [ { - "string": "x", - "raw_string": "x" + "unquoted_string": { + "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } } ] - } + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" } - ] + ], + "primary": {}, + "value": {} }, - "context": { - "key": { - "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", - "edges": [ + "edge": { + "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", + "path": [ { - "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", - "src": { - "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", - "path": [ + "unquoted_string": { + "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", + "value": [ { - "unquoted_string": { - "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } + "string": "x", + "raw_string": "x" } ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/root.d2,0:4:4-0:6:6", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "dst_arrow": ">" + } } - ], - "primary": {}, - "value": {} + ] }, - "edge": { - "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", - "src": { - "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/root.d2,0:4:4-0:6:6", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "dst_arrow": ">" - } + } + ] + }, + "dst_arrow": ">" } } - ] + } + ] + } + ], + "edges": [ + { + "edge_id": { + "src_path": [ + "x" + ], + "src_arrow": false, + "dst_path": [ + "y" + ], + "dst_arrow": true, + "index": 0 }, - { - "name": "y", - "references": [ - { - "string": { - "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", - "value": [ + "references": [ + { + "context": { + "key": { + "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", + "edges": [ { - "string": "y", - "raw_string": "y" - } - ] - }, - "key_path": { - "range": "TestCompile/edges/root.d2,0:4:4-0:6:6", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", - "value": [ + "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", + "path": [ { - "string": "y", - "raw_string": "y" + "unquoted_string": { + "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } } ] - } + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" } - ] + ], + "primary": {}, + "value": {} }, - "context": { - "key": { - "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", - "edges": [ + "edge": { + "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", + "path": [ { - "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", - "src": { - "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", - "path": [ + "unquoted_string": { + "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", + "value": [ { - "unquoted_string": { - "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } + "string": "x", + "raw_string": "x" } ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/root.d2,0:4:4-0:6:6", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "dst_arrow": ">" + } } - ], - "primary": {}, - "value": {} + ] }, - "edge": { - "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", - "src": { - "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/root.d2,0:4:4-0:6:6", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "dst_arrow": ">" - } + } + ] + }, + "dst_arrow": ">" } } - ] - } - ], - "edges": [ - { - "edge_id": { - "src_path": [ - "x" - ], - "src_arrow": false, - "dst_path": [ - "y" - ], - "dst_arrow": true, - "index": 0 - }, - "references": [ - { - "context": { - "key": { - "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", - "edges": [ - { - "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", - "src": { - "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/root.d2,0:4:4-0:6:6", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "dst_arrow": ">" - } - ], - "primary": {}, - "value": {} - }, - "edge": { - "range": "TestCompile/edges/root.d2,0:0:0-0:6:6", - "src": { - "range": "TestCompile/edges/root.d2,0:0:0-0:2:2", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/root.d2,0:4:4-0:6:6", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/root.d2,0:5:5-0:6:6", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "dst_arrow": ">" - } - } - } - ] - } - ] - } + } + ] + } + ] } diff --git a/testdata/d2ir/TestCompile/edges/underscore.exp.json b/testdata/d2ir/TestCompile/edges/underscore.exp.json index f248396d9..68ba516a2 100644 --- a/testdata/d2ir/TestCompile/edges/underscore.exp.json +++ b/testdata/d2ir/TestCompile/edges/underscore.exp.json @@ -1,33 +1,40 @@ { - "ast": { - "range": "TestCompile/edges/underscore.d2,0:0:0-0:15:15", - "nodes": [ - { - "map_key": { - "range": "TestCompile/edges/underscore.d2,0:0:0-0:15:15", - "key": { - "range": "TestCompile/edges/underscore.d2,0:0:0-0:1:1", - "path": [ + "fields": [ + { + "name": "p", + "composite": { + "fields": [ + { + "name": "z", + "references": [ { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:0:0-0:1:1", + "string": { + "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", "value": [ { - "string": "p", - "raw_string": "p" + "string": "z", + "raw_string": "z" } ] - } - } - ] - }, - "primary": {}, - "value": { - "map": { - "range": "TestCompile/edges/underscore.d2,0:3:3-0:14:14", - "nodes": [ - { - "map_key": { + }, + "key_path": { + "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "context": { + "key": { "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", "edges": [ { @@ -81,35 +88,254 @@ ], "primary": {}, "value": {} + }, + "edge": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", + "src": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", + "value": [ + { + "string": "_", + "raw_string": "_" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "dst_arrow": ">" } } - ] - } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/edges/underscore.d2,0:0:0-0:1:1", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + }, + "key_path": { + "range": "TestCompile/edges/underscore.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:0:0-0:1:1", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/edges/underscore.d2,0:0:0-0:15:15", + "key": { + "range": "TestCompile/edges/underscore.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:0:0-0:1:1", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/edges/underscore.d2,0:3:3-0:14:14", + "nodes": [ + { + "map_key": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", + "edges": [ + { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", + "src": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", + "value": [ + { + "string": "_", + "raw_string": "_" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + } + ] + } + } + }, + "edge": null } } - } - ] - }, - "base": { - "fields": [ - { - "name": "p", - "composite": { - "fields": [ - { - "name": "z", - "references": [ + ] + }, + { + "name": "x", + "references": [ + { + "string": { + "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", + "value": [ + { + "string": "_", + "raw_string": "_" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", + "edges": [ { - "string": { - "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", - "value": [ + "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", + "src": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", + "path": [ { - "string": "z", - "raw_string": "z" + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", + "value": [ + { + "string": "_", + "raw_string": "_" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } } ] }, - "key_path": { + "src_arrow": "", + "dst": { "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", "path": [ { @@ -125,507 +351,188 @@ } ] }, - "context": { - "key": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", - "edges": [ + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", + "src": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", + "value": [ { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", - "src": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", - "value": [ - { - "string": "_", - "raw_string": "_" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - } - ] - }, - "dst_arrow": ">" + "string": "_", + "raw_string": "_" } - ], - "primary": {}, - "value": {} - }, - "edge": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", - "src": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", - "value": [ - { - "string": "_", - "raw_string": "_" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - } - ] - }, - "dst_arrow": ">" + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] } } - } - ] - } - ], - "edges": null - }, - "references": [ - { - "string": { - "range": "TestCompile/edges/underscore.d2,0:0:0-0:1:1", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - }, - "key_path": { - "range": "TestCompile/edges/underscore.d2,0:0:0-0:1:1", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:0:0-0:1:1", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } - } - ] - }, - "context": { - "key": { - "range": "TestCompile/edges/underscore.d2,0:0:0-0:15:15", - "key": { - "range": "TestCompile/edges/underscore.d2,0:0:0-0:1:1", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:0:0-0:1:1", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } - } - ] - }, - "primary": {}, - "value": { - "map": { - "range": "TestCompile/edges/underscore.d2,0:3:3-0:14:14", - "nodes": [ - { - "map_key": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", - "edges": [ - { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", - "src": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", - "value": [ - { - "string": "_", - "raw_string": "_" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - } - ] - }, - "dst_arrow": ">" - } - ], - "primary": {}, - "value": {} - } - } - ] - } - } + ] }, - "edge": null + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "dst_arrow": ">" } } - ] + } + ] + } + ], + "edges": [ + { + "edge_id": { + "src_path": [ + "x" + ], + "src_arrow": false, + "dst_path": [ + "p", + "z" + ], + "dst_arrow": true, + "index": 0 }, - { - "name": "x", - "references": [ - { - "string": { - "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", - "value": [ + "references": [ + { + "context": { + "key": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", + "edges": [ { - "string": "x", - "raw_string": "x" - } - ] - }, - "key_path": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", - "value": [ + "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", + "src": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", + "path": [ { - "string": "_", - "raw_string": "_" + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", + "value": [ + { + "string": "_", + "raw_string": "_" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } } ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", - "value": [ + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", + "path": [ { - "string": "x", - "raw_string": "x" + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } } ] - } + }, + "dst_arrow": ">" } - ] + ], + "primary": {}, + "value": {} }, - "context": { - "key": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", - "edges": [ + "edge": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", + "src": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", + "path": [ { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", - "src": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", - "path": [ + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", + "value": [ { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", - "value": [ - { - "string": "_", - "raw_string": "_" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } + "string": "_", + "raw_string": "_" } ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", - "path": [ + } + }, + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", + "value": [ { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } + "string": "x", + "raw_string": "x" } ] - }, - "dst_arrow": ">" + } } - ], - "primary": {}, - "value": {} + ] }, - "edge": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", - "src": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", - "value": [ - { - "string": "_", - "raw_string": "_" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } + "src_arrow": "", + "dst": { + "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - } - ] - }, - "dst_arrow": ">" - } + } + ] + }, + "dst_arrow": ">" } } - ] - } - ], - "edges": [ - { - "edge_id": { - "src_path": [ - "x" - ], - "src_arrow": false, - "dst_path": [ - "p", - "z" - ], - "dst_arrow": true, - "index": 0 - }, - "references": [ - { - "context": { - "key": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", - "edges": [ - { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", - "src": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", - "value": [ - { - "string": "_", - "raw_string": "_" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - } - ] - }, - "dst_arrow": ">" - } - ], - "primary": {}, - "value": {} - }, - "edge": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:14:14", - "src": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:9:9", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:5:5-0:6:6", - "value": [ - { - "string": "_", - "raw_string": "_" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:7:7-0:8:8", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/edges/underscore.d2,0:11:11-0:14:14", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/edges/underscore.d2,0:12:12-0:13:13", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - } - ] - }, - "dst_arrow": ">" - } - } - } - ] - } - ] - } + } + ] + } + ] } diff --git a/testdata/d2ir/TestCompile/fields/array.exp.json b/testdata/d2ir/TestCompile/fields/array.exp.json index fa6329969..fbf42989a 100644 --- a/testdata/d2ir/TestCompile/fields/array.exp.json +++ b/testdata/d2ir/TestCompile/fields/array.exp.json @@ -1,11 +1,51 @@ { - "ast": { - "range": "TestCompile/fields/array.d2,0:0:0-0:12:12", - "nodes": [ - { - "map_key": { - "range": "TestCompile/fields/array.d2,0:0:0-0:12:12", - "key": { + "fields": [ + { + "name": "x", + "composite": { + "values": [ + { + "value": { + "range": "TestCompile/fields/array.d2,0:4:4-0:5:5", + "raw": "1", + "value": "1" + } + }, + { + "value": { + "range": "TestCompile/fields/array.d2,0:6:6-0:7:7", + "raw": "2", + "value": "2" + } + }, + { + "value": { + "range": "TestCompile/fields/array.d2,0:8:8-0:9:9", + "raw": "3", + "value": "3" + } + }, + { + "value": { + "range": "TestCompile/fields/array.d2,0:10:10-0:11:11", + "raw": "4", + "value": "4" + } + } + ] + }, + "references": [ + { + "string": { + "range": "TestCompile/fields/array.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { "range": "TestCompile/fields/array.d2,0:0:0-0:1:1", "path": [ { @@ -21,171 +61,67 @@ } ] }, - "primary": {}, - "value": { - "array": { - "range": "TestCompile/fields/array.d2,0:3:3-0:11:11", - "nodes": [ - { - "number": { - "range": "TestCompile/fields/array.d2,0:4:4-0:5:5", - "raw": "1", - "value": "1" - } - }, - { - "number": { - "range": "TestCompile/fields/array.d2,0:6:6-0:7:7", - "raw": "2", - "value": "2" - } - }, - { - "number": { - "range": "TestCompile/fields/array.d2,0:8:8-0:9:9", - "raw": "3", - "value": "3" - } - }, - { - "number": { - "range": "TestCompile/fields/array.d2,0:10:10-0:11:11", - "raw": "4", - "value": "4" - } - } - ] - } - } - } - } - ] - }, - "base": { - "fields": [ - { - "name": "x", - "composite": { - "values": [ - { - "value": { - "range": "TestCompile/fields/array.d2,0:4:4-0:5:5", - "raw": "1", - "value": "1" - } - }, - { - "value": { - "range": "TestCompile/fields/array.d2,0:6:6-0:7:7", - "raw": "2", - "value": "2" - } - }, - { - "value": { - "range": "TestCompile/fields/array.d2,0:8:8-0:9:9", - "raw": "3", - "value": "3" - } - }, - { - "value": { - "range": "TestCompile/fields/array.d2,0:10:10-0:11:11", - "raw": "4", - "value": "4" - } - } - ] - }, - "references": [ - { - "string": { - "range": "TestCompile/fields/array.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - }, - "key_path": { - "range": "TestCompile/fields/array.d2,0:0:0-0:1:1", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/array.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - } - ] - }, - "context": { + "context": { + "key": { + "range": "TestCompile/fields/array.d2,0:0:0-0:12:12", "key": { - "range": "TestCompile/fields/array.d2,0:0:0-0:12:12", - "key": { - "range": "TestCompile/fields/array.d2,0:0:0-0:1:1", - "path": [ + "range": "TestCompile/fields/array.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/array.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "array": { + "range": "TestCompile/fields/array.d2,0:3:3-0:11:11", + "nodes": [ { - "unquoted_string": { - "range": "TestCompile/fields/array.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] + "number": { + "range": "TestCompile/fields/array.d2,0:4:4-0:5:5", + "raw": "1", + "value": "1" + } + }, + { + "number": { + "range": "TestCompile/fields/array.d2,0:6:6-0:7:7", + "raw": "2", + "value": "2" + } + }, + { + "number": { + "range": "TestCompile/fields/array.d2,0:8:8-0:9:9", + "raw": "3", + "value": "3" + } + }, + { + "number": { + "range": "TestCompile/fields/array.d2,0:10:10-0:11:11", + "raw": "4", + "value": "4" } } ] - }, - "primary": {}, - "value": { - "array": { - "range": "TestCompile/fields/array.d2,0:3:3-0:11:11", - "nodes": [ - { - "number": { - "range": "TestCompile/fields/array.d2,0:4:4-0:5:5", - "raw": "1", - "value": "1" - } - }, - { - "number": { - "range": "TestCompile/fields/array.d2,0:6:6-0:7:7", - "raw": "2", - "value": "2" - } - }, - { - "number": { - "range": "TestCompile/fields/array.d2,0:8:8-0:9:9", - "raw": "3", - "value": "3" - } - }, - { - "number": { - "range": "TestCompile/fields/array.d2,0:10:10-0:11:11", - "raw": "4", - "value": "4" - } - } - ] - } } - }, - "edge": null - } + } + }, + "edge": null } - ] - } - ], - "edges": null - } + } + ] + } + ], + "edges": null } diff --git a/testdata/d2ir/TestCompile/fields/label.exp.json b/testdata/d2ir/TestCompile/fields/label.exp.json index 0d90b55dc..6098e519f 100644 --- a/testdata/d2ir/TestCompile/fields/label.exp.json +++ b/testdata/d2ir/TestCompile/fields/label.exp.json @@ -1,11 +1,30 @@ { - "ast": { - "range": "TestCompile/fields/label.d2,0:0:0-0:6:6", - "nodes": [ - { - "map_key": { - "range": "TestCompile/fields/label.d2,0:0:0-0:6:6", - "key": { + "fields": [ + { + "name": "x", + "primary": { + "value": { + "range": "TestCompile/fields/label.d2,0:3:3-0:6:6", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + }, + "references": [ + { + "string": { + "range": "TestCompile/fields/label.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { "range": "TestCompile/fields/label.d2,0:0:0-0:1:1", "path": [ { @@ -21,102 +40,43 @@ } ] }, - "primary": {}, - "value": { - "unquoted_string": { - "range": "TestCompile/fields/label.d2,0:3:3-0:6:6", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] - } - } - } - } - ] - }, - "base": { - "fields": [ - { - "name": "x", - "primary": { - "value": { - "range": "TestCompile/fields/label.d2,0:3:3-0:6:6", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] - } - }, - "references": [ - { - "string": { - "range": "TestCompile/fields/label.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - }, - "key_path": { - "range": "TestCompile/fields/label.d2,0:0:0-0:1:1", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/label.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - } - ] - }, - "context": { + "context": { + "key": { + "range": "TestCompile/fields/label.d2,0:0:0-0:6:6", "key": { - "range": "TestCompile/fields/label.d2,0:0:0-0:6:6", - "key": { - "range": "TestCompile/fields/label.d2,0:0:0-0:1:1", - "path": [ + "range": "TestCompile/fields/label.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/label.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/fields/label.d2,0:3:3-0:6:6", + "value": [ { - "unquoted_string": { - "range": "TestCompile/fields/label.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } + "string": "yes", + "raw_string": "yes" } ] - }, - "primary": {}, - "value": { - "unquoted_string": { - "range": "TestCompile/fields/label.d2,0:3:3-0:6:6", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] - } } - }, - "edge": null - } + } + }, + "edge": null } - ] - } - ], - "edges": null - } + } + ] + } + ], + "edges": null } diff --git a/testdata/d2ir/TestCompile/fields/nested.exp.json b/testdata/d2ir/TestCompile/fields/nested.exp.json index c9828d235..1bd7e29b6 100644 --- a/testdata/d2ir/TestCompile/fields/nested.exp.json +++ b/testdata/d2ir/TestCompile/fields/nested.exp.json @@ -1,26 +1,25 @@ { - "ast": { - "range": "TestCompile/fields/nested.d2,0:0:0-0:8:8", - "nodes": [ - { - "map_key": { - "range": "TestCompile/fields/nested.d2,0:0:0-0:8:8", - "key": { - "range": "TestCompile/fields/nested.d2,0:0:0-0:3:3", - "path": [ + "fields": [ + { + "name": "x", + "composite": { + "fields": [ + { + "name": "y", + "primary": { + "value": { + "range": "TestCompile/fields/nested.d2,0:5:5-0:8:8", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + }, + "references": [ { - "unquoted_string": { - "range": "TestCompile/fields/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - }, - { - "unquoted_string": { + "string": { "range": "TestCompile/fields/nested.d2,0:2:2-0:3:3", "value": [ { @@ -28,176 +27,8 @@ "raw_string": "y" } ] - } - } - ] - }, - "primary": {}, - "value": { - "unquoted_string": { - "range": "TestCompile/fields/nested.d2,0:5:5-0:8:8", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] - } - } - } - } - ] - }, - "base": { - "fields": [ - { - "name": "x", - "composite": { - "fields": [ - { - "name": "y", - "primary": { - "value": { - "range": "TestCompile/fields/nested.d2,0:5:5-0:8:8", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] - } - }, - "references": [ - { - "string": { - "range": "TestCompile/fields/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - }, - "key_path": { - "range": "TestCompile/fields/nested.d2,0:0:0-0:3:3", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/fields/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "context": { - "key": { - "range": "TestCompile/fields/nested.d2,0:0:0-0:8:8", - "key": { - "range": "TestCompile/fields/nested.d2,0:0:0-0:3:3", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/fields/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "primary": {}, - "value": { - "unquoted_string": { - "range": "TestCompile/fields/nested.d2,0:5:5-0:8:8", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] - } - } - }, - "edge": null - } - } - ] - } - ], - "edges": null - }, - "references": [ - { - "string": { - "range": "TestCompile/fields/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - }, - "key_path": { - "range": "TestCompile/fields/nested.d2,0:0:0-0:3:3", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } }, - { - "unquoted_string": { - "range": "TestCompile/fields/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "context": { - "key": { - "range": "TestCompile/fields/nested.d2,0:0:0-0:8:8", - "key": { + "key_path": { "range": "TestCompile/fields/nested.d2,0:0:0-0:3:3", "path": [ { @@ -224,25 +55,143 @@ } ] }, - "primary": {}, - "value": { - "unquoted_string": { - "range": "TestCompile/fields/nested.d2,0:5:5-0:8:8", - "value": [ - { - "string": "yes", - "raw_string": "yes" + "context": { + "key": { + "range": "TestCompile/fields/nested.d2,0:0:0-0:8:8", + "key": { + "range": "TestCompile/fields/nested.d2,0:0:0-0:3:3", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/fields/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/fields/nested.d2,0:5:5-0:8:8", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] } - ] - } + } + }, + "edge": null + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/fields/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "TestCompile/fields/nested.d2,0:0:0-0:3:3", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] } }, - "edge": null - } + { + "unquoted_string": { + "range": "TestCompile/fields/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/fields/nested.d2,0:0:0-0:8:8", + "key": { + "range": "TestCompile/fields/nested.d2,0:0:0-0:3:3", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/fields/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "TestCompile/fields/nested.d2,0:5:5-0:8:8", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + } + }, + "edge": null } - ] - } - ], - "edges": null - } + } + ] + } + ], + "edges": null } diff --git a/testdata/d2ir/TestCompile/fields/primary/nested.exp.json b/testdata/d2ir/TestCompile/fields/primary/nested.exp.json index f7f4069c8..e6085c395 100644 --- a/testdata/d2ir/TestCompile/fields/primary/nested.exp.json +++ b/testdata/d2ir/TestCompile/fields/primary/nested.exp.json @@ -1,26 +1,86 @@ { - "ast": { - "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:17:17", - "nodes": [ - { - "map_key": { - "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:17:17", - "key": { - "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:3:3", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:1:1", - "value": [ + "fields": [ + { + "name": "x", + "composite": { + "fields": [ + { + "name": "y", + "primary": { + "value": { + "range": "TestCompile/fields/primary/nested.d2,0:5:5-0:8:8", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + }, + "composite": { + "fields": [ + { + "name": "pqrs", + "references": [ { - "string": "x", - "raw_string": "x" + "string": { + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:15:15", + "value": [ + { + "string": "pqrs", + "raw_string": "pqrs" + } + ] + }, + "key_path": { + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:15:15", + "value": [ + { + "string": "pqrs", + "raw_string": "pqrs" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", + "key": { + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:15:15", + "value": [ + { + "string": "pqrs", + "raw_string": "pqrs" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null + } } ] } - }, + ], + "edges": null + }, + "references": [ { - "unquoted_string": { + "string": { "range": "TestCompile/fields/primary/nested.d2,0:2:2-0:3:3", "value": [ { @@ -28,295 +88,8 @@ "raw_string": "y" } ] - } - } - ] - }, - "primary": { - "unquoted_string": { - "range": "TestCompile/fields/primary/nested.d2,0:5:5-0:8:8", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] - } - }, - "value": { - "map": { - "range": "TestCompile/fields/primary/nested.d2,0:9:9-0:16:16", - "nodes": [ - { - "map_key": { - "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", - "key": { - "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:15:15", - "value": [ - { - "string": "pqrs", - "raw_string": "pqrs" - } - ] - } - } - ] - }, - "primary": {}, - "value": {} - } - } - ] - } - } - } - } - ] - }, - "base": { - "fields": [ - { - "name": "x", - "composite": { - "fields": [ - { - "name": "y", - "primary": { - "value": { - "range": "TestCompile/fields/primary/nested.d2,0:5:5-0:8:8", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] - } - }, - "composite": { - "fields": [ - { - "name": "pqrs", - "references": [ - { - "string": { - "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:15:15", - "value": [ - { - "string": "pqrs", - "raw_string": "pqrs" - } - ] - }, - "key_path": { - "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:15:15", - "value": [ - { - "string": "pqrs", - "raw_string": "pqrs" - } - ] - } - } - ] - }, - "context": { - "key": { - "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", - "key": { - "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:15:15", - "value": [ - { - "string": "pqrs", - "raw_string": "pqrs" - } - ] - } - } - ] - }, - "primary": {}, - "value": {} - }, - "edge": null - } - } - ] - } - ], - "edges": null - }, - "references": [ - { - "string": { - "range": "TestCompile/fields/primary/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - }, - "key_path": { - "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:3:3", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/fields/primary/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "context": { - "key": { - "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:17:17", - "key": { - "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:3:3", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/fields/primary/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "primary": { - "unquoted_string": { - "range": "TestCompile/fields/primary/nested.d2,0:5:5-0:8:8", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] - } - }, - "value": { - "map": { - "range": "TestCompile/fields/primary/nested.d2,0:9:9-0:16:16", - "nodes": [ - { - "map_key": { - "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", - "key": { - "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:15:15", - "value": [ - { - "string": "pqrs", - "raw_string": "pqrs" - } - ] - } - } - ] - }, - "primary": {}, - "value": {} - } - } - ] - } - } - }, - "edge": null - } - } - ] - } - ], - "edges": null - }, - "references": [ - { - "string": { - "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - }, - "key_path": { - "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:3:3", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } }, - { - "unquoted_string": { - "range": "TestCompile/fields/primary/nested.d2,0:2:2-0:3:3", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "context": { - "key": { - "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:17:17", - "key": { + "key_path": { "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:3:3", "path": [ { @@ -343,54 +116,201 @@ } ] }, - "primary": { - "unquoted_string": { - "range": "TestCompile/fields/primary/nested.d2,0:5:5-0:8:8", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] - } - }, - "value": { - "map": { - "range": "TestCompile/fields/primary/nested.d2,0:9:9-0:16:16", - "nodes": [ - { - "map_key": { - "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", - "key": { - "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", - "path": [ + "context": { + "key": { + "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:17:17", + "key": { + "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:3:3", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:1:1", + "value": [ { - "unquoted_string": { - "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:15:15", - "value": [ - { - "string": "pqrs", - "raw_string": "pqrs" - } - ] - } + "string": "x", + "raw_string": "x" } ] - }, - "primary": {}, - "value": {} + } + }, + { + "unquoted_string": { + "range": "TestCompile/fields/primary/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } } + ] + }, + "primary": { + "unquoted_string": { + "range": "TestCompile/fields/primary/nested.d2,0:5:5-0:8:8", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] } - ] - } + }, + "value": { + "map": { + "range": "TestCompile/fields/primary/nested.d2,0:9:9-0:16:16", + "nodes": [ + { + "map_key": { + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", + "key": { + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:15:15", + "value": [ + { + "string": "pqrs", + "raw_string": "pqrs" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + }, + "edge": null + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:3:3", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] } }, - "edge": null - } + { + "unquoted_string": { + "range": "TestCompile/fields/primary/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:17:17", + "key": { + "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:3:3", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/primary/nested.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/fields/primary/nested.d2,0:2:2-0:3:3", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "primary": { + "unquoted_string": { + "range": "TestCompile/fields/primary/nested.d2,0:5:5-0:8:8", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + }, + "value": { + "map": { + "range": "TestCompile/fields/primary/nested.d2,0:9:9-0:16:16", + "nodes": [ + { + "map_key": { + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", + "key": { + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:16:16", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/primary/nested.d2,0:11:11-0:15:15", + "value": [ + { + "string": "pqrs", + "raw_string": "pqrs" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + } + } + ] + } + } + }, + "edge": null } - ] - } - ], - "edges": null - } + } + ] + } + ], + "edges": null } diff --git a/testdata/d2ir/TestCompile/fields/primary/root.exp.json b/testdata/d2ir/TestCompile/fields/primary/root.exp.json index 1381cf544..e44960cf1 100644 --- a/testdata/d2ir/TestCompile/fields/primary/root.exp.json +++ b/testdata/d2ir/TestCompile/fields/primary/root.exp.json @@ -1,43 +1,51 @@ { - "ast": { - "range": "TestCompile/fields/primary/root.d2,0:0:0-0:15:15", - "nodes": [ - { - "map_key": { - "range": "TestCompile/fields/primary/root.d2,0:0:0-0:15:15", - "key": { - "range": "TestCompile/fields/primary/root.d2,0:0:0-0:1:1", - "path": [ + "fields": [ + { + "name": "x", + "primary": { + "value": { + "range": "TestCompile/fields/primary/root.d2,0:3:3-0:6:6", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + }, + "composite": { + "fields": [ + { + "name": "pqrs", + "references": [ { - "unquoted_string": { - "range": "TestCompile/fields/primary/root.d2,0:0:0-0:1:1", + "string": { + "range": "TestCompile/fields/primary/root.d2,0:9:9-0:13:13", "value": [ { - "string": "x", - "raw_string": "x" + "string": "pqrs", + "raw_string": "pqrs" } ] - } - } - ] - }, - "primary": { - "unquoted_string": { - "range": "TestCompile/fields/primary/root.d2,0:3:3-0:6:6", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] - } - }, - "value": { - "map": { - "range": "TestCompile/fields/primary/root.d2,0:7:7-0:14:14", - "nodes": [ - { - "map_key": { + }, + "key_path": { + "range": "TestCompile/fields/primary/root.d2,0:9:9-0:14:14", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/primary/root.d2,0:9:9-0:13:13", + "value": [ + { + "string": "pqrs", + "raw_string": "pqrs" + } + ] + } + } + ] + }, + "context": { + "key": { "range": "TestCompile/fields/primary/root.d2,0:9:9-0:14:14", "key": { "range": "TestCompile/fields/primary/root.d2,0:9:9-0:14:14", @@ -57,185 +65,108 @@ }, "primary": {}, "value": {} - } + }, + "edge": null } - ] - } - } - } - } - ] - }, - "base": { - "fields": [ - { - "name": "x", - "primary": { - "value": { - "range": "TestCompile/fields/primary/root.d2,0:3:3-0:6:6", - "value": [ - { - "string": "yes", - "raw_string": "yes" } ] } - }, - "composite": { - "fields": [ - { - "name": "pqrs", - "references": [ - { - "string": { - "range": "TestCompile/fields/primary/root.d2,0:9:9-0:13:13", - "value": [ - { - "string": "pqrs", - "raw_string": "pqrs" - } - ] - }, - "key_path": { - "range": "TestCompile/fields/primary/root.d2,0:9:9-0:14:14", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/primary/root.d2,0:9:9-0:13:13", - "value": [ + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/fields/primary/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "TestCompile/fields/primary/root.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/primary/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/fields/primary/root.d2,0:0:0-0:15:15", + "key": { + "range": "TestCompile/fields/primary/root.d2,0:0:0-0:1:1", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/primary/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "primary": { + "unquoted_string": { + "range": "TestCompile/fields/primary/root.d2,0:3:3-0:6:6", + "value": [ + { + "string": "yes", + "raw_string": "yes" + } + ] + } + }, + "value": { + "map": { + "range": "TestCompile/fields/primary/root.d2,0:7:7-0:14:14", + "nodes": [ + { + "map_key": { + "range": "TestCompile/fields/primary/root.d2,0:9:9-0:14:14", + "key": { + "range": "TestCompile/fields/primary/root.d2,0:9:9-0:14:14", + "path": [ { - "string": "pqrs", - "raw_string": "pqrs" + "unquoted_string": { + "range": "TestCompile/fields/primary/root.d2,0:9:9-0:13:13", + "value": [ + { + "string": "pqrs", + "raw_string": "pqrs" + } + ] + } } ] - } - } - ] - }, - "context": { - "key": { - "range": "TestCompile/fields/primary/root.d2,0:9:9-0:14:14", - "key": { - "range": "TestCompile/fields/primary/root.d2,0:9:9-0:14:14", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/primary/root.d2,0:9:9-0:13:13", - "value": [ - { - "string": "pqrs", - "raw_string": "pqrs" - } - ] - } - } - ] - }, - "primary": {}, - "value": {} - }, - "edge": null - } - } - ] - } - ], - "edges": null - }, - "references": [ - { - "string": { - "range": "TestCompile/fields/primary/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - }, - "key_path": { - "range": "TestCompile/fields/primary/root.d2,0:0:0-0:1:1", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/primary/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - } - ] - }, - "context": { - "key": { - "range": "TestCompile/fields/primary/root.d2,0:0:0-0:15:15", - "key": { - "range": "TestCompile/fields/primary/root.d2,0:0:0-0:1:1", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/primary/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] + }, + "primary": {}, + "value": {} } } ] - }, - "primary": { - "unquoted_string": { - "range": "TestCompile/fields/primary/root.d2,0:3:3-0:6:6", - "value": [ - { - "string": "yes", - "raw_string": "yes" - } - ] - } - }, - "value": { - "map": { - "range": "TestCompile/fields/primary/root.d2,0:7:7-0:14:14", - "nodes": [ - { - "map_key": { - "range": "TestCompile/fields/primary/root.d2,0:9:9-0:14:14", - "key": { - "range": "TestCompile/fields/primary/root.d2,0:9:9-0:14:14", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/primary/root.d2,0:9:9-0:13:13", - "value": [ - { - "string": "pqrs", - "raw_string": "pqrs" - } - ] - } - } - ] - }, - "primary": {}, - "value": {} - } - } - ] - } } - }, - "edge": null - } + } + }, + "edge": null } - ] - } - ], - "edges": null - } + } + ] + } + ], + "edges": null } diff --git a/testdata/d2ir/TestCompile/fields/root.exp.json b/testdata/d2ir/TestCompile/fields/root.exp.json index a76d04522..1d204d613 100644 --- a/testdata/d2ir/TestCompile/fields/root.exp.json +++ b/testdata/d2ir/TestCompile/fields/root.exp.json @@ -1,11 +1,19 @@ { - "ast": { - "range": "TestCompile/fields/root.d2,0:0:0-0:1:1", - "nodes": [ - { - "map_key": { - "range": "TestCompile/fields/root.d2,0:0:0-0:1:1", - "key": { + "fields": [ + { + "name": "x", + "references": [ + { + "string": { + "range": "TestCompile/fields/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { "range": "TestCompile/fields/root.d2,0:0:0-0:1:1", "path": [ { @@ -21,71 +29,33 @@ } ] }, - "primary": {}, - "value": {} - } - } - ] - }, - "base": { - "fields": [ - { - "name": "x", - "references": [ - { - "string": { + "context": { + "key": { "range": "TestCompile/fields/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - }, - "key_path": { - "range": "TestCompile/fields/root.d2,0:0:0-0:1:1", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - } - ] - }, - "context": { "key": { "range": "TestCompile/fields/root.d2,0:0:0-0:1:1", - "key": { - "range": "TestCompile/fields/root.d2,0:0:0-0:1:1", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/fields/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } + "path": [ + { + "unquoted_string": { + "range": "TestCompile/fields/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] } - ] - }, - "primary": {}, - "value": {} + } + ] }, - "edge": null - } + "primary": {}, + "value": {} + }, + "edge": null } - ] - } - ], - "edges": null - } + } + ] + } + ], + "edges": null } diff --git a/testdata/d2ir/TestCompile/layer/root.exp.json b/testdata/d2ir/TestCompile/layer/root.exp.json index 6d6daa531..e3e50b414 100644 --- a/testdata/d2ir/TestCompile/layer/root.exp.json +++ b/testdata/d2ir/TestCompile/layer/root.exp.json @@ -1,12 +1,80 @@ { - "ast": { - "range": "TestCompile/layer/root.d2,0:0:0-3:1:36", - "nodes": [ - { - "map_key": { - "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", - "edges": [ - { + "fields": [ + { + "name": "x", + "references": [ + { + "string": { + "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + }, + "key_path": { + "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "edges": [ + { + "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", "src": { "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", @@ -43,37 +111,475 @@ }, "dst_arrow": ">" } - ], - "primary": {}, - "value": {} + } } - }, - { - "map_key": { - "range": "TestCompile/layer/root.d2,1:0:7-3:1:36", - "key": { - "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", + ] + }, + { + "name": "y", + "references": [ + { + "string": { + "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + }, + "key_path": { + "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", "path": [ { "unquoted_string": { - "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", + "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", "value": [ { - "string": "layers", - "raw_string": "layers" + "string": "y", + "raw_string": "y" } ] } } ] }, - "primary": {}, - "value": { - "map": { - "range": "TestCompile/layer/root.d2,1:8:15-3:0:35", - "nodes": [ + "context": { + "key": { + "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "edges": [ { - "map_key": { + "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + }, + "edge": { + "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + } + } + ] + }, + { + "name": "layers", + "composite": { + "fields": [ + { + "name": "bingo", + "composite": { + "fields": [ + { + "name": "p", + "composite": { + "fields": [ + { + "name": "q", + "composite": { + "fields": [ + { + "name": "z", + "references": [ + { + "string": { + "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + }, + "key_path": { + "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "key": { + "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + }, + "key_path": { + "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "key": { + "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + }, + "key_path": { + "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "key": { + "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", + "value": [ + { + "string": "p", + "raw_string": "p" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", + "value": [ + { + "string": "q", + "raw_string": "q" + } + ] + } + }, + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", + "value": [ + { + "string": "z", + "raw_string": "z" + } + ] + } + } + ] + }, + "primary": {}, + "value": {} + }, + "edge": null + } + } + ] + } + ], + "edges": null + }, + "references": [ + { + "string": { + "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", + "value": [ + { + "string": "bingo", + "raw_string": "bingo" + } + ] + }, + "key_path": { + "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", + "value": [ + { + "string": "bingo", + "raw_string": "bingo" + } + ] + } + } + ] + }, + "context": { + "key": { "range": "TestCompile/layer/root.d2,2:1:18-2:17:34", "key": { "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", @@ -144,417 +650,92 @@ ] } } - } + }, + "edge": null } - ] - } - } - } - } - ] - }, - "base": { - "fields": [ - { - "name": "x", - "references": [ - { - "string": { - "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - }, - "key_path": { - "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - } - ] - }, - "context": { - "key": { - "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", - "edges": [ - { - "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", - "src": { - "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "dst_arrow": ">" - } - ], - "primary": {}, - "value": {} - }, - "edge": { - "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", - "src": { - "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "dst_arrow": ">" } - } + ] } - ] + ], + "edges": null }, - { - "name": "y", - "references": [ - { - "string": { - "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - }, - "key_path": { - "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "context": { - "key": { - "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", - "edges": [ - { - "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", - "src": { - "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "dst_arrow": ">" - } - ], - "primary": {}, - "value": {} - }, - "edge": { - "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", - "src": { - "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "dst_arrow": ">" + "references": [ + { + "string": { + "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", + "value": [ + { + "string": "layers", + "raw_string": "layers" } - } - } - ] - }, - { - "name": "layers", - "composite": { - "fields": [ - { - "name": "bingo", - "composite": { - "fields": [ + ] + }, + "key_path": { + "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", + "value": [ + { + "string": "layers", + "raw_string": "layers" + } + ] + } + } + ] + }, + "context": { + "key": { + "range": "TestCompile/layer/root.d2,1:0:7-3:1:36", + "key": { + "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", + "path": [ { - "name": "p", - "composite": { - "fields": [ + "unquoted_string": { + "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", + "value": [ { - "name": "q", - "composite": { - "fields": [ - { - "name": "z", - "references": [ - { - "string": { - "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - }, - "key_path": { - "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", - "value": [ - { - "string": "q", - "raw_string": "q" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - } - ] - }, - "context": { - "key": { - "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", - "key": { - "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", - "value": [ - { - "string": "q", - "raw_string": "q" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - } - ] - }, - "primary": {}, - "value": {} - }, - "edge": null - } - } - ] - } - ], - "edges": null - }, - "references": [ + "string": "layers", + "raw_string": "layers" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/layer/root.d2,1:8:15-3:0:35", + "nodes": [ + { + "map_key": { + "range": "TestCompile/layer/root.d2,2:1:18-2:17:34", + "key": { + "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", + "path": [ { - "string": { - "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", + "unquoted_string": { + "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", "value": [ { - "string": "q", - "raw_string": "q" + "string": "bingo", + "raw_string": "bingo" } ] - }, - "key_path": { - "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", - "value": [ - { - "string": "q", - "raw_string": "q" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - } - ] - }, - "context": { - "key": { + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "TestCompile/layer/root.d2,2:8:25-2:16:33", + "nodes": [ + { + "map_key": { "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", "key": { "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", @@ -596,460 +777,123 @@ }, "primary": {}, "value": {} - }, - "edge": null - } - } - ] - } - ], - "edges": null - }, - "references": [ - { - "string": { - "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - }, - "key_path": { - "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", - "value": [ - { - "string": "q", - "raw_string": "q" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - } - ] - }, - "context": { - "key": { - "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", - "key": { - "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", - "value": [ - { - "string": "q", - "raw_string": "q" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } } - ] - }, - "primary": {}, - "value": {} - }, - "edge": null + } + ] + } } } - ] - } - ], - "edges": null - }, - "references": [ + } + ] + } + } + }, + "edge": null + } + } + ] + } + ], + "edges": [ + { + "edge_id": { + "src_path": [ + "x" + ], + "src_arrow": false, + "dst_path": [ + "y" + ], + "dst_arrow": true, + "index": 0 + }, + "references": [ + { + "context": { + "key": { + "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "edges": [ { - "string": { - "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", - "value": [ - { - "string": "bingo", - "raw_string": "bingo" - } - ] - }, - "key_path": { - "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", + "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", "path": [ { "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", + "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", "value": [ { - "string": "bingo", - "raw_string": "bingo" + "string": "x", + "raw_string": "x" } ] } } ] }, - "context": { - "key": { - "range": "TestCompile/layer/root.d2,2:1:18-2:17:34", - "key": { - "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", - "value": [ - { - "string": "bingo", - "raw_string": "bingo" - } - ] - } - } - ] - }, - "primary": {}, - "value": { - "map": { - "range": "TestCompile/layer/root.d2,2:8:25-2:16:33", - "nodes": [ + "src_arrow": "", + "dst": { + "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", + "value": [ { - "map_key": { - "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", - "key": { - "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", - "value": [ - { - "string": "q", - "raw_string": "q" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - } - ] - }, - "primary": {}, - "value": {} - } + "string": "y", + "raw_string": "y" } ] } } - }, - "edge": null - } - } - ] - } - ], - "edges": null - }, - "references": [ - { - "string": { - "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", - "value": [ - { - "string": "layers", - "raw_string": "layers" - } - ] - }, - "key_path": { - "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", - "value": [ - { - "string": "layers", - "raw_string": "layers" - } ] - } + }, + "dst_arrow": ">" } - ] + ], + "primary": {}, + "value": {} }, - "context": { - "key": { - "range": "TestCompile/layer/root.d2,1:0:7-3:1:36", - "key": { - "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,1:0:7-1:6:13", - "value": [ - { - "string": "layers", - "raw_string": "layers" - } - ] - } - } - ] - }, - "primary": {}, - "value": { - "map": { - "range": "TestCompile/layer/root.d2,1:8:15-3:0:35", - "nodes": [ - { - "map_key": { - "range": "TestCompile/layer/root.d2,2:1:18-2:17:34", - "key": { - "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:1:18-2:6:23", - "value": [ - { - "string": "bingo", - "raw_string": "bingo" - } - ] - } - } - ] - }, - "primary": {}, - "value": { - "map": { - "range": "TestCompile/layer/root.d2,2:8:25-2:16:33", - "nodes": [ - { - "map_key": { - "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", - "key": { - "range": "TestCompile/layer/root.d2,2:10:27-2:16:33", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:10:27-2:11:28", - "value": [ - { - "string": "p", - "raw_string": "p" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:12:29-2:13:30", - "value": [ - { - "string": "q", - "raw_string": "q" - } - ] - } - }, - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,2:14:31-2:15:32", - "value": [ - { - "string": "z", - "raw_string": "z" - } - ] - } - } - ] - }, - "primary": {}, - "value": {} - } - } - ] - } - } - } - } - ] - } - } - }, - "edge": null - } - } - ] - } - ], - "edges": [ - { - "edge_id": { - "src_path": [ - "x" - ], - "src_arrow": false, - "dst_path": [ - "y" - ], - "dst_arrow": true, - "index": 0 - }, - "references": [ - { - "context": { - "key": { - "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", - "edges": [ + "edge": { + "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", + "src": { + "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", + "path": [ { - "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", - "src": { - "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", - "path": [ + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", + "value": [ { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } + "string": "x", + "raw_string": "x" } ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "dst_arrow": ">" + } } - ], - "primary": {}, - "value": {} + ] }, - "edge": { - "range": "TestCompile/layer/root.d2,0:0:0-0:6:6", - "src": { - "range": "TestCompile/layer/root.d2,0:0:0-0:2:2", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:0:0-0:1:1", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } + "src_arrow": "", + "dst": { + "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", + "path": [ + { + "unquoted_string": { + "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] } - ] - }, - "src_arrow": "", - "dst": { - "range": "TestCompile/layer/root.d2,0:4:4-0:6:6", - "path": [ - { - "unquoted_string": { - "range": "TestCompile/layer/root.d2,0:5:5-0:6:6", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "dst_arrow": ">" - } + } + ] + }, + "dst_arrow": ">" } } - ] - } - ] - } + } + ] + } + ] }