Mercurial > cpython-lru_cache-weakref
comparison Python/Python-ast.c @ 39678:f87a3e61853d
Remove the UNARY_CONVERT opcode (was used for backticks). Also bumped up the
import MAGIC number.
| author | Brett Cannon <bcannon@gmail.com> |
|---|---|
| date | Fri, 25 Aug 2006 05:05:30 +0000 |
| parents | a31202c9485d |
| children | c4d8c054616c |
comparison
equal
deleted
inserted
replaced
| 39677:78564e269d23 | 39678:f87a3e61853d |
|---|---|
| 203 "func", | 203 "func", |
| 204 "args", | 204 "args", |
| 205 "keywords", | 205 "keywords", |
| 206 "starargs", | 206 "starargs", |
| 207 "kwargs", | 207 "kwargs", |
| 208 }; | |
| 209 static PyTypeObject *Repr_type; | |
| 210 static char *Repr_fields[]={ | |
| 211 "value", | |
| 212 }; | 208 }; |
| 213 static PyTypeObject *Num_type; | 209 static PyTypeObject *Num_type; |
| 214 static char *Num_fields[]={ | 210 static char *Num_fields[]={ |
| 215 "n", | 211 "n", |
| 216 }; | 212 }; |
| 530 if (!Yield_type) return 0; | 526 if (!Yield_type) return 0; |
| 531 Compare_type = make_type("Compare", expr_type, Compare_fields, 3); | 527 Compare_type = make_type("Compare", expr_type, Compare_fields, 3); |
| 532 if (!Compare_type) return 0; | 528 if (!Compare_type) return 0; |
| 533 Call_type = make_type("Call", expr_type, Call_fields, 5); | 529 Call_type = make_type("Call", expr_type, Call_fields, 5); |
| 534 if (!Call_type) return 0; | 530 if (!Call_type) return 0; |
| 535 Repr_type = make_type("Repr", expr_type, Repr_fields, 1); | |
| 536 if (!Repr_type) return 0; | |
| 537 Num_type = make_type("Num", expr_type, Num_fields, 1); | 531 Num_type = make_type("Num", expr_type, Num_fields, 1); |
| 538 if (!Num_type) return 0; | 532 if (!Num_type) return 0; |
| 539 Str_type = make_type("Str", expr_type, Str_fields, 1); | 533 Str_type = make_type("Str", expr_type, Str_fields, 1); |
| 540 if (!Str_type) return 0; | 534 if (!Str_type) return 0; |
| 541 Attribute_type = make_type("Attribute", expr_type, Attribute_fields, 3); | 535 Attribute_type = make_type("Attribute", expr_type, Attribute_fields, 3); |
| 1551 p->col_offset = col_offset; | 1545 p->col_offset = col_offset; |
| 1552 return p; | 1546 return p; |
| 1553 } | 1547 } |
| 1554 | 1548 |
| 1555 expr_ty | 1549 expr_ty |
| 1556 Repr(expr_ty value, int lineno, int col_offset, PyArena *arena) | |
| 1557 { | |
| 1558 expr_ty p; | |
| 1559 if (!value) { | |
| 1560 PyErr_SetString(PyExc_ValueError, | |
| 1561 "field value is required for Repr"); | |
| 1562 return NULL; | |
| 1563 } | |
| 1564 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | |
| 1565 if (!p) { | |
| 1566 PyErr_NoMemory(); | |
| 1567 return NULL; | |
| 1568 } | |
| 1569 p->kind = Repr_kind; | |
| 1570 p->v.Repr.value = value; | |
| 1571 p->lineno = lineno; | |
| 1572 p->col_offset = col_offset; | |
| 1573 return p; | |
| 1574 } | |
| 1575 | |
| 1576 expr_ty | |
| 1577 Num(object n, int lineno, int col_offset, PyArena *arena) | 1550 Num(object n, int lineno, int col_offset, PyArena *arena) |
| 1578 { | 1551 { |
| 1579 expr_ty p; | 1552 expr_ty p; |
| 1580 if (!n) { | 1553 if (!n) { |
| 1581 PyErr_SetString(PyExc_ValueError, | 1554 PyErr_SetString(PyExc_ValueError, |
| 2539 goto failed; | 2512 goto failed; |
| 2540 Py_DECREF(value); | 2513 Py_DECREF(value); |
| 2541 value = ast2obj_expr(o->v.Call.kwargs); | 2514 value = ast2obj_expr(o->v.Call.kwargs); |
| 2542 if (!value) goto failed; | 2515 if (!value) goto failed; |
| 2543 if (PyObject_SetAttrString(result, "kwargs", value) == -1) | 2516 if (PyObject_SetAttrString(result, "kwargs", value) == -1) |
| 2544 goto failed; | |
| 2545 Py_DECREF(value); | |
| 2546 break; | |
| 2547 case Repr_kind: | |
| 2548 result = PyType_GenericNew(Repr_type, NULL, NULL); | |
| 2549 if (!result) goto failed; | |
| 2550 value = ast2obj_expr(o->v.Repr.value); | |
| 2551 if (!value) goto failed; | |
| 2552 if (PyObject_SetAttrString(result, "value", value) == -1) | |
| 2553 goto failed; | 2517 goto failed; |
| 2554 Py_DECREF(value); | 2518 Py_DECREF(value); |
| 2555 break; | 2519 break; |
| 2556 case Num_kind: | 2520 case Num_kind: |
| 2557 result = PyType_GenericNew(Num_type, NULL, NULL); | 2521 result = PyType_GenericNew(Num_type, NULL, NULL); |
| 3111 (PyObject*)GeneratorExp_type) < 0) return; | 3075 (PyObject*)GeneratorExp_type) < 0) return; |
| 3112 if (PyDict_SetItemString(d, "Yield", (PyObject*)Yield_type) < 0) return; | 3076 if (PyDict_SetItemString(d, "Yield", (PyObject*)Yield_type) < 0) return; |
| 3113 if (PyDict_SetItemString(d, "Compare", (PyObject*)Compare_type) < 0) | 3077 if (PyDict_SetItemString(d, "Compare", (PyObject*)Compare_type) < 0) |
| 3114 return; | 3078 return; |
| 3115 if (PyDict_SetItemString(d, "Call", (PyObject*)Call_type) < 0) return; | 3079 if (PyDict_SetItemString(d, "Call", (PyObject*)Call_type) < 0) return; |
| 3116 if (PyDict_SetItemString(d, "Repr", (PyObject*)Repr_type) < 0) return; | |
| 3117 if (PyDict_SetItemString(d, "Num", (PyObject*)Num_type) < 0) return; | 3080 if (PyDict_SetItemString(d, "Num", (PyObject*)Num_type) < 0) return; |
| 3118 if (PyDict_SetItemString(d, "Str", (PyObject*)Str_type) < 0) return; | 3081 if (PyDict_SetItemString(d, "Str", (PyObject*)Str_type) < 0) return; |
| 3119 if (PyDict_SetItemString(d, "Attribute", (PyObject*)Attribute_type) < | 3082 if (PyDict_SetItemString(d, "Attribute", (PyObject*)Attribute_type) < |
| 3120 0) return; | 3083 0) return; |
| 3121 if (PyDict_SetItemString(d, "Subscript", (PyObject*)Subscript_type) < | 3084 if (PyDict_SetItemString(d, "Subscript", (PyObject*)Subscript_type) < |
