Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/core: extract sorted features from Vertex
Given: ``` a: { z: 4 y: 3 } b: { x: 2 w: 1 } ``` I want the following behaviour: ``` c1: a & b c2: b & a ``` c1 and c2 should have fields in the same order. I.e. order of arguments to unification does not matter (essential for associativity). ``` d1: { a b } d2: { b a } ``` d1 and d2 should not have fields in the same order. I.e. order of embedding dictates order of fields in output. ``` e1: { zz: 14 a&b t: 13 } e2: { zz: 14 b&a t: 13 } ``` e1 and e2 should have fields in the same order, both with zz first and t last. This means we need to understand the embedding of expressions, We also need to be able to add edges between nodes from plain fields and nodes from embedded structs. ``` f: { g: b | a h: a | b } ``` The expansion of the values of g and h should match the order of the branches in the disjunctions. ``` z: d: _ z: c: _ z: { b: _ f: _ } ``` Within z, the output fields should be ordered d, c, b, f. In order to do this, I need to modify StructInfo so that it contains a pointer back to the declaration from which it came. This is sufficient to be able to construct the graph correctly, by traversing the vertex structs themselves in a topological order. This change only supports evalv3. Support for evalv2 is added in the next commit. Signed-off-by: Matthew Sackman <[email protected]> Change-Id: Ic47d380f25b74f7633475091c34ff193dc547e01 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1202400 Reviewed-by: Marcel van Lohuizen <[email protected]> Unity-Result: CUE porcuepine <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
- Loading branch information