mirror of
https://github.com/chaisql/chai.git
synced 2025-10-06 08:06:55 +08:00
stream: clone stream before execution
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user