-
Notifications
You must be signed in to change notification settings - Fork 487
/
enum_statics.go
62 lines (50 loc) · 1.21 KB
/
enum_statics.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package traceql
import "fmt"
type StaticType int
const (
typeSpanset StaticType = iota // type used by spanset pipelines
typeAttribute // a special constant that indicates the type is determined at query time by the attribute
typeInt
typeFloat
typeString
typeBoolean
typeNil
typeDuration
typeStatus
)
// isMatchingOperand returns whether two types can be combined with a binary operator. the kind of operator is
// immaterial. see Operator.typesValid() for code that determines if the passed types are valid for the given
// operator.
func (t StaticType) isMatchingOperand(otherT StaticType) bool {
if t == typeAttribute || otherT == typeAttribute {
return true
}
if t == otherT {
return true
}
if t.isNumeric() && otherT.isNumeric() {
return true
}
return false
}
func (t StaticType) isNumeric() bool {
return t == typeInt || t == typeFloat || t == typeDuration
}
// Status represents valid static values of typeStatus
type Status int
const (
statusError Status = iota
statusOk
statusUnset
)
func (s Status) String() string {
switch s {
case statusError:
return "error"
case statusOk:
return "ok"
case statusUnset:
return "unset"
}
return fmt.Sprintf("status(%d)", s)
}