Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 734x 647x 321x 321x | import type { ExpressionState } from '../../expression-state.js';
import { TypedValue } from '../../typed-value.js';
import { Operator } from '../spel-node.js';
import { NodeType } from '../../language/node-type.js';
import { requireBoolean } from './operand-guards.js';
/**
* Logical conjunction. Both operands must be Boolean, and the right operand
* is not evaluated when the left is false.
*/
export class OpAnd extends Operator {
constructor(
operatorName: string,
startPos: number,
endPos: number,
...operands: import('../spel-node.js').SpelNodeImpl[]
) {
super(NodeType.OP_AND, operatorName, startPos, endPos, ...operands);
}
public override getValueInternal(state: ExpressionState): TypedValue {
// The left operand is evaluated and type-checked first, so short-circuiting
// still happens and a non-boolean left operand is still reported.
if (!requireBoolean(this.children[0]!, state)) {
return new TypedValue(false);
}
return new TypedValue(requireBoolean(this.children[1]!, state));
}
}
|