-
Notifications
You must be signed in to change notification settings - Fork 15
/
value_set_eclosure.go
123 lines (98 loc) · 2.64 KB
/
value_set_eclosure.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
package rel
import (
"reflect"
"github.com/arr-ai/wbnf/parser"
)
// ExprClosure represents the closure of an expression over a scope.
type ExprClosure struct {
scope Scope
e Expr
}
// NewFunction returns a new function.
func NewExprClosure(scope Scope, e Expr) Value {
return ExprClosure{scope: scope, e: e}
}
// Hash computes a hash for a ExprClosure.
func (c ExprClosure) Hash(seed uintptr) uintptr {
panic("not implemented")
// TODO: Is this enough?
// return c.e.Hash(seed)
}
// Equal tests two Values for equality. Any other type returns false.
func (c ExprClosure) Equal(i interface{}) bool {
if d, ok := i.(ExprClosure); ok {
return c.EqualExprClosure(d)
}
return false
}
// Equal tests two Values for equality. Any other type returns false.
func (c ExprClosure) EqualExprClosure(d ExprClosure) bool {
panic("not implemented")
// return c.f.EqualFunction(d.f)
}
// String returns a string representation of the expression.
func (c ExprClosure) String() string {
return "◖" + c.e.String() + "◗"
}
// Eval returns the Value
func (c ExprClosure) Eval(_ Scope) (Value, error) {
return c.e.Eval(c.scope)
}
// Source returns a scanner locating the ExprClosure's source code.
func (c ExprClosure) Source() parser.Scanner {
return *parser.NewScanner("")
}
var eclosureKind = registerKind(206, reflect.TypeOf(ExprClosure{}))
// Kind returns a number that is unique for each major kind of Value.
func (c ExprClosure) Kind() int {
return eclosureKind
}
// Bool returns true iff the tuple has attributes.
func (c ExprClosure) IsTrue() bool {
return true
}
// Less returns true iff g is not a number or f.number < g.number.
func (c ExprClosure) Less(d Value) bool {
if c.Kind() != d.Kind() {
return c.Kind() < d.Kind()
}
return c.String() < d.String()
}
// Negate returns {(negateTag): f}.
func (c ExprClosure) Negate() Value {
return NewTuple(NewAttr(negateTag, c))
}
// Export exports a ExprClosure.
func (c ExprClosure) Export() interface{} {
return func(v Value) Value {
return SetCall(c, v)
}
}
func (ExprClosure) Count() int {
return 1
}
func (ExprClosure) Has(Value) bool {
panic("unimplemented")
}
func (ExprClosure) Enumerator() ValueEnumerator {
panic("unimplemented")
}
func (c ExprClosure) With(Value) Set {
panic("unimplemented")
}
func (ExprClosure) Without(Value) Set {
panic("unimplemented")
}
func (ExprClosure) Map(func(Value) Value) Set {
panic("unimplemented")
}
func (ExprClosure) Where(func(Value) bool) Set {
panic("unimplemented")
}
func (c ExprClosure) CallAll(arg Value) Set {
//TODO: CallAll
panic("unimplemented")
}
func (ExprClosure) ArrayEnumerator() (OffsetValueEnumerator, bool) {
panic("unimplemented")
}