(expr)
| 16962 | this.emitIfElseBlocks(stmt.range(), cond_value, stmt.body, stmt.orelse); |
| 16963 | } |
| 16964 | emitCondExpr(expr) { |
| 16965 | /* |
| 16966 | switch (expr.kind()) { |
| 16967 | case TK_AND: |
| 16968 | case TK_OR: { |
| 16969 | const binop = BinOp(expr); |
| 16970 | return emitShortCircuitLogical( |
| 16971 | binop.range(), binop.lhs(), binop.rhs(), expr.kind() == TK_OR); |
| 16972 | } |
| 16973 | case TK_NOT: { |
| 16974 | CondValue v = emitCondExpr(Expr(expr.tree().trees()[0])); |
| 16975 | Value* result = emitBuiltinCall( |
| 16976 | expr.range(), *graph, aten::__not__, {v.value()}, {}); |
| 16977 | std::optional<bool> static_if; |
| 16978 | if (v.staticIf()) { |
| 16979 | static_if = !*v.staticIf(); |
| 16980 | } |
| 16981 | return CondValue(result, v.refinements().Not(), static_if); |
| 16982 | } break; |
| 16983 | case TK_IS: |
| 16984 | case TK_ISNOT: { |
| 16985 | // meta programming on AST for is/is not cases and emit branches base on |
| 16986 | const cond_op = BinOp(expr); |
| 16987 | Value* lhs_val = emitExpr(cond_op.lhs()); |
| 16988 | Value* rhs_val = emitExpr(cond_op.rhs()); |
| 16989 | const lhs_none = canBeNone(lhs_val); |
| 16990 | const rhs_none = canBeNone(rhs_val); |
| 16991 | // Dispatch logic (A: ALWAYS, N: NEVER, M: MAYBE): |
| 16992 | // AA, -> statically IS always holds, IS_NOT never holds |
| 16993 | // AN , NA-> statically IS_NOT always holds, IS never holds |
| 16994 | // MA, MM, MN, NM, NN, AM -> cannot prove anything statically |
| 16995 | bool its_is = expr.kind() == TK_IS; |
| 16996 | if (lhs_none == ALWAYS && rhs_none == ALWAYS) { |
| 16997 | return CondValue(*graph, expr.range(), its_is, {}); |
| 16998 | } else if ( |
| 16999 | (lhs_none == ALWAYS && rhs_none == NEVER) || |
| 17000 | (lhs_none == NEVER && rhs_none == ALWAYS)) { |
| 17001 | // lhs_val/rhs_val with A/M: only emit never_none_branch |
| 17002 | return CondValue(*graph, expr.range(), !its_is, {}); |
| 17003 | } else { |
| 17004 | const kind = getNodeKind(expr.kind(), expr.get()->trees().size()); |
| 17005 | Value* cond_value = emitBuiltinCall( |
| 17006 | expr.get()->range(), |
| 17007 | *method.graph(), |
| 17008 | kind, |
| 17009 | {lhs_val, rhs_val}, |
| 17010 | {}); |
| 17011 | const refinements = RefinementSet(findIsNoneRefinements( |
| 17012 | cond_op.lhs(), lhs_val, cond_op.rhs(), rhs_val, expr.kind())); |
| 17013 | return CondValue(cond_value, refinements, null); |
| 17014 | } |
| 17015 | } break; |
| 17016 | */ |
| 17017 | if (expr instanceof ast.UnaryOp) { |
| 17018 | throw new python.Error('Not implemented.'); |
| 17019 | } |
| 17020 | if (expr instanceof ast.Call) { |
| 17021 | const apply = expr; |
no test coverage detected