Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(473)

Side by Side Diff: Python/symtable.c

Issue 11682: PEP 380 reference implementation for 3.3
Patch Set: Created 7 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« Python/ceval.c ('K') | « Python/Python-ast.c ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include "Python.h" 1 #include "Python.h"
2 #include "Python-ast.h" 2 #include "Python-ast.h"
3 #include "code.h" 3 #include "code.h"
4 #include "symtable.h" 4 #include "symtable.h"
5 #include "structmember.h" 5 #include "structmember.h"
6 6
7 /* error strings used for warnings */ 7 /* error strings used for warnings */
8 #define GLOBAL_AFTER_ASSIGN \ 8 #define GLOBAL_AFTER_ASSIGN \
9 "name '%.400s' is assigned to before global declaration" 9 "name '%.400s' is assigned to before global declaration"
10 10
(...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 VISIT_SEQ(st, stmt, s->v.ClassDef.body); 1126 VISIT_SEQ(st, stmt, s->v.ClassDef.body);
1127 st->st_private = tmp; 1127 st->st_private = tmp;
1128 if (!symtable_exit_block(st, s)) 1128 if (!symtable_exit_block(st, s))
1129 return 0; 1129 return 0;
1130 break; 1130 break;
1131 } 1131 }
1132 case Return_kind: 1132 case Return_kind:
1133 if (s->v.Return.value) { 1133 if (s->v.Return.value) {
1134 VISIT(st, expr, s->v.Return.value); 1134 VISIT(st, expr, s->v.Return.value);
1135 st->st_cur->ste_returns_value = 1; 1135 st->st_cur->ste_returns_value = 1;
1136 if (st->st_cur->ste_generator) {
1137 PyErr_SetString(PyExc_SyntaxError,
1138 RETURN_VAL_IN_GENERATOR);
Benjamin Peterson 2011/07/09 18:41:14 Presumably you can also remove the define of this
Nick Coghlan 2011/09/20 13:21:02 Done.
1139 PyErr_SyntaxLocationEx(st->st_filename,
1140 s->lineno,
1141 s->col_offset);
1142 return 0;
1143 }
1144 } 1136 }
1145 break; 1137 break;
1146 case Delete_kind: 1138 case Delete_kind:
1147 VISIT_SEQ(st, expr, s->v.Delete.targets); 1139 VISIT_SEQ(st, expr, s->v.Delete.targets);
1148 break; 1140 break;
1149 case Assign_kind: 1141 case Assign_kind:
1150 VISIT_SEQ(st, expr, s->v.Assign.targets); 1142 VISIT_SEQ(st, expr, s->v.Assign.targets);
1151 VISIT(st, expr, s->v.Assign.value); 1143 VISIT(st, expr, s->v.Assign.value);
1152 break; 1144 break;
1153 case AugAssign_kind: 1145 case AugAssign_kind:
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
1335 return 0; 1327 return 0;
1336 break; 1328 break;
1337 case DictComp_kind: 1329 case DictComp_kind:
1338 if (!symtable_visit_dictcomp(st, e)) 1330 if (!symtable_visit_dictcomp(st, e))
1339 return 0; 1331 return 0;
1340 break; 1332 break;
1341 case Yield_kind: 1333 case Yield_kind:
1342 if (e->v.Yield.value) 1334 if (e->v.Yield.value)
1343 VISIT(st, expr, e->v.Yield.value); 1335 VISIT(st, expr, e->v.Yield.value);
1344 st->st_cur->ste_generator = 1; 1336 st->st_cur->ste_generator = 1;
1345 if (st->st_cur->ste_returns_value) {
1346 PyErr_SetString(PyExc_SyntaxError,
1347 RETURN_VAL_IN_GENERATOR);
1348 PyErr_SyntaxLocationEx(st->st_filename,
1349 e->lineno, e->col_offset);
1350 return 0;
1351 }
1352 break; 1337 break;
1353 case Compare_kind: 1338 case Compare_kind:
1354 VISIT(st, expr, e->v.Compare.left); 1339 VISIT(st, expr, e->v.Compare.left);
1355 VISIT_SEQ(st, expr, e->v.Compare.comparators); 1340 VISIT_SEQ(st, expr, e->v.Compare.comparators);
1356 break; 1341 break;
1357 case Call_kind: 1342 case Call_kind:
1358 VISIT(st, expr, e->v.Call.func); 1343 VISIT(st, expr, e->v.Call.func);
1359 VISIT_SEQ(st, expr, e->v.Call.args); 1344 VISIT_SEQ(st, expr, e->v.Call.args);
1360 VISIT_SEQ(st, keyword, e->v.Call.keywords); 1345 VISIT_SEQ(st, keyword, e->v.Call.keywords);
1361 if (e->v.Call.starargs) 1346 if (e->v.Call.starargs)
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1659 } 1644 }
1660 1645
1661 static int 1646 static int
1662 symtable_visit_dictcomp(struct symtable *st, expr_ty e) 1647 symtable_visit_dictcomp(struct symtable *st, expr_ty e)
1663 { 1648 {
1664 return symtable_handle_comprehension(st, e, GET_IDENTIFIER(dictcomp), 1649 return symtable_handle_comprehension(st, e, GET_IDENTIFIER(dictcomp),
1665 e->v.DictComp.generators, 1650 e->v.DictComp.generators,
1666 e->v.DictComp.key, 1651 e->v.DictComp.key,
1667 e->v.DictComp.value); 1652 e->v.DictComp.value);
1668 } 1653 }
OLDNEW
« Python/ceval.c ('K') | « Python/Python-ast.c ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+