-
-
Notifications
You must be signed in to change notification settings - Fork 494
Expand file tree
/
Copy pathutils.go
More file actions
59 lines (51 loc) · 1.01 KB
/
utils.go
File metadata and controls
59 lines (51 loc) · 1.01 KB
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
package vm
import (
"reflect"
"time"
)
type (
Function = func(params ...any) (any, error)
SafeFunction = func(params ...any) (any, uint, error)
)
var (
errorType = reflect.TypeOf((*error)(nil)).Elem()
)
type Scope struct {
Array reflect.Value
Index int
Len int
Count int
Acc any
// Fast paths
Ints []int
Floats []float64
Strings []string
Anys []any
}
// Item returns the current element from the scope using fast paths when available.
func (s *Scope) Item() any {
if s.Ints != nil {
return s.Ints[s.Index]
}
if s.Floats != nil {
return s.Floats[s.Index]
}
if s.Strings != nil {
return s.Strings[s.Index]
}
if s.Anys != nil {
return s.Anys[s.Index]
}
return s.Array.Index(s.Index).Interface()
}
type groupBy = map[any][]any
type Span struct {
Name string `json:"name"`
Expression string `json:"expression"`
Duration int64 `json:"duration"`
Children []*Span `json:"children"`
start time.Time
}
func GetSpan(program *Program) *Span {
return program.span
}