12
12
// See the License for the specific language governing permissions and
13
13
// limitations under the License.
14
14
15
- package eval
15
+ package adt
16
16
17
- import "cuelang.org/go/internal/core/adt"
18
-
19
- func Equal (ctx * adt.OpContext , v , w adt.Value ) bool {
20
- if x , ok := v .(* adt.Vertex ); ok {
17
+ func Equal (ctx * OpContext , v , w Value ) bool {
18
+ if x , ok := v .(* Vertex ); ok {
21
19
return equalVertex (ctx , x , w )
22
20
}
23
- if y , ok := w .(* adt. Vertex ); ok {
21
+ if y , ok := w .(* Vertex ); ok {
24
22
return equalVertex (ctx , y , v )
25
23
}
26
24
return equalTerminal (ctx , v , w )
27
25
}
28
26
29
- func equalVertex (ctx * adt. OpContext , x * adt. Vertex , v adt. Value ) bool {
30
- y , ok := v .(* adt. Vertex )
27
+ func equalVertex (ctx * OpContext , x * Vertex , v Value ) bool {
28
+ y , ok := v .(* Vertex )
31
29
if ! ok {
32
30
return false
33
31
}
@@ -69,42 +67,42 @@ loop1:
69
67
// return false
70
68
// }
71
69
72
- v , ok1 := x .BaseValue .(adt. Value )
73
- w , ok2 := y .BaseValue .(adt. Value )
70
+ v , ok1 := x .BaseValue .(Value )
71
+ w , ok2 := y .BaseValue .(Value )
74
72
if ! ok1 && ! ok2 {
75
73
return true // both are struct or list.
76
74
}
77
75
78
76
return equalTerminal (ctx , v , w )
79
77
}
80
78
81
- func equalTerminal (ctx * adt. OpContext , v , w adt. Value ) bool {
79
+ func equalTerminal (ctx * OpContext , v , w Value ) bool {
82
80
if v == w {
83
81
return true
84
82
}
85
83
86
84
switch x := v .(type ) {
87
- case * adt. Num , * adt. String , * adt. Bool , * adt. Bytes :
88
- if b , ok := adt . BinOp (ctx , adt . EqualOp , v , w ).(* adt. Bool ); ok {
85
+ case * Num , * String , * Bool , * Bytes :
86
+ if b , ok := BinOp (ctx , EqualOp , v , w ).(* Bool ); ok {
89
87
return b .B
90
88
}
91
89
return false
92
90
93
91
// TODO: for the remainder we are dealing with non-concrete values, so we
94
92
// could also just not bother.
95
93
96
- case * adt. BoundValue :
97
- if y , ok := w .(* adt. BoundValue ); ok {
94
+ case * BoundValue :
95
+ if y , ok := w .(* BoundValue ); ok {
98
96
return x .Op == y .Op && Equal (ctx , x .Value , y .Value )
99
97
}
100
98
101
- case * adt. BasicType :
102
- if y , ok := w .(* adt. BasicType ); ok {
99
+ case * BasicType :
100
+ if y , ok := w .(* BasicType ); ok {
103
101
return x .K == y .K
104
102
}
105
103
106
- case * adt. Conjunction :
107
- y , ok := w .(* adt. Conjunction )
104
+ case * Conjunction :
105
+ y , ok := w .(* Conjunction )
108
106
if ! ok || len (x .Values ) != len (y .Values ) {
109
107
return false
110
108
}
@@ -116,10 +114,10 @@ func equalTerminal(ctx *adt.OpContext, v, w adt.Value) bool {
116
114
}
117
115
return true
118
116
119
- case * adt. Disjunction :
117
+ case * Disjunction :
120
118
// The best way to compute this is with subsumption, but even that won't
121
119
// be too accurate. Assume structural equivalence for now.
122
- y , ok := w .(* adt. Disjunction )
120
+ y , ok := w .(* Disjunction )
123
121
if ! ok || len (x .Values ) != len (y .Values ) {
124
122
return false
125
123
}
@@ -130,7 +128,7 @@ func equalTerminal(ctx *adt.OpContext, v, w adt.Value) bool {
130
128
}
131
129
return true
132
130
133
- case * adt. BuiltinValidator :
131
+ case * BuiltinValidator :
134
132
}
135
133
136
134
return false
0 commit comments