-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/core/export: sort conjuncts in binary expressions
This is to help reduce diffs in Unity. It sorts both the values in adt.Conjunction as well as adt.BinaryExpr. In the latter case, it first flattens the three, then sorts, then rebuilds the binary tree. Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I9fa6b91816a15c3a6cfa78c25b34851bd791011e Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1205862 Reviewed-by: Daniel Martí <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
- Loading branch information
Showing
9 changed files
with
435 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,258 @@ | ||
-- in.cue -- | ||
import "list" | ||
|
||
basicFirst: { | ||
sort: Z & {a: _x} // string first | ||
_x: y + "" | ||
y: string | ||
Z: a: string | ||
} | ||
|
||
literalLast: { | ||
p1: { | ||
[string]: list.UniqueItems() | ||
a: [_, _] | ||
} | ||
p2: { | ||
a: [_, _] | ||
[string]: list.UniqueItems() | ||
} | ||
} | ||
|
||
posTieBreaker: { | ||
p1: { | ||
a: list.UniqueItems() | ||
b: list.MinItems(3) | ||
c: a & b | ||
} | ||
p2: { | ||
b: list.MinItems(3) | ||
a: list.UniqueItems() | ||
c: a & b | ||
} | ||
} | ||
-- out/definition -- | ||
import "list" | ||
|
||
basicFirst: { | ||
sort: Z & { | ||
a: _x | ||
} | ||
_x: y + "" | ||
y: string | ||
Z: { | ||
a: string | ||
} | ||
} | ||
literalLast: { | ||
p1: { | ||
[string]: list.UniqueItems() | ||
a: [_, _] | ||
} | ||
p2: { | ||
a: [_, _] | ||
[string]: list.UniqueItems() | ||
} | ||
} | ||
posTieBreaker: { | ||
p1: { | ||
a: list.UniqueItems() | ||
b: list.MinItems(3) | ||
c: a & b | ||
} | ||
p2: { | ||
b: list.MinItems(3) | ||
a: list.UniqueItems() | ||
c: a & b | ||
} | ||
} | ||
-- out/doc -- | ||
[] | ||
[basicFirst] | ||
[basicFirst sort] | ||
[basicFirst sort a] | ||
[basicFirst _x] | ||
[basicFirst y] | ||
[basicFirst Z] | ||
[basicFirst Z a] | ||
[literalLast] | ||
[literalLast p1] | ||
[literalLast p1 a] | ||
[literalLast p1 a 0] | ||
[literalLast p1 a 1] | ||
[literalLast p2] | ||
[literalLast p2 a] | ||
[literalLast p2 a 0] | ||
[literalLast p2 a 1] | ||
[posTieBreaker] | ||
[posTieBreaker p1] | ||
[posTieBreaker p1 a] | ||
[posTieBreaker p1 b] | ||
[posTieBreaker p1 c] | ||
[posTieBreaker p2] | ||
[posTieBreaker p2 b] | ||
[posTieBreaker p2 a] | ||
[posTieBreaker p2 c] | ||
-- out/value -- | ||
== Simplified | ||
{ | ||
basicFirst: { | ||
sort: { | ||
a: string & _x | ||
} | ||
y: string | ||
Z: { | ||
a: string | ||
} | ||
} | ||
literalLast: { | ||
p1: { | ||
a: list.UniqueItems() & [_, _] | ||
} | ||
p2: { | ||
a: list.UniqueItems() & [_, _] | ||
} | ||
} | ||
posTieBreaker: { | ||
p1: { | ||
a: list.UniqueItems() | ||
b: list.MinItems(3) | ||
c: list.UniqueItems() & list.MinItems(3) | ||
} | ||
p2: { | ||
b: list.MinItems(3) | ||
a: list.UniqueItems() | ||
c: list.MinItems(3) & list.UniqueItems() | ||
} | ||
} | ||
} | ||
== Raw | ||
{ | ||
basicFirst: { | ||
sort: { | ||
a: string & _x | ||
} | ||
_x: y + "" | ||
y: string | ||
Z: { | ||
a: string | ||
} | ||
} | ||
literalLast: { | ||
p1: { | ||
a: list.UniqueItems() & [_, _] | ||
} | ||
p2: { | ||
a: list.UniqueItems() & [_, _] | ||
} | ||
} | ||
posTieBreaker: { | ||
p1: { | ||
a: list.UniqueItems() | ||
b: list.MinItems(3) | ||
c: list.UniqueItems() & list.MinItems(3) | ||
} | ||
p2: { | ||
b: list.MinItems(3) | ||
a: list.UniqueItems() | ||
c: list.MinItems(3) & list.UniqueItems() | ||
} | ||
} | ||
} | ||
== Final | ||
{ | ||
basicFirst: { | ||
sort: { | ||
a: _|_ // basicFirst.sort.a: non-concrete value string in operand to + | ||
} | ||
y: string | ||
Z: { | ||
a: string | ||
} | ||
} | ||
literalLast: { | ||
p1: { | ||
a: _|_ // literalLast.p1.a: invalid value [_,_] (does not satisfy list.UniqueItems): equal values at position 0 and 1 | ||
} | ||
p2: { | ||
a: _|_ // literalLast.p2.a: invalid value [_,_] (does not satisfy list.UniqueItems): equal values at position 0 and 1 | ||
} | ||
} | ||
posTieBreaker: { | ||
p1: { | ||
a: list.UniqueItems() | ||
b: list.MinItems(3) | ||
c: list.UniqueItems() & list.MinItems(3) | ||
} | ||
p2: { | ||
b: list.MinItems(3) | ||
a: list.UniqueItems() | ||
c: list.MinItems(3) & list.UniqueItems() | ||
} | ||
} | ||
} | ||
== All | ||
{ | ||
basicFirst: { | ||
sort: { | ||
a: string & _x | ||
} | ||
_x: y + "" | ||
y: string | ||
Z: { | ||
a: string | ||
} | ||
} | ||
literalLast: { | ||
p1: { | ||
a: list.UniqueItems() & [_, _] | ||
} | ||
p2: { | ||
a: list.UniqueItems() & [_, _] | ||
} | ||
} | ||
posTieBreaker: { | ||
p1: { | ||
a: list.UniqueItems() | ||
b: list.MinItems(3) | ||
c: list.UniqueItems() & list.MinItems(3) | ||
} | ||
p2: { | ||
b: list.MinItems(3) | ||
a: list.UniqueItems() | ||
c: list.MinItems(3) & list.UniqueItems() | ||
} | ||
} | ||
} | ||
== Eval | ||
{ | ||
basicFirst: { | ||
sort: { | ||
a: string & _x | ||
} | ||
y: string | ||
Z: { | ||
a: string | ||
} | ||
} | ||
literalLast: { | ||
p1: { | ||
a: list.UniqueItems() & [_, _] | ||
} | ||
p2: { | ||
a: list.UniqueItems() & [_, _] | ||
} | ||
} | ||
posTieBreaker: { | ||
p1: { | ||
a: list.UniqueItems() | ||
b: list.MinItems(3) | ||
c: list.UniqueItems() & list.MinItems(3) | ||
} | ||
p2: { | ||
b: list.MinItems(3) | ||
a: list.UniqueItems() | ||
c: list.MinItems(3) & list.UniqueItems() | ||
} | ||
} | ||
} |
Oops, something went wrong.