-
Notifications
You must be signed in to change notification settings - Fork 1
/
expr_in.go
36 lines (33 loc) · 956 Bytes
/
expr_in.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
package lure
// ExprIn represents an identity node in the AST
type ExprIn struct {
left Expr
list *ExprList
}
// evaluate:
// - returns FALSE if left or context is nil
// - resolve all nodes in the list and return true if a match is found
// - if the already resolved sets contains the value, return TRUE
func (me ExprIn) evaluate(context map[string]IData) IData {
if me.left == nil || context == nil || me.list == nil {
return boolDataFalse
}
leftData := me.left.evaluate(context)
// test if the resolved set contains the value
m := me.list.getResolvedSet()
if _, ok := m[leftData.toString()]; ok {
return boolDataTrue
}
// loop over unresolved list, resolve and return TRUE if match found
if me.list.isResolvable() {
for _, xp := range me.list.getUnResolvedList() {
if xp.evaluate(context).compareTo(leftData) == 0 {
return boolDataTrue
}
}
}
return boolDataFalse
}
func (me ExprIn) isResolvable() bool {
return true
}