• Home
  • Raw
  • Download

Lines Matching +full:constant +full:- +full:conversion

33     return _PyUnicodeWriter_WriteASCIIString(writer, charp, -1);  in append_charp()
41 if (-1 == append_charp(writer, (str))) { \
42 return -1; \
47 if ((cond) && -1 == append_charp(writer, (str))) { \
48 return -1; \
58 if (-1 == append_ast_expr(writer, (expr), (pr))) { \
59 return -1; \
64 if (-1 == append_ast_ ## type(writer, (value))) { \
65 return -1; \
75 return -1; in append_repr()
85 -1 in append_repr()
89 return -1; in append_repr()
102 PR_TEST, /* 'if'-'else', 'lambda' */
113 PR_ARITH, /* '+', '-' */
115 PR_FACTOR, /* unary '+', '-', '~' */
126 const char *op = (e->v.BoolOp.op == And) ? " and " : " or "; in append_ast_boolop()
127 int pr = (e->v.BoolOp.op == And) ? PR_AND : PR_OR; in append_ast_boolop()
131 values = e->v.BoolOp.values; in append_ast_boolop()
148 bool rassoc = false; /* is right-associative? */ in append_ast_binop()
150 switch (e->v.BinOp.op) { in append_ast_binop()
152 case Sub: op = " - "; pr = PR_ARITH; break; in append_ast_binop()
167 return -1; in append_ast_binop()
171 APPEND_EXPR(e->v.BinOp.left, pr + rassoc); in append_ast_binop()
173 APPEND_EXPR(e->v.BinOp.right, pr + !rassoc); in append_ast_binop()
184 switch (e->v.UnaryOp.op) { in append_ast_unaryop()
188 case USub: op = "-"; pr = PR_FACTOR; break; in append_ast_unaryop()
192 return -1; in append_ast_unaryop()
197 APPEND_EXPR(e->v.UnaryOp.operand, pr); in append_ast_unaryop()
205 if (-1 == _PyUnicodeWriter_WriteStr(writer, arg->arg)) { in append_ast_arg()
206 return -1; in append_ast_arg()
208 if (arg->annotation) { in append_ast_arg()
210 APPEND_EXPR(arg->annotation, PR_TEST); in append_ast_arg()
223 /* positional-only and positional arguments with defaults */ in append_ast_args()
224 posonlyarg_count = asdl_seq_LEN(args->posonlyargs); in append_ast_args()
225 arg_count = asdl_seq_LEN(args->args); in append_ast_args()
226 default_count = asdl_seq_LEN(args->defaults); in append_ast_args()
230 APPEND(arg, (arg_ty)asdl_seq_GET(args->posonlyargs, i)); in append_ast_args()
232 APPEND(arg, (arg_ty)asdl_seq_GET(args->args, i-posonlyarg_count)); in append_ast_args()
235 di = i - posonlyarg_count - arg_count + default_count; in append_ast_args()
238 APPEND_EXPR((expr_ty)asdl_seq_GET(args->defaults, di), PR_TEST); in append_ast_args()
245 /* vararg, or bare '*' if no varargs but keyword-only arguments present */ in append_ast_args()
246 if (args->vararg || asdl_seq_LEN(args->kwonlyargs)) { in append_ast_args()
249 if (args->vararg) { in append_ast_args()
250 APPEND(arg, args->vararg); in append_ast_args()
254 /* keyword-only arguments */ in append_ast_args()
255 arg_count = asdl_seq_LEN(args->kwonlyargs); in append_ast_args()
256 default_count = asdl_seq_LEN(args->kw_defaults); in append_ast_args()
259 APPEND(arg, (arg_ty)asdl_seq_GET(args->kwonlyargs, i)); in append_ast_args()
261 di = i - arg_count + default_count; in append_ast_args()
263 expr_ty default_ = (expr_ty)asdl_seq_GET(args->kw_defaults, di); in append_ast_args()
272 if (args->kwarg) { in append_ast_args()
275 APPEND(arg, args->kwarg); in append_ast_args()
285 Py_ssize_t n_positional = (asdl_seq_LEN(e->v.Lambda.args->args) + in append_ast_lambda()
286 asdl_seq_LEN(e->v.Lambda.args->posonlyargs)); in append_ast_lambda()
288 APPEND(args, e->v.Lambda.args); in append_ast_lambda()
290 APPEND_EXPR(e->v.Lambda.body, PR_TEST); in append_ast_lambda()
299 APPEND_EXPR(e->v.IfExp.body, PR_TEST + 1); in append_ast_ifexp()
301 APPEND_EXPR(e->v.IfExp.test, PR_TEST + 1); in append_ast_ifexp()
303 APPEND_EXPR(e->v.IfExp.orelse, PR_TEST); in append_ast_ifexp()
315 value_count = asdl_seq_LEN(e->v.Dict.values); in append_ast_dict()
319 key_node = (expr_ty)asdl_seq_GET(e->v.Dict.keys, i); in append_ast_dict()
323 APPEND_EXPR((expr_ty)asdl_seq_GET(e->v.Dict.values, i), PR_TEST); in append_ast_dict()
327 APPEND_EXPR((expr_ty)asdl_seq_GET(e->v.Dict.values, i), PR_EXPR); in append_ast_dict()
340 elem_count = asdl_seq_LEN(e->v.Set.elts); in append_ast_set()
343 APPEND_EXPR((expr_ty)asdl_seq_GET(e->v.Set.elts, i), PR_TEST); in append_ast_set()
355 elem_count = asdl_seq_LEN(e->v.List.elts); in append_ast_list()
358 APPEND_EXPR((expr_ty)asdl_seq_GET(e->v.List.elts, i), PR_TEST); in append_ast_list()
369 elem_count = asdl_seq_LEN(e->v.Tuple.elts); in append_ast_tuple()
379 APPEND_EXPR((expr_ty)asdl_seq_GET(e->v.Tuple.elts, i), PR_TEST); in append_ast_tuple()
392 APPEND_STR(gen->is_async ? " async for " : " for "); in append_ast_comprehension()
393 APPEND_EXPR(gen->target, PR_TUPLE); in append_ast_comprehension()
395 APPEND_EXPR(gen->iter, PR_TEST + 1); in append_ast_comprehension()
397 if_count = asdl_seq_LEN(gen->ifs); in append_ast_comprehension()
400 APPEND_EXPR((expr_ty)asdl_seq_GET(gen->ifs, i), PR_TEST + 1); in append_ast_comprehension()
422 APPEND_EXPR(e->v.GeneratorExp.elt, PR_TEST); in append_ast_genexp()
423 APPEND(comprehensions, e->v.GeneratorExp.generators); in append_ast_genexp()
431 APPEND_EXPR(e->v.ListComp.elt, PR_TEST); in append_ast_listcomp()
432 APPEND(comprehensions, e->v.ListComp.generators); in append_ast_listcomp()
440 APPEND_EXPR(e->v.SetComp.elt, PR_TEST); in append_ast_setcomp()
441 APPEND(comprehensions, e->v.SetComp.generators); in append_ast_setcomp()
449 APPEND_EXPR(e->v.DictComp.key, PR_TEST); in append_ast_dictcomp()
451 APPEND_EXPR(e->v.DictComp.value, PR_TEST); in append_ast_dictcomp()
452 APPEND(comprehensions, e->v.DictComp.generators); in append_ast_dictcomp()
466 comparators = e->v.Compare.comparators; in append_ast_compare()
467 ops = e->v.Compare.ops; in append_ast_compare()
472 APPEND_EXPR(e->v.Compare.left, PR_CMP + 1); in append_ast_compare()
509 return -1; in append_ast_compare()
523 if (kw->arg == NULL) { in append_ast_keyword()
527 if (-1 == _PyUnicodeWriter_WriteStr(writer, kw->arg)) { in append_ast_keyword()
528 return -1; in append_ast_keyword()
534 APPEND_EXPR(kw->value, PR_TEST); in append_ast_keyword()
545 APPEND_EXPR(e->v.Call.func, PR_ATOM); in append_ast_call()
547 arg_count = asdl_seq_LEN(e->v.Call.args); in append_ast_call()
548 kw_count = asdl_seq_LEN(e->v.Call.keywords); in append_ast_call()
550 expr = (expr_ty)asdl_seq_GET(e->v.Call.args, 0); in append_ast_call()
551 if (expr->kind == GeneratorExp_kind) { in append_ast_call()
562 APPEND_EXPR((expr_ty)asdl_seq_GET(e->v.Call.args, i), PR_TEST); in append_ast_call()
567 APPEND(keyword, (keyword_ty)asdl_seq_GET(e->v.Call.keywords, i)); in append_ast_call()
578 temp = PyUnicode_Replace(orig, &_Py_STR(open_br), &_Py_STR(dbl_open_br), -1); in escape_braces()
582 result = PyUnicode_Replace(temp, &_Py_STR(close_br), &_Py_STR(dbl_close_br), -1); in escape_braces()
591 int result = -1; in append_fstring_unicode()
603 switch (e->kind) { in append_fstring_element()
605 return append_fstring_unicode(writer, e->v.Constant.value); in append_fstring_element()
612 "unknown expression kind inside f-string"); in append_fstring_element()
613 return -1; in append_fstring_element()
630 if (-1 == append_fstring_element(&body_writer, in build_fstring_body()
645 int result = -1; in append_joinedstr()
646 PyObject *body = build_fstring_body(e->v.JoinedStr.values, is_format_spec); in append_joinedstr()
648 return -1; in append_joinedstr()
652 if (-1 != append_charp(writer, "f") && in append_joinedstr()
653 -1 != append_repr(writer, body)) in append_joinedstr()
668 const char *conversion; in append_formattedvalue() local
672 PyObject *temp_fv_str = expr_as_unicode(e->v.FormattedValue.value, PR_TEST + 1); in append_formattedvalue()
674 return -1; in append_formattedvalue()
681 if (-1 == append_charp(writer, outer_brace)) { in append_formattedvalue()
683 return -1; in append_formattedvalue()
685 if (-1 == _PyUnicodeWriter_WriteStr(writer, temp_fv_str)) { in append_formattedvalue()
687 return -1; in append_formattedvalue()
691 if (e->v.FormattedValue.conversion > 0) { in append_formattedvalue()
692 switch (e->v.FormattedValue.conversion) { in append_formattedvalue()
694 conversion = "!a"; in append_formattedvalue()
697 conversion = "!r"; in append_formattedvalue()
700 conversion = "!s"; in append_formattedvalue()
704 "unknown f-value conversion kind"); in append_formattedvalue()
705 return -1; in append_formattedvalue()
707 APPEND_STR(conversion); in append_formattedvalue()
709 if (e->v.FormattedValue.format_spec) { in append_formattedvalue()
710 if (-1 == _PyUnicodeWriter_WriteASCIIString(writer, ":", 1) || in append_formattedvalue()
711 -1 == append_fstring_element(writer, in append_formattedvalue()
712 e->v.FormattedValue.format_spec, in append_formattedvalue()
716 return -1; in append_formattedvalue()
724 append_ast_constant(_PyUnicodeWriter *writer, PyObject *constant) in append_ast_constant() argument
726 if (PyTuple_CheckExact(constant)) { in append_ast_constant()
729 elem_count = PyTuple_GET_SIZE(constant); in append_ast_constant()
733 if (append_ast_constant(writer, PyTuple_GET_ITEM(constant, i)) < 0) { in append_ast_constant()
734 return -1; in append_ast_constant()
742 return append_repr(writer, constant); in append_ast_constant()
749 expr_ty v = e->v.Attribute.value; in append_ast_attribute()
754 if (v->kind == Constant_kind && PyLong_CheckExact(v->v.Constant.value)) { in append_ast_attribute()
762 return _PyUnicodeWriter_WriteStr(writer, e->v.Attribute.attr); in append_ast_attribute()
768 if (e->v.Slice.lower) { in append_ast_slice()
769 APPEND_EXPR(e->v.Slice.lower, PR_TEST); in append_ast_slice()
774 if (e->v.Slice.upper) { in append_ast_slice()
775 APPEND_EXPR(e->v.Slice.upper, PR_TEST); in append_ast_slice()
778 if (e->v.Slice.step) { in append_ast_slice()
780 APPEND_EXPR(e->v.Slice.step, PR_TEST); in append_ast_slice()
788 APPEND_EXPR(e->v.Subscript.value, PR_ATOM); in append_ast_subscript()
790 APPEND_EXPR(e->v.Subscript.slice, PR_TUPLE); in append_ast_subscript()
798 APPEND_EXPR(e->v.Starred.value, PR_EXPR); in append_ast_starred()
805 if (!e->v.Yield.value) { in append_ast_yield()
810 APPEND_EXPR(e->v.Yield.value, PR_TEST); in append_ast_yield()
818 APPEND_EXPR(e->v.YieldFrom.value, PR_TEST); in append_ast_yield_from()
827 APPEND_EXPR(e->v.Await.value, PR_ATOM); in append_ast_await()
836 APPEND_EXPR(e->v.NamedExpr.target, PR_ATOM); in append_named_expr()
838 APPEND_EXPR(e->v.NamedExpr.value, PR_ATOM); in append_named_expr()
846 switch (e->kind) { in append_ast_expr()
880 if (e->v.Constant.value == Py_Ellipsis) { in append_ast_expr()
883 if (e->v.Constant.kind != NULL in append_ast_expr()
884 && -1 == _PyUnicodeWriter_WriteStr(writer, e->v.Constant.kind)) { in append_ast_expr()
885 return -1; in append_ast_expr()
887 return append_ast_constant(writer, e->v.Constant.value); in append_ast_expr()
902 return _PyUnicodeWriter_WriteStr(writer, e->v.Name.id); in append_ast_expr()
913 return -1; in append_ast_expr()
921 return -1; in maybe_init_static_strings()
933 if (-1 == maybe_init_static_strings() || in expr_as_unicode()
934 -1 == append_ast_expr(&writer, e, level)) in expr_as_unicode()