@@ -591,16 +591,39 @@ def inner(operands):
591
591
592
592
return inner
593
593
594
+ @staticmethod
595
+ def build_static_short_circuit_and (operands ):
596
+ for operand in operands :
597
+ if not operand .ptr :
598
+ return operand .ptr
599
+ return operands [- 1 ].ptr
600
+
601
+ @staticmethod
602
+ def build_static_short_circuit_or (operands ):
603
+ for operand in operands :
604
+ if operand .ptr :
605
+ return operand .ptr
606
+ return operands [- 1 ].ptr
607
+
594
608
@staticmethod
595
609
def build_BoolOp (ctx , node ):
596
610
build_stmts (ctx , node .values )
597
- ops = {
598
- ast .And : ASTTransformer .build_short_circuit_and ,
599
- ast .Or : ASTTransformer .build_short_circuit_or ,
600
- } if impl .get_runtime ().short_circuit_operators else {
601
- ast .And : ASTTransformer .build_normal_bool_op (ti_ops .logical_and ),
602
- ast .Or : ASTTransformer .build_normal_bool_op (ti_ops .logical_or ),
603
- }
611
+ if ctx .is_in_static_scope :
612
+ ops = {
613
+ ast .And : ASTTransformer .build_static_short_circuit_and ,
614
+ ast .Or : ASTTransformer .build_static_short_circuit_or ,
615
+ }
616
+ elif impl .get_runtime ().short_circuit_operators :
617
+ ops = {
618
+ ast .And : ASTTransformer .build_short_circuit_and ,
619
+ ast .Or : ASTTransformer .build_short_circuit_or ,
620
+ }
621
+ else :
622
+ ops = {
623
+ ast .And :
624
+ ASTTransformer .build_normal_bool_op (ti_ops .logical_and ),
625
+ ast .Or : ASTTransformer .build_normal_bool_op (ti_ops .logical_or ),
626
+ }
604
627
op = ops .get (type (node .op ))
605
628
node .ptr = op (node .values )
606
629
return node .ptr
0 commit comments