-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathop.go
105 lines (85 loc) · 1.95 KB
/
op.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package ron
import (
// "fmt"
)
func (frame Frame) IsSameOp(b Frame) bool {
return frame.Event() == b.Event() && frame.Object() == b.Object() && frame.Ref() == b.Ref() && frame.Type() == b.Type()
}
func (frame Frame) Type() UUID {
return frame.UUID(SPEC_TYPE)
}
func (frame Frame) Object() UUID {
return frame.UUID(SPEC_OBJECT)
}
func (frame Frame) Event() UUID {
return frame.UUID(SPEC_EVENT)
}
func (frame Frame) Ref() UUID {
return frame.UUID(SPEC_REF)
}
func (frame Frame) Term() int {
return frame.term
}
func (frame Frame) IsQuery() bool {
return frame.Term() == TERM_QUERY
}
func (frame Frame) IsHeader() bool {
return frame.Term() == TERM_HEADER
}
func (frame Frame) IsFullState() bool {
return frame.IsHeader() && frame.Ref().IsZero()
}
func (frame Frame) IsFramed() bool {
return frame.Term() == TERM_REDUCED
}
func (frame Frame) IsRaw() bool {
return frame.Term() == TERM_RAW
}
func (frame Frame) IsOn() bool {
return frame.IsQuery() && frame.Ref() != NEVER_UUID
}
func (frame Frame) IsOff() bool {
return frame.IsQuery() && frame.Ref() == NEVER_UUID
}
func CreateFrame(rdtype, object, event, location, value string) Frame {
return Frame{}
}
func (frame Frame) Stamp(clock Clock) Frame {
cur := MakeFrame(frame.Len() + 20)
stamps := map[uint64]UUID{}
for !frame.EOF() {
for t := 0; t < 4; t++ {
uuid := frame.UUID(t)
if uuid.IsTemplate() {
stamp, ok := stamps[uuid.Origin()]
if !ok {
stamp = clock.Time()
stamps[uuid.Origin()] = stamp
}
frame.atoms[t] = Atom(stamp)
}
}
cur.Append(frame)
frame.Next()
}
return cur.Close()
}
func (frame Frame) isZero() bool {
for t := 0; t < 4; t++ {
if !frame.UUID(t).IsZero() {
return false
}
}
return true
}
func (frame Frame) OpString() string {
cur := MakeFrame(128)
cur.Append(frame)
return string(cur.Body)
}
func (frame Frame) Origin() uint64 {
return frame.atoms[SPEC_EVENT][1]
}
func (frame Frame) Time() uint64 {
return frame.atoms[SPEC_EVENT][0]
}