Rewrite logical operators and chained comparisons into array operations. More...
Public Member Functions | |
| visit_Call (self, node) | |
Rewrite sum(k, lo, hi, body) as a loop over lambda k: body. | |
| visit_BoolOp (self, node) | |
Fold a and b and c into nested logical calls. | |
| visit_UnaryOp (self, node) | |
Rewrite not a as logical_not(a). | |
| visit_Compare (self, node) | |
Rewrite a < b < c as logical_and(a < b, b < c). | |
Static Protected Member Functions | |
| _call (name, args) | |
| Build a call to one of the evaluation-only logical helpers. | |
Rewrite logical operators and chained comparisons into array operations.
and, or, not and a chain a < b < c have no elementwise meaning for arrays, so they become logical_and, logical_or, logical_not calls, the same 1-or-0 semantics the runtime evaluator gives them.
Definition at line 197 of file source_expressions.py.
|
staticprotected |
Build a call to one of the evaluation-only logical helpers.
| [in] | name | Helper name. |
| [in] | args | Argument nodes. |
Definition at line 206 of file source_expressions.py.
| picurv_cli.source_expressions._LogicalRewriter.visit_Call | ( | self, | |
| node | |||
| ) |
Rewrite sum(k, lo, hi, body) as a loop over lambda k: body.
| [in] | node | Call node. |
Definition at line 215 of file source_expressions.py.
| picurv_cli.source_expressions._LogicalRewriter.visit_BoolOp | ( | self, | |
| node | |||
| ) |
Fold a and b and c into nested logical calls.
| [in] | node | BoolOp node. |
Definition at line 230 of file source_expressions.py.
| picurv_cli.source_expressions._LogicalRewriter.visit_UnaryOp | ( | self, | |
| node | |||
| ) |
Rewrite not a as logical_not(a).
| [in] | node | UnaryOp node. |
Definition at line 243 of file source_expressions.py.
| picurv_cli.source_expressions._LogicalRewriter.visit_Compare | ( | self, | |
| node | |||
| ) |
Rewrite a < b < c as logical_and(a < b, b < c).
| [in] | node | Compare node. |
Definition at line 254 of file source_expressions.py.