• Home
  • Raw
  • Download

Lines Matching +full:- +full:v

54         if (!validate_expr(state, comp->target, Store) ||  in validate_comprehension()
55 !validate_expr(state, comp->iter, Load) || in validate_comprehension()
56 !validate_exprs(state, comp->ifs, Load, 0)) in validate_comprehension()
67 if (!validate_expr(state, (asdl_seq_GET(keywords, i))->value, Load)) in validate_keywords()
78 if (arg->annotation && !validate_expr(state, arg->annotation, Load)) in validate_args()
102 if (!validate_args(state, args->posonlyargs) || !validate_args(state, args->args)) { in validate_arguments()
105 if (args->vararg && args->vararg->annotation in validate_arguments()
106 && !validate_expr(state, args->vararg->annotation, Load)) { in validate_arguments()
109 if (!validate_args(state, args->kwonlyargs)) in validate_arguments()
111 if (args->kwarg && args->kwarg->annotation in validate_arguments()
112 && !validate_expr(state, args->kwarg->annotation, Load)) { in validate_arguments()
115 if (asdl_seq_LEN(args->defaults) > asdl_seq_LEN(args->posonlyargs) + asdl_seq_LEN(args->args)) { in validate_arguments()
119 if (asdl_seq_LEN(args->kw_defaults) != asdl_seq_LEN(args->kwonlyargs)) { in validate_arguments()
124 …return validate_exprs(state, args->defaults, Load, 0) && validate_exprs(state, args->kw_defaults, … in validate_arguments()
142 if (++state->recursion_depth > state->recursion_limit) { in validate_constant()
171 --state->recursion_depth; in validate_constant()
186 int ret = -1; in validate_expr()
187 if (++state->recursion_depth > state->recursion_limit) { in validate_expr()
196 switch (exp->kind) { in validate_expr()
198 actual_ctx = exp->v.Attribute.ctx; in validate_expr()
201 actual_ctx = exp->v.Subscript.ctx; in validate_expr()
204 actual_ctx = exp->v.Starred.ctx; in validate_expr()
207 if (!validate_name(exp->v.Name.id)) { in validate_expr()
210 actual_ctx = exp->v.Name.ctx; in validate_expr()
213 actual_ctx = exp->v.List.ctx; in validate_expr()
216 actual_ctx = exp->v.Tuple.ctx; in validate_expr()
235 switch (exp->kind) { in validate_expr()
237 if (asdl_seq_LEN(exp->v.BoolOp.values) < 2) { in validate_expr()
241 ret = validate_exprs(state, exp->v.BoolOp.values, Load, 0); in validate_expr()
244 ret = validate_expr(state, exp->v.BinOp.left, Load) && in validate_expr()
245 validate_expr(state, exp->v.BinOp.right, Load); in validate_expr()
248 ret = validate_expr(state, exp->v.UnaryOp.operand, Load); in validate_expr()
251 ret = validate_arguments(state, exp->v.Lambda.args) && in validate_expr()
252 validate_expr(state, exp->v.Lambda.body, Load); in validate_expr()
255 ret = validate_expr(state, exp->v.IfExp.test, Load) && in validate_expr()
256 validate_expr(state, exp->v.IfExp.body, Load) && in validate_expr()
257 validate_expr(state, exp->v.IfExp.orelse, Load); in validate_expr()
260 if (asdl_seq_LEN(exp->v.Dict.keys) != asdl_seq_LEN(exp->v.Dict.values)) { in validate_expr()
267 ret = validate_exprs(state, exp->v.Dict.keys, Load, /*null_ok=*/ 1) && in validate_expr()
268 validate_exprs(state, exp->v.Dict.values, Load, /*null_ok=*/ 0); in validate_expr()
271 ret = validate_exprs(state, exp->v.Set.elts, Load, 0); in validate_expr()
275 ret = validate_comprehension(state, exp->v.NAME.generators) && \ in validate_expr()
276 validate_expr(state, exp->v.NAME.elt, Load); \ in validate_expr()
283 ret = validate_comprehension(state, exp->v.DictComp.generators) && in validate_expr()
284 validate_expr(state, exp->v.DictComp.key, Load) && in validate_expr()
285 validate_expr(state, exp->v.DictComp.value, Load); in validate_expr()
288 ret = !exp->v.Yield.value || validate_expr(state, exp->v.Yield.value, Load); in validate_expr()
291 ret = validate_expr(state, exp->v.YieldFrom.value, Load); in validate_expr()
294 ret = validate_expr(state, exp->v.Await.value, Load); in validate_expr()
297 if (!asdl_seq_LEN(exp->v.Compare.comparators)) { in validate_expr()
301 if (asdl_seq_LEN(exp->v.Compare.comparators) != in validate_expr()
302 asdl_seq_LEN(exp->v.Compare.ops)) { in validate_expr()
307 ret = validate_exprs(state, exp->v.Compare.comparators, Load, 0) && in validate_expr()
308 validate_expr(state, exp->v.Compare.left, Load); in validate_expr()
311 ret = validate_expr(state, exp->v.Call.func, Load) && in validate_expr()
312 validate_exprs(state, exp->v.Call.args, Load, 0) && in validate_expr()
313 validate_keywords(state, exp->v.Call.keywords); in validate_expr()
316 if (!validate_constant(state, exp->v.Constant.value)) { in validate_expr()
322 ret = validate_exprs(state, exp->v.JoinedStr.values, Load, 0); in validate_expr()
325 if (validate_expr(state, exp->v.FormattedValue.value, Load) == 0) in validate_expr()
327 if (exp->v.FormattedValue.format_spec) { in validate_expr()
328 ret = validate_expr(state, exp->v.FormattedValue.format_spec, Load); in validate_expr()
334 ret = validate_expr(state, exp->v.Attribute.value, Load); in validate_expr()
337 ret = validate_expr(state, exp->v.Subscript.slice, Load) && in validate_expr()
338 validate_expr(state, exp->v.Subscript.value, Load); in validate_expr()
341 ret = validate_expr(state, exp->v.Starred.value, ctx); in validate_expr()
344 ret = (!exp->v.Slice.lower || validate_expr(state, exp->v.Slice.lower, Load)) && in validate_expr()
345 (!exp->v.Slice.upper || validate_expr(state, exp->v.Slice.upper, Load)) && in validate_expr()
346 (!exp->v.Slice.step || validate_expr(state, exp->v.Slice.step, Load)); in validate_expr()
349 ret = validate_exprs(state, exp->v.List.elts, ctx, 0); in validate_expr()
352 ret = validate_exprs(state, exp->v.Tuple.elts, ctx, 0); in validate_expr()
355 ret = validate_expr(state, exp->v.NamedExpr.value, Load); in validate_expr()
367 state->recursion_depth--; in validate_expr()
373 // set of non-recursive literals that have already been checked with
378 assert(exp->kind == Constant_kind); in ensure_literal_number()
379 PyObject *value = exp->v.Constant.value; in ensure_literal_number()
388 assert(exp->kind == UnaryOp_kind); in ensure_literal_negative()
390 if (exp->v.UnaryOp.op != USub) { in ensure_literal_negative()
394 expr_ty operand = exp->v.UnaryOp.operand; in ensure_literal_negative()
395 if (operand->kind != Constant_kind) { in ensure_literal_negative()
405 assert(exp->kind == BinOp_kind); in ensure_literal_complex()
406 expr_ty left = exp->v.BinOp.left; in ensure_literal_complex()
407 expr_ty right = exp->v.BinOp.right; in ensure_literal_complex()
409 if (exp->v.BinOp.op != Add && exp->v.BinOp.op != Sub) { in ensure_literal_complex()
413 switch (left->kind) in ensure_literal_complex()
429 switch (right->kind) in ensure_literal_complex()
449 switch (exp->kind) in validate_pattern_match_value()
458 PyObject *literal = exp->v.Constant.value; in validate_pattern_match_value()
508 int ret = -1; in validate_pattern()
509 if (++state->recursion_depth > state->recursion_limit) { in validate_pattern()
514 switch (p->kind) { in validate_pattern()
516 ret = validate_pattern_match_value(state, p->v.MatchValue.value); in validate_pattern()
519 ret = p->v.MatchSingleton.value == Py_None || PyBool_Check(p->v.MatchSingleton.value); in validate_pattern()
526 ret = validate_patterns(state, p->v.MatchSequence.patterns, /*star_ok=*/1); in validate_pattern()
529 if (asdl_seq_LEN(p->v.MatchMapping.keys) != asdl_seq_LEN(p->v.MatchMapping.patterns)) { in validate_pattern()
536 if (p->v.MatchMapping.rest && !validate_capture(p->v.MatchMapping.rest)) { in validate_pattern()
541 asdl_expr_seq *keys = p->v.MatchMapping.keys; in validate_pattern()
544 if (key->kind == Constant_kind) { in validate_pattern()
545 PyObject *literal = key->v.Constant.value; in validate_pattern()
560 ret = validate_patterns(state, p->v.MatchMapping.patterns, /*star_ok=*/0); in validate_pattern()
563 … if (asdl_seq_LEN(p->v.MatchClass.kwd_attrs) != asdl_seq_LEN(p->v.MatchClass.kwd_patterns)) { in validate_pattern()
569 if (!validate_expr(state, p->v.MatchClass.cls, Load)) { in validate_pattern()
574 expr_ty cls = p->v.MatchClass.cls; in validate_pattern()
576 if (cls->kind == Name_kind) { in validate_pattern()
579 else if (cls->kind == Attribute_kind) { in validate_pattern()
580 cls = cls->v.Attribute.value; in validate_pattern()
591 for (Py_ssize_t i = 0; i < asdl_seq_LEN(p->v.MatchClass.kwd_attrs); i++) { in validate_pattern()
592 PyObject *identifier = asdl_seq_GET(p->v.MatchClass.kwd_attrs, i); in validate_pattern()
599 if (!validate_patterns(state, p->v.MatchClass.patterns, /*star_ok=*/0)) { in validate_pattern()
604 ret = validate_patterns(state, p->v.MatchClass.kwd_patterns, /*star_ok=*/0); in validate_pattern()
612 ret = p->v.MatchStar.name == NULL || validate_capture(p->v.MatchStar.name); in validate_pattern()
615 if (p->v.MatchAs.name && !validate_capture(p->v.MatchAs.name)) { in validate_pattern()
619 if (p->v.MatchAs.pattern == NULL) { in validate_pattern()
622 else if (p->v.MatchAs.name == NULL) { in validate_pattern()
628 ret = validate_pattern(state, p->v.MatchAs.pattern, /*star_ok=*/0); in validate_pattern()
632 if (asdl_seq_LEN(p->v.MatchOr.patterns) < 2) { in validate_pattern()
638 ret = validate_patterns(state, p->v.MatchOr.patterns, /*star_ok=*/0); in validate_pattern()
647 state->recursion_depth--; in validate_pattern()
677 int ret = -1; in validate_stmt()
679 if (++state->recursion_depth > state->recursion_limit) { in validate_stmt()
684 switch (stmt->kind) { in validate_stmt()
686 ret = validate_body(state, stmt->v.FunctionDef.body, "FunctionDef") && in validate_stmt()
687 validate_arguments(state, stmt->v.FunctionDef.args) && in validate_stmt()
688 validate_exprs(state, stmt->v.FunctionDef.decorator_list, Load, 0) && in validate_stmt()
689 (!stmt->v.FunctionDef.returns || in validate_stmt()
690 validate_expr(state, stmt->v.FunctionDef.returns, Load)); in validate_stmt()
693 ret = validate_body(state, stmt->v.ClassDef.body, "ClassDef") && in validate_stmt()
694 validate_exprs(state, stmt->v.ClassDef.bases, Load, 0) && in validate_stmt()
695 validate_keywords(state, stmt->v.ClassDef.keywords) && in validate_stmt()
696 validate_exprs(state, stmt->v.ClassDef.decorator_list, Load, 0); in validate_stmt()
699 ret = !stmt->v.Return.value || validate_expr(state, stmt->v.Return.value, Load); in validate_stmt()
702 ret = validate_assignlist(state, stmt->v.Delete.targets, Del); in validate_stmt()
705 ret = validate_assignlist(state, stmt->v.Assign.targets, Store) && in validate_stmt()
706 validate_expr(state, stmt->v.Assign.value, Load); in validate_stmt()
709 ret = validate_expr(state, stmt->v.AugAssign.target, Store) && in validate_stmt()
710 validate_expr(state, stmt->v.AugAssign.value, Load); in validate_stmt()
713 if (stmt->v.AnnAssign.target->kind != Name_kind && in validate_stmt()
714 stmt->v.AnnAssign.simple) { in validate_stmt()
716 "AnnAssign with simple non-Name target"); in validate_stmt()
719 ret = validate_expr(state, stmt->v.AnnAssign.target, Store) && in validate_stmt()
720 (!stmt->v.AnnAssign.value || in validate_stmt()
721 validate_expr(state, stmt->v.AnnAssign.value, Load)) && in validate_stmt()
722 validate_expr(state, stmt->v.AnnAssign.annotation, Load); in validate_stmt()
725 ret = validate_expr(state, stmt->v.For.target, Store) && in validate_stmt()
726 validate_expr(state, stmt->v.For.iter, Load) && in validate_stmt()
727 validate_body(state, stmt->v.For.body, "For") && in validate_stmt()
728 validate_stmts(state, stmt->v.For.orelse); in validate_stmt()
731 ret = validate_expr(state, stmt->v.AsyncFor.target, Store) && in validate_stmt()
732 validate_expr(state, stmt->v.AsyncFor.iter, Load) && in validate_stmt()
733 validate_body(state, stmt->v.AsyncFor.body, "AsyncFor") && in validate_stmt()
734 validate_stmts(state, stmt->v.AsyncFor.orelse); in validate_stmt()
737 ret = validate_expr(state, stmt->v.While.test, Load) && in validate_stmt()
738 validate_body(state, stmt->v.While.body, "While") && in validate_stmt()
739 validate_stmts(state, stmt->v.While.orelse); in validate_stmt()
742 ret = validate_expr(state, stmt->v.If.test, Load) && in validate_stmt()
743 validate_body(state, stmt->v.If.body, "If") && in validate_stmt()
744 validate_stmts(state, stmt->v.If.orelse); in validate_stmt()
747 if (!validate_nonempty_seq(stmt->v.With.items, "items", "With")) in validate_stmt()
749 for (i = 0; i < asdl_seq_LEN(stmt->v.With.items); i++) { in validate_stmt()
750 withitem_ty item = asdl_seq_GET(stmt->v.With.items, i); in validate_stmt()
751 if (!validate_expr(state, item->context_expr, Load) || in validate_stmt()
752 (item->optional_vars && !validate_expr(state, item->optional_vars, Store))) in validate_stmt()
755 ret = validate_body(state, stmt->v.With.body, "With"); in validate_stmt()
758 if (!validate_nonempty_seq(stmt->v.AsyncWith.items, "items", "AsyncWith")) in validate_stmt()
760 for (i = 0; i < asdl_seq_LEN(stmt->v.AsyncWith.items); i++) { in validate_stmt()
761 withitem_ty item = asdl_seq_GET(stmt->v.AsyncWith.items, i); in validate_stmt()
762 if (!validate_expr(state, item->context_expr, Load) || in validate_stmt()
763 (item->optional_vars && !validate_expr(state, item->optional_vars, Store))) in validate_stmt()
766 ret = validate_body(state, stmt->v.AsyncWith.body, "AsyncWith"); in validate_stmt()
769 if (!validate_expr(state, stmt->v.Match.subject, Load) in validate_stmt()
770 || !validate_nonempty_seq(stmt->v.Match.cases, "cases", "Match")) { in validate_stmt()
773 for (i = 0; i < asdl_seq_LEN(stmt->v.Match.cases); i++) { in validate_stmt()
774 match_case_ty m = asdl_seq_GET(stmt->v.Match.cases, i); in validate_stmt()
775 if (!validate_pattern(state, m->pattern, /*star_ok=*/0) in validate_stmt()
776 || (m->guard && !validate_expr(state, m->guard, Load)) in validate_stmt()
777 || !validate_body(state, m->body, "match_case")) { in validate_stmt()
784 if (stmt->v.Raise.exc) { in validate_stmt()
785 ret = validate_expr(state, stmt->v.Raise.exc, Load) && in validate_stmt()
786 (!stmt->v.Raise.cause || validate_expr(state, stmt->v.Raise.cause, Load)); in validate_stmt()
789 if (stmt->v.Raise.cause) { in validate_stmt()
796 if (!validate_body(state, stmt->v.Try.body, "Try")) in validate_stmt()
798 if (!asdl_seq_LEN(stmt->v.Try.handlers) && in validate_stmt()
799 !asdl_seq_LEN(stmt->v.Try.finalbody)) { in validate_stmt()
803 if (!asdl_seq_LEN(stmt->v.Try.handlers) && in validate_stmt()
804 asdl_seq_LEN(stmt->v.Try.orelse)) { in validate_stmt()
808 for (i = 0; i < asdl_seq_LEN(stmt->v.Try.handlers); i++) { in validate_stmt()
809 excepthandler_ty handler = asdl_seq_GET(stmt->v.Try.handlers, i); in validate_stmt()
810 if ((handler->v.ExceptHandler.type && in validate_stmt()
811 !validate_expr(state, handler->v.ExceptHandler.type, Load)) || in validate_stmt()
812 !validate_body(state, handler->v.ExceptHandler.body, "ExceptHandler")) in validate_stmt()
815 ret = (!asdl_seq_LEN(stmt->v.Try.finalbody) || in validate_stmt()
816 validate_stmts(state, stmt->v.Try.finalbody)) && in validate_stmt()
817 (!asdl_seq_LEN(stmt->v.Try.orelse) || in validate_stmt()
818 validate_stmts(state, stmt->v.Try.orelse)); in validate_stmt()
821 ret = validate_expr(state, stmt->v.Assert.test, Load) && in validate_stmt()
822 (!stmt->v.Assert.msg || validate_expr(state, stmt->v.Assert.msg, Load)); in validate_stmt()
825 ret = validate_nonempty_seq(stmt->v.Import.names, "names", "Import"); in validate_stmt()
828 if (stmt->v.ImportFrom.level < 0) { in validate_stmt()
832 ret = validate_nonempty_seq(stmt->v.ImportFrom.names, "names", "ImportFrom"); in validate_stmt()
835 ret = validate_nonempty_seq(stmt->v.Global.names, "names", "Global"); in validate_stmt()
838 ret = validate_nonempty_seq(stmt->v.Nonlocal.names, "names", "Nonlocal"); in validate_stmt()
841 ret = validate_expr(state, stmt->v.Expr.value, Load); in validate_stmt()
844 ret = validate_body(state, stmt->v.AsyncFunctionDef.body, "AsyncFunctionDef") && in validate_stmt()
845 validate_arguments(state, stmt->v.AsyncFunctionDef.args) && in validate_stmt()
846 validate_exprs(state, stmt->v.AsyncFunctionDef.decorator_list, Load, 0) && in validate_stmt()
847 (!stmt->v.AsyncFunctionDef.returns || in validate_stmt()
848 validate_expr(state, stmt->v.AsyncFunctionDef.returns, Load)); in validate_stmt()
861 state->recursion_depth--; in validate_stmt()
924 int res = -1; in _PyAST_Validate()
936 starting_recursion_depth = (tstate->recursion_depth < INT_MAX / COMPILER_STACK_FRAME_SCALE) ? in _PyAST_Validate()
937 tstate->recursion_depth * COMPILER_STACK_FRAME_SCALE : tstate->recursion_depth; in _PyAST_Validate()
942 switch (mod->kind) { in _PyAST_Validate()
944 res = validate_stmts(&state, mod->v.Module.body); in _PyAST_Validate()
947 res = validate_stmts(&state, mod->v.Interactive.body); in _PyAST_Validate()
950 res = validate_expr(&state, mod->v.Expression.body, Load); in _PyAST_Validate()
953 res = validate_exprs(&state, mod->v.FunctionType.argtypes, Load, /*null_ok=*/0) && in _PyAST_Validate()
954 validate_expr(&state, mod->v.FunctionType.returns, Load); in _PyAST_Validate()
981 if (st->kind != Expr_kind) { in _PyAST_GetDocString()
984 expr_ty e = st->v.Expr.value; in _PyAST_GetDocString()
985 if (e->kind == Constant_kind && PyUnicode_CheckExact(e->v.Constant.value)) { in _PyAST_GetDocString()
986 return e->v.Constant.value; in _PyAST_GetDocString()