Lines Matching refs:st
59 ste_new(struct symtable *st, identifier name, _Py_block_ty block,
74 ste->ste_table = st;
98 if (st->st_cur != NULL &&
99 (st->st_cur->ste_nested ||
100 st->st_cur->ste_type == FunctionBlock))
119 if (PyDict_SetItem(st->st_blocks, ste->ste_id, (PyObject *)ste) < 0)
204 static int symtable_analyze(struct symtable *st);
205 static int symtable_enter_block(struct symtable *st, identifier name,
209 static int symtable_exit_block(struct symtable *st);
210 static int symtable_visit_stmt(struct symtable *st, stmt_ty s);
211 static int symtable_visit_expr(struct symtable *st, expr_ty s);
212 static int symtable_visit_genexp(struct symtable *st, expr_ty s);
213 static int symtable_visit_listcomp(struct symtable *st, expr_ty s);
214 static int symtable_visit_setcomp(struct symtable *st, expr_ty s);
215 static int symtable_visit_dictcomp(struct symtable *st, expr_ty s);
216 static int symtable_visit_arguments(struct symtable *st, arguments_ty);
217 static int symtable_visit_excepthandler(struct symtable *st, excepthandler_ty);
218 static int symtable_visit_alias(struct symtable *st, alias_ty);
219 static int symtable_visit_comprehension(struct symtable *st, comprehension_ty);
220 static int symtable_visit_keyword(struct symtable *st, keyword_ty);
221 static int symtable_visit_params(struct symtable *st, asdl_arg_seq *args);
222 static int symtable_visit_annotation(struct symtable *st, expr_ty annotation);
223 static int symtable_visit_argannotations(struct symtable *st, asdl_arg_seq *args);
224 static int symtable_implicit_arg(struct symtable *st, int pos);
225 static int symtable_visit_annotations(struct symtable *st, stmt_ty, arguments_ty, expr_ty);
226 static int symtable_visit_withitem(struct symtable *st, withitem_ty item);
227 static int symtable_visit_match_case(struct symtable *st, match_case_ty m);
228 static int symtable_visit_pattern(struct symtable *st, pattern_ty s);
229 static int symtable_raise_if_annotation_block(struct symtable *st, const char *, expr_ty);
230 static int symtable_raise_if_comprehension_block(struct symtable *st, expr_ty);
239 struct symtable *st;
241 st = (struct symtable *)PyMem_Malloc(sizeof(struct symtable));
242 if (st == NULL) {
247 st->st_filename = NULL;
248 st->st_blocks = NULL;
250 if ((st->st_stack = PyList_New(0)) == NULL)
252 if ((st->st_blocks = PyDict_New()) == NULL)
254 st->st_cur = NULL;
255 st->st_private = NULL;
256 return st;
258 _PySymtable_Free(st);
277 struct symtable *st = symtable_new();
284 if (st == NULL)
287 _PySymtable_Free(st);
291 st->st_filename = filename;
292 st->st_future = future;
297 _PySymtable_Free(st);
304 st->recursion_depth = starting_recursion_depth;
305 st->recursion_limit = (recursion_limit < INT_MAX / COMPILER_STACK_FRAME_SCALE) ?
309 if (!symtable_enter_block(st, &_Py_ID(top), ModuleBlock, (void *)mod, 0, 0, 0, 0)) {
310 _PySymtable_Free(st);
314 st->st_top = st->st_cur;
319 if (!symtable_visit_stmt(st,
324 if (!symtable_visit_expr(st, mod->v.Expression.body))
330 if (!symtable_visit_stmt(st,
339 if (!symtable_exit_block(st)) {
340 _PySymtable_Free(st);
344 if (st->recursion_depth != starting_recursion_depth) {
347 starting_recursion_depth, st->recursion_depth);
348 _PySymtable_Free(st);
352 if (symtable_analyze(st))
353 return st;
354 _PySymtable_Free(st);
357 (void) symtable_exit_block(st);
358 _PySymtable_Free(st);
364 _PySymtable_Free(struct symtable *st)
366 Py_XDECREF(st->st_filename);
367 Py_XDECREF(st->st_blocks);
368 Py_XDECREF(st->st_stack);
369 PyMem_Free((void *)st);
373 PySymtable_Lookup(struct symtable *st, void *key)
380 v = PyDict_GetItemWithError(st->st_blocks, k);
927 symtable_analyze(struct symtable *st)
940 r = analyze_block(st->st_top, NULL, free, global);
952 symtable_exit_block(struct symtable *st)
956 st->st_cur = NULL;
957 size = PyList_GET_SIZE(st->st_stack);
959 if (PyList_SetSlice(st->st_stack, size - 1, size, NULL) < 0)
962 st->st_cur = (PySTEntryObject *)PyList_GET_ITEM(st->st_stack, size - 1);
968 symtable_enter_block(struct symtable *st, identifier name, _Py_block_ty block,
974 ste = ste_new(st, name, block, ast, lineno, col_offset, end_lineno, end_col_offset);
977 if (PyList_Append(st->st_stack, (PyObject *)ste) < 0) {
981 prev = st->st_cur;
991 st->st_cur = ste;
1001 st->st_global = st->st_cur->ste_symbols;
1012 symtable_lookup(struct symtable *st, PyObject *name)
1014 PyObject *mangled = _Py_Mangle(st->st_private, name);
1017 long ret = _PyST_GetSymbol(st->st_cur, mangled);
1023 symtable_add_def_helper(struct symtable *st, PyObject *name, int flag, struct _symtable_entry *ste,
1029 PyObject *mangled = _Py_Mangle(st->st_private, name);
1040 PyErr_RangedSyntaxLocationObject(st->st_filename,
1062 PyErr_RangedSyntaxLocationObject(st->st_filename,
1085 if ((o = PyDict_GetItemWithError(st->st_global, mangled))) {
1094 if (PyDict_SetItem(st->st_global, mangled, o) < 0) {
1109 symtable_add_def(struct symtable *st, PyObject *name, int flag,
1112 return symtable_add_def_helper(st, name, flag, st->st_cur,
1166 symtable_record_directive(struct symtable *st, identifier name, int lineno,
1171 if (!st->st_cur->ste_directives) {
1172 st->st_cur->ste_directives = PyList_New(0);
1173 if (!st->st_cur->ste_directives)
1176 mangled = _Py_Mangle(st->st_private, name);
1182 res = PyList_Append(st->st_cur->ste_directives, data);
1189 symtable_visit_stmt(struct symtable *st, stmt_ty s)
1191 if (++st->recursion_depth > st->recursion_limit) {
1194 VISIT_QUIT(st, 0);
1198 if (!symtable_add_def(st, s->v.FunctionDef.name, DEF_LOCAL, LOCATION(s)))
1199 VISIT_QUIT(st, 0);
1201 VISIT_SEQ(st, expr, s->v.FunctionDef.args->defaults);
1203 VISIT_SEQ_WITH_NULL(st, expr, s->v.FunctionDef.args->kw_defaults);
1204 if (!symtable_visit_annotations(st, s, s->v.FunctionDef.args,
1206 VISIT_QUIT(st, 0);
1208 VISIT_SEQ(st, expr, s->v.FunctionDef.decorator_list);
1209 if (!symtable_enter_block(st, s->v.FunctionDef.name,
1212 VISIT_QUIT(st, 0);
1213 VISIT(st, arguments, s->v.FunctionDef.args);
1214 VISIT_SEQ(st, stmt, s->v.FunctionDef.body);
1215 if (!symtable_exit_block(st))
1216 VISIT_QUIT(st, 0);
1220 if (!symtable_add_def(st, s->v.ClassDef.name, DEF_LOCAL, LOCATION(s)))
1221 VISIT_QUIT(st, 0);
1222 VISIT_SEQ(st, expr, s->v.ClassDef.bases);
1223 VISIT_SEQ(st, keyword, s->v.ClassDef.keywords);
1225 VISIT_SEQ(st, expr, s->v.ClassDef.decorator_list);
1226 if (!symtable_enter_block(st, s->v.ClassDef.name, ClassBlock,
1229 VISIT_QUIT(st, 0);
1230 tmp = st->st_private;
1231 st->st_private = s->v.ClassDef.name;
1232 VISIT_SEQ(st, stmt, s->v.ClassDef.body);
1233 st->st_private = tmp;
1234 if (!symtable_exit_block(st))
1235 VISIT_QUIT(st, 0);
1240 VISIT(st, expr, s->v.Return.value);
1241 st->st_cur->ste_returns_value = 1;
1245 VISIT_SEQ(st, expr, s->v.Delete.targets);
1248 VISIT_SEQ(st, expr, s->v.Assign.targets);
1249 VISIT(st, expr, s->v.Assign.value);
1254 long cur = symtable_lookup(st, e_name->v.Name.id);
1256 VISIT_QUIT(st, 0);
1259 && (st->st_cur->ste_symbols != st->st_global)
1264 PyErr_RangedSyntaxLocationObject(st->st_filename,
1269 VISIT_QUIT(st, 0);
1272 !symtable_add_def(st, e_name->v.Name.id,
1274 VISIT_QUIT(st, 0);
1278 && !symtable_add_def(st, e_name->v.Name.id, DEF_LOCAL, LOCATION(e_name))) {
1279 VISIT_QUIT(st, 0);
1284 VISIT(st, expr, s->v.AnnAssign.target);
1286 if (!symtable_visit_annotation(st, s->v.AnnAssign.annotation)) {
1287 VISIT_QUIT(st, 0);
1291 VISIT(st, expr, s->v.AnnAssign.value);
1295 VISIT(st, expr, s->v.AugAssign.target);
1296 VISIT(st, expr, s->v.AugAssign.value);
1299 VISIT(st, expr, s->v.For.target);
1300 VISIT(st, expr, s->v.For.iter);
1301 VISIT_SEQ(st, stmt, s->v.For.body);
1303 VISIT_SEQ(st, stmt, s->v.For.orelse);
1306 VISIT(st, expr, s->v.While.test);
1307 VISIT_SEQ(st, stmt, s->v.While.body);
1309 VISIT_SEQ(st, stmt, s->v.While.orelse);
1313 VISIT(st, expr, s->v.If.test);
1314 VISIT_SEQ(st, stmt, s->v.If.body);
1316 VISIT_SEQ(st, stmt, s->v.If.orelse);
1319 VISIT(st, expr, s->v.Match.subject);
1320 VISIT_SEQ(st, match_case, s->v.Match.cases);
1324 VISIT(st, expr, s->v.Raise.exc);
1326 VISIT(st, expr, s->v.Raise.cause);
1331 VISIT_SEQ(st, stmt, s->v.Try.body);
1332 VISIT_SEQ(st, stmt, s->v.Try.orelse);
1333 VISIT_SEQ(st, excepthandler, s->v.Try.handlers);
1334 VISIT_SEQ(st, stmt, s->v.Try.finalbody);
1337 VISIT_SEQ(st, stmt, s->v.TryStar.body);
1338 VISIT_SEQ(st, stmt, s->v.TryStar.orelse);
1339 VISIT_SEQ(st, excepthandler, s->v.TryStar.handlers);
1340 VISIT_SEQ(st, stmt, s->v.TryStar.finalbody);
1343 VISIT(st, expr, s->v.Assert.test);
1345 VISIT(st, expr, s->v.Assert.msg);
1348 VISIT_SEQ(st, alias, s->v.Import.names);
1351 VISIT_SEQ(st, alias, s->v.ImportFrom.names);
1358 long cur = symtable_lookup(st, name);
1360 VISIT_QUIT(st, 0);
1374 PyErr_RangedSyntaxLocationObject(st->st_filename,
1379 VISIT_QUIT(st, 0);
1381 if (!symtable_add_def(st, name, DEF_GLOBAL, LOCATION(s)))
1382 VISIT_QUIT(st, 0);
1383 if (!symtable_record_directive(st, name, s->lineno, s->col_offset,
1385 VISIT_QUIT(st, 0);
1394 long cur = symtable_lookup(st, name);
1396 VISIT_QUIT(st, 0);
1409 PyErr_RangedSyntaxLocationObject(st->st_filename,
1414 VISIT_QUIT(st, 0);
1416 if (!symtable_add_def(st, name, DEF_NONLOCAL, LOCATION(s)))
1417 VISIT_QUIT(st, 0);
1418 if (!symtable_record_directive(st, name, s->lineno, s->col_offset,
1420 VISIT_QUIT(st, 0);
1425 VISIT(st, expr, s->v.Expr.value);
1433 VISIT_SEQ(st, withitem, s->v.With.items);
1434 VISIT_SEQ(st, stmt, s->v.With.body);
1437 if (!symtable_add_def(st, s->v.AsyncFunctionDef.name, DEF_LOCAL, LOCATION(s)))
1438 VISIT_QUIT(st, 0);
1440 VISIT_SEQ(st, expr, s->v.AsyncFunctionDef.args->defaults);
1442 VISIT_SEQ_WITH_NULL(st, expr,
1444 if (!symtable_visit_annotations(st, s, s->v.AsyncFunctionDef.args,
1446 VISIT_QUIT(st, 0);
1448 VISIT_SEQ(st, expr, s->v.AsyncFunctionDef.decorator_list);
1449 if (!symtable_enter_block(st, s->v.AsyncFunctionDef.name,
1453 VISIT_QUIT(st, 0);
1454 st->st_cur->ste_coroutine = 1;
1455 VISIT(st, arguments, s->v.AsyncFunctionDef.args);
1456 VISIT_SEQ(st, stmt, s->v.AsyncFunctionDef.body);
1457 if (!symtable_exit_block(st))
1458 VISIT_QUIT(st, 0);
1461 VISIT_SEQ(st, withitem, s->v.AsyncWith.items);
1462 VISIT_SEQ(st, stmt, s->v.AsyncWith.body);
1465 VISIT(st, expr, s->v.AsyncFor.target);
1466 VISIT(st, expr, s->v.AsyncFor.iter);
1467 VISIT_SEQ(st, stmt, s->v.AsyncFor.body);
1469 VISIT_SEQ(st, stmt, s->v.AsyncFor.orelse);
1472 VISIT_QUIT(st, 1);
1476 symtable_extend_namedexpr_scope(struct symtable *st, expr_ty e)
1478 assert(st->st_stack);
1484 size = PyList_GET_SIZE(st->st_stack);
1489 ste = (struct _symtable_entry *) PyList_GET_ITEM(st->st_stack, i);
1498 PyErr_RangedSyntaxLocationObject(st->st_filename,
1503 VISIT_QUIT(st, 0);
1512 if (!symtable_add_def(st, target_name, DEF_GLOBAL, LOCATION(e)))
1513 VISIT_QUIT(st, 0);
1515 if (!symtable_add_def(st, target_name, DEF_NONLOCAL, LOCATION(e)))
1516 VISIT_QUIT(st, 0);
1518 if (!symtable_record_directive(st, target_name, LOCATION(e)))
1519 VISIT_QUIT(st, 0);
1521 return symtable_add_def_helper(st, target_name, DEF_LOCAL, ste, LOCATION(e));
1525 if (!symtable_add_def(st, target_name, DEF_GLOBAL, LOCATION(e)))
1526 VISIT_QUIT(st, 0);
1527 if (!symtable_record_directive(st, target_name, LOCATION(e)))
1528 VISIT_QUIT(st, 0);
1530 return symtable_add_def_helper(st, target_name, DEF_GLOBAL, ste, LOCATION(e));
1535 PyErr_RangedSyntaxLocationObject(st->st_filename,
1540 VISIT_QUIT(st, 0);
1552 symtable_handle_namedexpr(struct symtable *st, expr_ty e)
1554 if (st->st_cur->ste_comp_iter_expr > 0) {
1557 PyErr_RangedSyntaxLocationObject(st->st_filename,
1564 if (st->st_cur->ste_comprehension) {
1566 if (!symtable_extend_namedexpr_scope(st, e->v.NamedExpr.target))
1569 VISIT(st, expr, e->v.NamedExpr.value);
1570 VISIT(st, expr, e->v.NamedExpr.target);
1575 symtable_visit_expr(struct symtable *st, expr_ty e)
1577 if (++st->recursion_depth > st->recursion_limit) {
1580 VISIT_QUIT(st, 0);
1584 if (!symtable_raise_if_annotation_block(st, "named expression", e)) {
1585 VISIT_QUIT(st, 0);
1587 if(!symtable_handle_namedexpr(st, e))
1588 VISIT_QUIT(st, 0);
1591 VISIT_SEQ(st, expr, e->v.BoolOp.values);
1594 VISIT(st, expr, e->v.BinOp.left);
1595 VISIT(st, expr, e->v.BinOp.right);
1598 VISIT(st, expr, e->v.UnaryOp.operand);
1602 VISIT_SEQ(st, expr, e->v.Lambda.args->defaults);
1604 VISIT_SEQ_WITH_NULL(st, expr, e->v.Lambda.args->kw_defaults);
1605 if (!symtable_enter_block(st, &_Py_ID(lambda),
1609 VISIT_QUIT(st, 0);
1610 VISIT(st, arguments, e->v.Lambda.args);
1611 VISIT(st, expr, e->v.Lambda.body);
1612 if (!symtable_exit_block(st))
1613 VISIT_QUIT(st, 0);
1617 VISIT(st, expr, e->v.IfExp.test);
1618 VISIT(st, expr, e->v.IfExp.body);
1619 VISIT(st, expr, e->v.IfExp.orelse);
1622 VISIT_SEQ_WITH_NULL(st, expr, e->v.Dict.keys);
1623 VISIT_SEQ(st, expr, e->v.Dict.values);
1626 VISIT_SEQ(st, expr, e->v.Set.elts);
1629 if (!symtable_visit_genexp(st, e))
1630 VISIT_QUIT(st, 0);
1633 if (!symtable_visit_listcomp(st, e))
1634 VISIT_QUIT(st, 0);
1637 if (!symtable_visit_setcomp(st, e))
1638 VISIT_QUIT(st, 0);
1641 if (!symtable_visit_dictcomp(st, e))
1642 VISIT_QUIT(st, 0);
1645 if (!symtable_raise_if_annotation_block(st, "yield expression", e)) {
1646 VISIT_QUIT(st, 0);
1649 VISIT(st, expr, e->v.Yield.value);
1650 st->st_cur->ste_generator = 1;
1651 if (st->st_cur->ste_comprehension) {
1652 return symtable_raise_if_comprehension_block(st, e);
1656 if (!symtable_raise_if_annotation_block(st, "yield expression", e)) {
1657 VISIT_QUIT(st, 0);
1659 VISIT(st, expr, e->v.YieldFrom.value);
1660 st->st_cur->ste_generator = 1;
1661 if (st->st_cur->ste_comprehension) {
1662 return symtable_raise_if_comprehension_block(st, e);
1666 if (!symtable_raise_if_annotation_block(st, "await expression", e)) {
1667 VISIT_QUIT(st, 0);
1669 VISIT(st, expr, e->v.Await.value);
1670 st->st_cur->ste_coroutine = 1;
1673 VISIT(st, expr, e->v.Compare.left);
1674 VISIT_SEQ(st, expr, e->v.Compare.comparators);
1677 VISIT(st, expr, e->v.Call.func);
1678 VISIT_SEQ(st, expr, e->v.Call.args);
1679 VISIT_SEQ_WITH_NULL(st, keyword, e->v.Call.keywords);
1682 VISIT(st, expr, e->v.FormattedValue.value);
1684 VISIT(st, expr, e->v.FormattedValue.format_spec);
1687 VISIT_SEQ(st, expr, e->v.JoinedStr.values);
1694 VISIT(st, expr, e->v.Attribute.value);
1697 VISIT(st, expr, e->v.Subscript.value);
1698 VISIT(st, expr, e->v.Subscript.slice);
1701 VISIT(st, expr, e->v.Starred.value);
1705 VISIT(st, expr, e->v.Slice.lower)
1707 VISIT(st, expr, e->v.Slice.upper)
1709 VISIT(st, expr, e->v.Slice.step)
1712 if (!symtable_add_def(st, e->v.Name.id,
1714 VISIT_QUIT(st, 0);
1717 st->st_cur->ste_type == FunctionBlock &&
1719 if (!symtable_add_def(st, &_Py_ID(__class__), USE, LOCATION(e)))
1720 VISIT_QUIT(st, 0);
1725 VISIT_SEQ(st, expr, e->v.List.elts);
1728 VISIT_SEQ(st, expr, e->v.Tuple.elts);
1731 VISIT_QUIT(st, 1);
1735 symtable_visit_pattern(struct symtable *st, pattern_ty p)
1737 if (++st->recursion_depth > st->recursion_limit) {
1740 VISIT_QUIT(st, 0);
1744 VISIT(st, expr, p->v.MatchValue.value);
1750 VISIT_SEQ(st, pattern, p->v.MatchSequence.patterns);
1754 symtable_add_def(st, p->v.MatchStar.name, DEF_LOCAL, LOCATION(p));
1758 VISIT_SEQ(st, expr, p->v.MatchMapping.keys);
1759 VISIT_SEQ(st, pattern, p->v.MatchMapping.patterns);
1761 symtable_add_def(st, p->v.MatchMapping.rest, DEF_LOCAL, LOCATION(p));
1765 VISIT(st, expr, p->v.MatchClass.cls);
1766 VISIT_SEQ(st, pattern, p->v.MatchClass.patterns);
1767 VISIT_SEQ(st, pattern, p->v.MatchClass.kwd_patterns);
1771 VISIT(st, pattern, p->v.MatchAs.pattern);
1774 symtable_add_def(st, p->v.MatchAs.name, DEF_LOCAL, LOCATION(p));
1778 VISIT_SEQ(st, pattern, p->v.MatchOr.patterns);
1781 VISIT_QUIT(st, 1);
1785 symtable_implicit_arg(struct symtable *st, int pos)
1790 if (!symtable_add_def(st, id, DEF_PARAM, ST_LOCATION(st->st_cur))) {
1799 symtable_visit_params(struct symtable *st, asdl_arg_seq *args)
1808 if (!symtable_add_def(st, arg->arg, DEF_PARAM, LOCATION(arg)))
1816 symtable_visit_annotation(struct symtable *st, expr_ty annotation)
1818 int future_annotations = st->st_future->ff_features & CO_FUTURE_ANNOTATIONS;
1820 !symtable_enter_block(st, &_Py_ID(_annotation), AnnotationBlock,
1824 VISIT_QUIT(st, 0);
1826 VISIT(st, expr, annotation);
1827 if (future_annotations && !symtable_exit_block(st)) {
1828 VISIT_QUIT(st, 0);
1834 symtable_visit_argannotations(struct symtable *st, asdl_arg_seq *args)
1844 VISIT(st, expr, arg->annotation);
1851 symtable_visit_annotations(struct symtable *st, stmt_ty o, arguments_ty a, expr_ty returns)
1853 int future_annotations = st->st_future->ff_features & CO_FUTURE_ANNOTATIONS;
1855 !symtable_enter_block(st, &_Py_ID(_annotation), AnnotationBlock,
1858 VISIT_QUIT(st, 0);
1860 if (a->posonlyargs && !symtable_visit_argannotations(st, a->posonlyargs))
1862 if (a->args && !symtable_visit_argannotations(st, a->args))
1865 VISIT(st, expr, a->vararg->annotation);
1867 VISIT(st, expr, a->kwarg->annotation);
1868 if (a->kwonlyargs && !symtable_visit_argannotations(st, a->kwonlyargs))
1870 if (future_annotations && !symtable_exit_block(st)) {
1871 VISIT_QUIT(st, 0);
1873 if (returns && !symtable_visit_annotation(st, returns)) {
1874 VISIT_QUIT(st, 0);
1880 symtable_visit_arguments(struct symtable *st, arguments_ty a)
1885 if (a->posonlyargs && !symtable_visit_params(st, a->posonlyargs))
1887 if (a->args && !symtable_visit_params(st, a->args))
1889 if (a->kwonlyargs && !symtable_visit_params(st, a->kwonlyargs))
1892 if (!symtable_add_def(st, a->vararg->arg, DEF_PARAM, LOCATION(a->vararg)))
1894 st->st_cur->ste_varargs = 1;
1897 if (!symtable_add_def(st, a->kwarg->arg, DEF_PARAM, LOCATION(a->kwarg)))
1899 st->st_cur->ste_varkeywords = 1;
1906 symtable_visit_excepthandler(struct symtable *st, excepthandler_ty eh)
1909 VISIT(st, expr, eh->v.ExceptHandler.type);
1911 if (!symtable_add_def(st, eh->v.ExceptHandler.name, DEF_LOCAL, LOCATION(eh)))
1913 VISIT_SEQ(st, stmt, eh->v.ExceptHandler.body);
1918 symtable_visit_withitem(struct symtable *st, withitem_ty item)
1920 VISIT(st, expr, item->context_expr);
1922 VISIT(st, expr, item->optional_vars);
1928 symtable_visit_match_case(struct symtable *st, match_case_ty m)
1930 VISIT(st, pattern, m->pattern);
1932 VISIT(st, expr, m->guard);
1934 VISIT_SEQ(st, stmt, m->body);
1939 symtable_visit_alias(struct symtable *st, alias_ty a)
1959 int r = symtable_add_def(st, store_name, DEF_IMPORT, LOCATION(a));
1964 if (st->st_cur->ste_type != ModuleBlock) {
1970 PyErr_RangedSyntaxLocationObject(st->st_filename,
1983 symtable_visit_comprehension(struct symtable *st, comprehension_ty lc)
1985 st->st_cur->ste_comp_iter_target = 1;
1986 VISIT(st, expr, lc->target);
1987 st->st_cur->ste_comp_iter_target = 0;
1988 st->st_cur->ste_comp_iter_expr++;
1989 VISIT(st, expr, lc->iter);
1990 st->st_cur->ste_comp_iter_expr--;
1991 VISIT_SEQ(st, expr, lc->ifs);
1993 st->st_cur->ste_coroutine = 1;
2000 symtable_visit_keyword(struct symtable *st, keyword_ty k)
2002 VISIT(st, expr, k->value);
2008 symtable_handle_comprehension(struct symtable *st, expr_ty e,
2016 st->st_cur->ste_comp_iter_expr++;
2017 VISIT(st, expr, outermost->iter);
2018 st->st_cur->ste_comp_iter_expr--;
2021 !symtable_enter_block(st, scope_name, FunctionBlock, (void *)e,
2028 st->st_cur->ste_comprehension = ListComprehension;
2031 st->st_cur->ste_comprehension = SetComprehension;
2034 st->st_cur->ste_comprehension = DictComprehension;
2037 st->st_cur->ste_comprehension = GeneratorExpression;
2041 st->st_cur->ste_coroutine = 1;
2045 if (!symtable_implicit_arg(st, 0)) {
2046 symtable_exit_block(st);
2050 st->st_cur->ste_comp_iter_target = 1;
2051 VISIT(st, expr, outermost->target);
2052 st->st_cur->ste_comp_iter_target = 0;
2054 VISIT_SEQ(st, expr, outermost->ifs);
2055 VISIT_SEQ_TAIL(st, comprehension, generators, 1);
2057 VISIT(st, expr, value);
2058 VISIT(st, expr, elt);
2059 st->st_cur->ste_generator = is_generator;
2060 int is_async = st->st_cur->ste_coroutine && !is_generator;
2061 if (!symtable_exit_block(st)) {
2065 st->st_cur->ste_coroutine = 1;
2071 symtable_visit_genexp(struct symtable *st, expr_ty e)
2073 return symtable_handle_comprehension(st, e, &_Py_ID(genexpr),
2079 symtable_visit_listcomp(struct symtable *st, expr_ty e)
2081 return symtable_handle_comprehension(st, e, &_Py_ID(listcomp),
2087 symtable_visit_setcomp(struct symtable *st, expr_ty e)
2089 return symtable_handle_comprehension(st, e, &_Py_ID(setcomp),
2095 symtable_visit_dictcomp(struct symtable *st, expr_ty e)
2097 return symtable_handle_comprehension(st, e, &_Py_ID(dictcomp),
2104 symtable_raise_if_annotation_block(struct symtable *st, const char *name, expr_ty e)
2106 if (st->st_cur->ste_type != AnnotationBlock) {
2111 PyErr_RangedSyntaxLocationObject(st->st_filename,
2120 symtable_raise_if_comprehension_block(struct symtable *st, expr_ty e) {
2121 _Py_comprehension_ty type = st->st_cur->ste_comprehension;
2127 PyErr_RangedSyntaxLocationObject(st->st_filename,
2130 VISIT_QUIT(st, 0);
2137 struct symtable *st;
2156 st = _PySymtable_Build(mod, filename, future);
2159 return st;