| 72 | } |
| 73 | |
| 74 | func (a *And) Eval(this super.Value) super.Value { |
| 75 | lhs := EvalBool(a.sctx, this, a.lhs) |
| 76 | rhs := EvalBool(a.sctx, this, a.rhs) |
| 77 | if isfalse(lhs) || isfalse(rhs) { |
| 78 | // anything AND FALSE = FALSE |
| 79 | return super.False |
| 80 | } |
| 81 | // ERROR AND NULL = ERROR |
| 82 | // ERROR AND TRUE = ERROR |
| 83 | if lhs.IsError() { |
| 84 | return lhs |
| 85 | } |
| 86 | if rhs.IsError() { |
| 87 | return rhs |
| 88 | } |
| 89 | if lhs.IsNull() || rhs.IsNull() { |
| 90 | // NULL AND TRUE = NULL |
| 91 | return super.Null |
| 92 | } |
| 93 | return super.True |
| 94 | } |
| 95 | |
| 96 | func isfalse(val super.Value) bool { |
| 97 | return val.Type().ID() == super.IDBool && !val.IsNull() && !val.Bool() |