stream: clone stream before execution

This commit is contained in:
Asdine El Hrychy
2024-02-17 17:56:41 +04:00
parent bac26ce46a
commit 71146bcc9b
37 changed files with 464 additions and 13 deletions

View File

@@ -18,6 +18,12 @@ func And(a, b Expr) Expr {
return &AndOp{&simpleOperator{a, b, scanner.AND}}
}
func (op *AndOp) Clone() Expr {
return &AndOp{
simpleOperator: op.simpleOperator.Clone(),
}
}
// Eval implements the Expr interface. It evaluates a and b and returns true if both evaluate
// to true.
func (op *AndOp) Eval(env *environment.Environment) (types.Value, error) {
@@ -52,6 +58,12 @@ func Or(a, b Expr) Expr {
return &OrOp{&simpleOperator{a, b, scanner.OR}}
}
func (op *OrOp) Clone() Expr {
return &OrOp{
simpleOperator: op.simpleOperator.Clone(),
}
}
// Eval implements the Expr interface. It evaluates a and b and returns true if a or b evalutate
// to true.
func (op *OrOp) Eval(env *environment.Environment) (types.Value, error) {
@@ -92,6 +104,12 @@ func Not(e Expr) Expr {
return &NotOp{&simpleOperator{a: e}}
}
func (op *NotOp) Clone() Expr {
return &NotOp{
simpleOperator: op.simpleOperator.Clone(),
}
}
// Eval implements the Expr interface. It evaluates e and returns true if b is falsy
func (op *NotOp) Eval(env *environment.Environment) (types.Value, error) {
s, err := op.a.Eval(env)