-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
queue.go
73 lines (57 loc) · 1.59 KB
/
queue.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
package containers
import (
"github.com/inoxlang/inox/internal/core/symbolic"
"github.com/inoxlang/inox/internal/prettyprint"
pprint "github.com/inoxlang/inox/internal/prettyprint"
)
var (
QUEUE_PROPNAMES = []string{"enqueue", "dequeue", "peek"}
_ = []symbolic.Iterable{(*Queue)(nil)}
)
type Queue struct {
symbolic.UnassignablePropsMixin
_ int
}
func (*Queue) Test(v symbolic.Value, state symbolic.RecTestCallState) bool {
state.StartCall()
defer state.FinishCall()
_, ok := v.(*Queue)
return ok
}
func (q *Queue) GetGoMethod(name string) (*symbolic.GoFunction, bool) {
switch name {
case "enqueue":
return symbolic.WrapGoMethod(q.Enqueue), true
case "dequeue":
return symbolic.WrapGoMethod(q.Dequeue), true
case "peek":
return symbolic.WrapGoMethod(q.Peek), true
}
return nil, false
}
func (q *Queue) Prop(name string) symbolic.Value {
return symbolic.GetGoMethodOrPanic(name, q)
}
func (*Queue) PropertyNames() []string {
return QUEUE_PROPNAMES
}
func (*Queue) Enqueue(ctx *symbolic.Context, elems symbolic.Value) {
}
func (*Queue) Dequeue(ctx *symbolic.Context) (symbolic.Value, *symbolic.Bool) {
return symbolic.ANY, nil
}
func (*Queue) Peek(ctx *symbolic.Context) (symbolic.Value, *symbolic.Bool) {
return symbolic.ANY, nil
}
func (*Queue) PrettyPrint(w prettyprint.PrettyPrintWriter, config *pprint.PrettyPrintConfig) {
w.WriteName("queue")
}
func (*Queue) IteratorElementKey() symbolic.Value {
return symbolic.ANY
}
func (*Queue) IteratorElementValue() symbolic.Value {
return symbolic.ANY
}
func (*Queue) WidestOfType() symbolic.Value {
return &Queue{}
}