| 1 | // Copyright 2018 Google LLC |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package typesscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/ |
| 16 | |
| 17 | import ( |
| 18 | "fmtscip-go gomod github.com/golang/go/src go1.23.0 fmt/" |
| 19 | "mathscip-go gomod github.com/golang/go/src go1.23.0 math/" |
| 20 | "reflectscip-go gomod github.com/golang/go/src go1.23.0 reflect/" |
| 21 | "sortscip-go gomod github.com/golang/go/src go1.23.0 sort/" |
| 22 | "stringsscip-go gomod github.com/golang/go/src go1.23.0 strings/" |
| 23 | "unicodescip-go gomod github.com/golang/go/src go1.23.0 unicode/" |
| 24 | |
| 25 | "github.com/google/cel-go/common/types/refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/" |
| 26 | ) |
| 27 | |
| 28 | var ( |
| 29 | unspecifiedAttributescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/unspecifiedAttribute. = &AttributeTrailscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail#{qualifierPathscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail#qualifierPath.: []any{}} |
| 30 | ) |
| 31 | |
| 32 | // NewAttributeTrail creates a new simple attribute from a variable name. |
| 33 | func NewAttributeTrailscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/NewAttributeTrail().(variable string) *AttributeTrailscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail# { |
| 34 | if variable == "" { |
| 35 | return unspecifiedAttributescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/unspecifiedAttribute. |
| 36 | } |
| 37 | return &AttributeTrailscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail#{variablescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail#variable.: variable} |
| 38 | } |
| 39 | |
| 40 | // AttributeTrail specifies a variable with an optional qualifier path. An attribute value is expected to |
| 41 | // correspond to an AbsoluteAttribute, meaning a field selection which starts with a top-level variable. |
| 42 | // |
| 43 | // The qualifer path elements adhere to the AttributeQualifier type constraint. |
| 44 | type AttributeTrailscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail# struct { |
| 45 | variablescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail#variable. string |
| 46 | qualifierPathscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail#qualifierPath. []any |
| 47 | } |
| 48 | |
| 49 | // Equal returns whether two attribute values have the same variable name and qualifier paths. |
| 50 | func (a *AttributeTrailscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail#) Equalscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail#Equal().(other *AttributeTrailscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail#) bool { |
| 51 | if a.Variablescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail#Variable().() != other.Variablescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail#Variable().() || len(a.QualifierPathscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail#QualifierPath().()) != len(other.QualifierPathscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail#QualifierPath().()) { |
| 52 | return false |
| 53 | } |
| 54 | for i, q := range a.QualifierPathscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail#QualifierPath().() { |
| 55 | qual := other.QualifierPathscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail#QualifierPath().()[i] |
| 56 | if !qualifiersEqualscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/qualifiersEqual().(q, qual) { |
| 57 | return false |
| 58 | } |
| 59 | } |
| 60 | return true |
| 61 | } |
| 62 | |
| 63 | func qualifiersEqualscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/qualifiersEqual().(a, b any) bool { |
| 64 | if a == b { |
| 65 | return true |
| 66 | } |
| 67 | switch numA := a.(type) { |
| 68 | case int64: |
| 69 | numB, ok := b.(uint64) |
| 70 | if !ok { |
| 71 | return false |
| 72 | } |
| 73 | return intUintEqualscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/intUintEqual().(numA, numB) |
| 74 | case uint64: |
| 75 | numB, ok := b.(int64) |
| 76 | if !ok { |
| 77 | return false |
| 78 | } |
| 79 | return intUintEqualscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/intUintEqual().(numB, numA) |
| 80 | default: |
| 81 | return false |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | func intUintEqualscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/intUintEqual().(i int64, u uint64) bool { |
| 86 | if i < 0 || u > mathscip-go gomod github.com/golang/go/src go1.23.0 math/.MaxInt64scip-go gomod github.com/golang/go/src go1.23.0 math/MaxInt64. { |
| 87 | return false |
| 88 | } |
| 89 | return i == int64(u) |
| 90 | } |
| 91 | |
| 92 | // Variable returns the variable name associated with the attribute. |
| 93 | func (a *AttributeTrailscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail#) Variablescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail#Variable().() string { |
| 94 | return a.variablescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail#variable. |
| 95 | } |
| 96 | |
| 97 | // QualifierPath returns the optional set of qualifying fields or indices applied to the variable. |
| 98 | func (a *AttributeTrailscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail#) QualifierPathscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail#QualifierPath().() []any { |
| 99 | return a.qualifierPathscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail#qualifierPath. |
| 100 | } |
| 101 | |
| 102 | // String returns the string representation of the Attribute. |
| 103 | func (a *AttributeTrailscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail#) Stringscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail#String().() string { |
| 104 | if a.variablescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail#variable. == "" { |
| 105 | return "<unspecified>" |
| 106 | } |
| 107 | var str stringsscip-go gomod github.com/golang/go/src go1.23.0 strings/.Builderscip-go gomod github.com/golang/go/src go1.23.0 strings/Builder# |
| 108 | str.WriteStringscip-go gomod github.com/golang/go/src go1.23.0 strings/Builder#WriteString().(a.variablescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail#variable.) |
| 109 | for _, q := range a.qualifierPathscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail#qualifierPath. { |
| 110 | switch q := q.(type) { |
| 111 | case bool, int64: |
| 112 | str.WriteStringscip-go gomod github.com/golang/go/src go1.23.0 strings/Builder#WriteString().(fmtscip-go gomod github.com/golang/go/src go1.23.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.23.0 fmt/Sprintf().("[%v]", q)) |
| 113 | case uint64: |
| 114 | str.WriteStringscip-go gomod github.com/golang/go/src go1.23.0 strings/Builder#WriteString().(fmtscip-go gomod github.com/golang/go/src go1.23.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.23.0 fmt/Sprintf().("[%vu]", q)) |
| 115 | case string: |
| 116 | if isIdentifierCharacterscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/isIdentifierCharacter().(q) { |
| 117 | str.WriteStringscip-go gomod github.com/golang/go/src go1.23.0 strings/Builder#WriteString().(fmtscip-go gomod github.com/golang/go/src go1.23.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.23.0 fmt/Sprintf().(".%v", q)) |
| 118 | } else { |
| 119 | str.WriteStringscip-go gomod github.com/golang/go/src go1.23.0 strings/Builder#WriteString().(fmtscip-go gomod github.com/golang/go/src go1.23.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.23.0 fmt/Sprintf().("[%q]", q)) |
| 120 | } |
| 121 | } |
| 122 | } |
| 123 | return str.Stringscip-go gomod github.com/golang/go/src go1.23.0 strings/Builder#String().() |
| 124 | } |
| 125 | |
| 126 | func isIdentifierCharacterscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/isIdentifierCharacter().(str string) bool { |
| 127 | for _, c := range str { |
| 128 | if unicodescip-go gomod github.com/golang/go/src go1.23.0 unicode/.IsLetterscip-go gomod github.com/golang/go/src go1.23.0 unicode/IsLetter().(c) || unicodescip-go gomod github.com/golang/go/src go1.23.0 unicode/.IsDigitscip-go gomod github.com/golang/go/src go1.23.0 unicode/IsDigit().(c) || string(c) == "_" { |
| 129 | continue |
| 130 | } |
| 131 | return false |
| 132 | } |
| 133 | return true |
| 134 | } |
| 135 | |
| 136 | // AttributeQualifier constrains the possible types which may be used to qualify an attribute. |
| 137 | type AttributeQualifierscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeQualifier# interface { |
| 138 | bool | int64 | uint64 | string |
| 139 | } |
| 140 | |
| 141 | // QualifyAttribute qualifies an attribute using a valid AttributeQualifier type. |
| 142 | func QualifyAttributescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/QualifyAttribute().[T AttributeQualifierscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeQualifier#](attr *AttributeTrailscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail#, qualifier T) *AttributeTrailscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail# { |
| 143 | attr.qualifierPathscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail#qualifierPath. = append(attr.qualifierPathscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail#qualifierPath., qualifier) |
| 144 | return attr |
| 145 | } |
| 146 | |
| 147 | // Unknown type which collects expression ids which caused the current value to become unknown. |
| 148 | type Unknownscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown# struct { |
| 149 | attributeTrailsscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#attributeTrails. map[int64][]*AttributeTrailscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail# |
| 150 | } |
| 151 | |
| 152 | // NewUnknown creates a new unknown at a given expression id for an attribute. |
| 153 | // |
| 154 | // If the attribute is nil, the attribute value will be the `unspecifiedAttribute`. |
| 155 | func NewUnknownscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/NewUnknown().(id int64, attr *AttributeTrailscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail#) *Unknownscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown# { |
| 156 | if attr == nil { |
| 157 | attr = unspecifiedAttributescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/unspecifiedAttribute. |
| 158 | } |
| 159 | return &Unknownscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#{ |
| 160 | attributeTrailsscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#attributeTrails.: map[int64][]*AttributeTrailscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail#{id: {attr}}, |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | // IDs returns the set of unknown expression ids contained by this value. |
| 165 | // |
| 166 | // Numeric identifiers are guaranteed to be in sorted order. |
| 167 | func (u *Unknownscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#) IDsscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#IDs().() []int64 { |
| 168 | ids := make(int64Slicescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/int64Slice#, len(u.attributeTrailsscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#attributeTrails.)) |
| 169 | i := 0 |
| 170 | for id := range u.attributeTrailsscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#attributeTrails. { |
| 171 | ids[i] = id |
| 172 | i++ |
| 173 | } |
| 174 | ids.Sortscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/int64Slice#Sort().() |
| 175 | return ids |
| 176 | } |
| 177 | |
| 178 | // GetAttributeTrails returns the attribute trails, if present, missing for a given expression id. |
| 179 | func (u *Unknownscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#) GetAttributeTrailsscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#GetAttributeTrails().(id int64) ([]*AttributeTrailscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail#, bool) { |
| 180 | trails, found := u.attributeTrailsscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#attributeTrails.[id] |
| 181 | return trails, found |
| 182 | } |
| 183 | |
| 184 | // Contains returns true if the input unknown is a subset of the current unknown. |
| 185 | func (u *Unknownscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#) Containsscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#Contains().(other *Unknownscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#) bool { |
| 186 | for id, otherTrails := range other.attributeTrailsscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#attributeTrails. { |
| 187 | trails, found := u.attributeTrailsscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#attributeTrails.[id] |
| 188 | if !found || len(otherTrails) != len(trails) { |
| 189 | return false |
| 190 | } |
| 191 | for _, ot := range otherTrails { |
| 192 | found := false |
| 193 | for _, t := range trails { |
| 194 | if t.Equalscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail#Equal().(ot) { |
| 195 | found = true |
| 196 | break |
| 197 | } |
| 198 | } |
| 199 | if !found { |
| 200 | return false |
| 201 | } |
| 202 | } |
| 203 | } |
| 204 | return true |
| 205 | } |
| 206 | |
| 207 | // ConvertToNative implements ref.Val.ConvertToNative. |
| 208 | func (u *Unknownscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#) ConvertToNativescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#ConvertToNative().(typeDesc reflectscip-go gomod github.com/golang/go/src go1.23.0 reflect/.Typescip-go gomod github.com/golang/go/src go1.23.0 reflect/Type#) (any, error) { |
| 209 | return u.Valuescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#Value().(), nil |
| 210 | } |
| 211 | |
| 212 | // ConvertToType is an identity function since unknown values cannot be modified. |
| 213 | func (u *Unknownscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#) ConvertToTypescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#ConvertToType().(typeVal refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Typescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Type#) refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Valscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Val# { |
| 214 | return u |
| 215 | } |
| 216 | |
| 217 | // Equal is an identity function since unknown values cannot be modified. |
| 218 | func (u *Unknownscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#) Equalscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#Equal().(other refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Valscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Val#) refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Valscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Val# { |
| 219 | return u |
| 220 | } |
| 221 | |
| 222 | // String implements the Stringer interface |
| 223 | func (u *Unknownscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#) Stringscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#String().() string { |
| 224 | var str stringsscip-go gomod github.com/golang/go/src go1.23.0 strings/.Builderscip-go gomod github.com/golang/go/src go1.23.0 strings/Builder# |
| 225 | for id, attrs := range u.attributeTrailsscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#attributeTrails. { |
| 226 | if str.Lenscip-go gomod github.com/golang/go/src go1.23.0 strings/Builder#Len().() != 0 { |
| 227 | str.WriteStringscip-go gomod github.com/golang/go/src go1.23.0 strings/Builder#WriteString().(", ") |
| 228 | } |
| 229 | if len(attrs) == 1 { |
| 230 | str.WriteStringscip-go gomod github.com/golang/go/src go1.23.0 strings/Builder#WriteString().(fmtscip-go gomod github.com/golang/go/src go1.23.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.23.0 fmt/Sprintf().("%v (%d)", attrs[0], id)) |
| 231 | } else { |
| 232 | str.WriteStringscip-go gomod github.com/golang/go/src go1.23.0 strings/Builder#WriteString().(fmtscip-go gomod github.com/golang/go/src go1.23.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.23.0 fmt/Sprintf().("%v (%d)", attrs, id)) |
| 233 | } |
| 234 | } |
| 235 | return str.Stringscip-go gomod github.com/golang/go/src go1.23.0 strings/Builder#String().() |
| 236 | } |
| 237 | |
| 238 | // Type implements ref.Val.Type. |
| 239 | func (u *Unknownscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#) Typescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#Type().() refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Typescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Type# { |
| 240 | return UnknownTypescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/UnknownType. |
| 241 | } |
| 242 | |
| 243 | // Value implements ref.Val.Value. |
| 244 | func (u *Unknownscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#) Valuescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#Value().() any { |
| 245 | return u |
| 246 | } |
| 247 | |
| 248 | // IsUnknown returns whether the element ref.Val is in instance of *types.Unknown |
| 249 | func IsUnknownscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/IsUnknown().(val refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Valscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Val#) bool { |
| 250 | switch val.(type) { |
| 251 | case *Unknownscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#: |
| 252 | return true |
| 253 | default: |
| 254 | return false |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | // MaybeMergeUnknowns determines whether an input value and another, possibly nil, unknown will produce |
| 259 | // an unknown result. |
| 260 | // |
| 261 | // If the input `val` is another Unknown, then the result will be the merge of the `val` and the input |
| 262 | // `unk`. If the `val` is not unknown, then the result will depend on whether the input `unk` is nil. |
| 263 | // If both values are non-nil and unknown, then the return value will be a merge of both unknowns. |
| 264 | func MaybeMergeUnknownsscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/MaybeMergeUnknowns().(val refscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/.Valscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types/ref`/Val#, unk *Unknownscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#) (*Unknownscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#, bool) { |
| 265 | src, isUnk := val.(*Unknownscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#) |
| 266 | if !isUnk { |
| 267 | if unk != nil { |
| 268 | return unk, true |
| 269 | } |
| 270 | return unk, false |
| 271 | } |
| 272 | return MergeUnknownsscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/MergeUnknowns().(src, unk), true |
| 273 | } |
| 274 | |
| 275 | // MergeUnknowns combines two unknown values into a new unknown value. |
| 276 | func MergeUnknownsscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/MergeUnknowns().(unk1, unk2 *Unknownscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#) *Unknownscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown# { |
| 277 | if unk1 == nil { |
| 278 | return unk2 |
| 279 | } |
| 280 | if unk2 == nil { |
| 281 | return unk1 |
| 282 | } |
| 283 | out := &Unknownscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#{ |
| 284 | attributeTrailsscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#attributeTrails.: make(map[int64][]*AttributeTrailscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail#, len(unk1.attributeTrailsscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#attributeTrails.)+len(unk2.attributeTrailsscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#attributeTrails.)), |
| 285 | } |
| 286 | for id, ats := range unk1.attributeTrailsscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#attributeTrails. { |
| 287 | out.attributeTrailsscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#attributeTrails.[id] = ats |
| 288 | } |
| 289 | for id, ats := range unk2.attributeTrailsscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#attributeTrails. { |
| 290 | existing, found := out.attributeTrailsscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#attributeTrails.[id] |
| 291 | if !found { |
| 292 | out.attributeTrailsscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#attributeTrails.[id] = ats |
| 293 | continue |
| 294 | } |
| 295 | |
| 296 | for _, at := range ats { |
| 297 | found := false |
| 298 | for _, et := range existing { |
| 299 | if at.Equalscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/AttributeTrail#Equal().(et) { |
| 300 | found = true |
| 301 | break |
| 302 | } |
| 303 | } |
| 304 | if !found { |
| 305 | existing = append(existing, at) |
| 306 | } |
| 307 | } |
| 308 | out.attributeTrailsscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/Unknown#attributeTrails.[id] = existing |
| 309 | } |
| 310 | return out |
| 311 | } |
| 312 | |
| 313 | // int64Slice is an implementation of the sort.Interface |
| 314 | type int64Slicescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/int64Slice# []int64 |
| 315 | |
| 316 | // Len returns the number of elements in the slice. |
| 317 | func (x int64Slicescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/int64Slice#) Lenscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/int64Slice#Len().() int { return len(x) } |
| 318 | |
| 319 | // Less indicates whether the value at index i is less than the value at index j. |
| 320 | func (x int64Slicescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/int64Slice#) Lessscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/int64Slice#Less().(i, j int) bool { return x[i] < x[j] } |
| 321 | |
| 322 | // Swap swaps the values at indices i and j in place. |
| 323 | func (x int64Slicescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/int64Slice#) Swapscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/int64Slice#Swap().(i, j int) { x[i], x[j] = x[j], x[i] } |
| 324 | |
| 325 | // Sort is a convenience method: x.Sort() calls Sort(x). |
| 326 | func (x int64Slicescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/int64Slice#) Sortscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common/types`/int64Slice#Sort().() { sortscip-go gomod github.com/golang/go/src go1.23.0 sort/.Sortscip-go gomod github.com/golang/go/src go1.23.0 sort/Sort().(x) } |