Mercurial > cpython-lru_cache-weakref
comparison Python/Python-ast.c @ 40937:6aa1be5dd009
Merged revisions 53912-53951 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r53919 | thomas.wouters | 2007-02-25 23:12:31 +0100 (Sun, 25 Feb 2007) | 8 lines
Backported r51621 from p3yk:
Don't use a fixed temporary name (gdbm).
Don't use our own temp name creation (dbm).
Should be backported to 2.5.
........
r53935 | georg.brandl | 2007-02-26 14:51:29 +0100 (Mon, 26 Feb 2007) | 2 lines
Backport from Py3k branch: fix refleak in PyString_Format.
........
r53943 | jeremy.hylton | 2007-02-26 17:14:51 +0100 (Mon, 26 Feb 2007) | 2 lines
Reformat long lines.
........
r53947 | neal.norwitz | 2007-02-26 18:01:08 +0100 (Mon, 26 Feb 2007) | 1 line
Add Steven Bethard to help out with patches.
........
r53949 | georg.brandl | 2007-02-26 18:09:03 +0100 (Mon, 26 Feb 2007) | 3 lines
Fix typo.
........
r53951 | neal.norwitz | 2007-02-26 19:10:47 +0100 (Mon, 26 Feb 2007) | 5 lines
Fix a couple of problems in generating the AST code:
* use %r instead of backticks since backticks are going away in Py3k
* PyArena_Malloc() already sets PyErr_NoMemory so we don't need to do it again
* the signature for ast2obj_int incorrectly used a bool, rather than a long
........
| author | Thomas Wouters <thomas@python.org> |
|---|---|
| date | Mon, 26 Feb 2007 18:20:15 +0000 |
| parents | b05790d066b4 |
| children | 2ca14d6a369b |
comparison
equal
deleted
inserted
replaced
| 40933:a2629be1b1d0 | 40937:6aa1be5dd009 |
|---|---|
| 1 /* File automatically generated by Parser/asdl_c.py. */ | 1 /* File automatically generated by Parser/asdl_c.py. */ |
| 2 | 2 |
| 3 | 3 |
| 4 /* | 4 /* |
| 5 __version__ 53872. | 5 __version__ 53873. |
| 6 | 6 |
| 7 This module must be committed separately after each AST grammar change; | 7 This module must be committed separately after each AST grammar change; |
| 8 The __version__ number is set to the revision number of the commit | 8 The __version__ number is set to the revision number of the commit |
| 9 containing the grammar change. | 9 containing the grammar change. |
| 10 */ | 10 */ |
| 446 static PyObject* ast2obj_bool(bool b) | 446 static PyObject* ast2obj_bool(bool b) |
| 447 { | 447 { |
| 448 return PyBool_FromLong(b); | 448 return PyBool_FromLong(b); |
| 449 } | 449 } |
| 450 | 450 |
| 451 static PyObject* ast2obj_int(bool b) | 451 static PyObject* ast2obj_int(long b) |
| 452 { | 452 { |
| 453 return PyInt_FromLong(b); | 453 return PyInt_FromLong(b); |
| 454 } | 454 } |
| 455 | 455 |
| 456 static int init_types(void) | 456 static int init_types(void) |
| 752 mod_ty | 752 mod_ty |
| 753 Module(asdl_seq * body, PyArena *arena) | 753 Module(asdl_seq * body, PyArena *arena) |
| 754 { | 754 { |
| 755 mod_ty p; | 755 mod_ty p; |
| 756 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); | 756 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 757 if (!p) { | 757 if (!p) |
| 758 PyErr_NoMemory(); | 758 return NULL; |
| 759 return NULL; | |
| 760 } | |
| 761 p->kind = Module_kind; | 759 p->kind = Module_kind; |
| 762 p->v.Module.body = body; | 760 p->v.Module.body = body; |
| 763 return p; | 761 return p; |
| 764 } | 762 } |
| 765 | 763 |
| 766 mod_ty | 764 mod_ty |
| 767 Interactive(asdl_seq * body, PyArena *arena) | 765 Interactive(asdl_seq * body, PyArena *arena) |
| 768 { | 766 { |
| 769 mod_ty p; | 767 mod_ty p; |
| 770 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); | 768 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 771 if (!p) { | 769 if (!p) |
| 772 PyErr_NoMemory(); | 770 return NULL; |
| 773 return NULL; | |
| 774 } | |
| 775 p->kind = Interactive_kind; | 771 p->kind = Interactive_kind; |
| 776 p->v.Interactive.body = body; | 772 p->v.Interactive.body = body; |
| 777 return p; | 773 return p; |
| 778 } | 774 } |
| 779 | 775 |
| 785 PyErr_SetString(PyExc_ValueError, | 781 PyErr_SetString(PyExc_ValueError, |
| 786 "field body is required for Expression"); | 782 "field body is required for Expression"); |
| 787 return NULL; | 783 return NULL; |
| 788 } | 784 } |
| 789 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); | 785 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 790 if (!p) { | 786 if (!p) |
| 791 PyErr_NoMemory(); | 787 return NULL; |
| 792 return NULL; | |
| 793 } | |
| 794 p->kind = Expression_kind; | 788 p->kind = Expression_kind; |
| 795 p->v.Expression.body = body; | 789 p->v.Expression.body = body; |
| 796 return p; | 790 return p; |
| 797 } | 791 } |
| 798 | 792 |
| 799 mod_ty | 793 mod_ty |
| 800 Suite(asdl_seq * body, PyArena *arena) | 794 Suite(asdl_seq * body, PyArena *arena) |
| 801 { | 795 { |
| 802 mod_ty p; | 796 mod_ty p; |
| 803 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); | 797 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 804 if (!p) { | 798 if (!p) |
| 805 PyErr_NoMemory(); | 799 return NULL; |
| 806 return NULL; | |
| 807 } | |
| 808 p->kind = Suite_kind; | 800 p->kind = Suite_kind; |
| 809 p->v.Suite.body = body; | 801 p->v.Suite.body = body; |
| 810 return p; | 802 return p; |
| 811 } | 803 } |
| 812 | 804 |
| 825 PyErr_SetString(PyExc_ValueError, | 817 PyErr_SetString(PyExc_ValueError, |
| 826 "field args is required for FunctionDef"); | 818 "field args is required for FunctionDef"); |
| 827 return NULL; | 819 return NULL; |
| 828 } | 820 } |
| 829 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 821 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 830 if (!p) { | 822 if (!p) |
| 831 PyErr_NoMemory(); | 823 return NULL; |
| 832 return NULL; | |
| 833 } | |
| 834 p->kind = FunctionDef_kind; | 824 p->kind = FunctionDef_kind; |
| 835 p->v.FunctionDef.name = name; | 825 p->v.FunctionDef.name = name; |
| 836 p->v.FunctionDef.args = args; | 826 p->v.FunctionDef.args = args; |
| 837 p->v.FunctionDef.body = body; | 827 p->v.FunctionDef.body = body; |
| 838 p->v.FunctionDef.decorators = decorators; | 828 p->v.FunctionDef.decorators = decorators; |
| 851 PyErr_SetString(PyExc_ValueError, | 841 PyErr_SetString(PyExc_ValueError, |
| 852 "field name is required for ClassDef"); | 842 "field name is required for ClassDef"); |
| 853 return NULL; | 843 return NULL; |
| 854 } | 844 } |
| 855 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 845 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 856 if (!p) { | 846 if (!p) |
| 857 PyErr_NoMemory(); | 847 return NULL; |
| 858 return NULL; | |
| 859 } | |
| 860 p->kind = ClassDef_kind; | 848 p->kind = ClassDef_kind; |
| 861 p->v.ClassDef.name = name; | 849 p->v.ClassDef.name = name; |
| 862 p->v.ClassDef.bases = bases; | 850 p->v.ClassDef.bases = bases; |
| 863 p->v.ClassDef.body = body; | 851 p->v.ClassDef.body = body; |
| 864 p->lineno = lineno; | 852 p->lineno = lineno; |
| 869 stmt_ty | 857 stmt_ty |
| 870 Return(expr_ty value, int lineno, int col_offset, PyArena *arena) | 858 Return(expr_ty value, int lineno, int col_offset, PyArena *arena) |
| 871 { | 859 { |
| 872 stmt_ty p; | 860 stmt_ty p; |
| 873 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 861 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 874 if (!p) { | 862 if (!p) |
| 875 PyErr_NoMemory(); | 863 return NULL; |
| 876 return NULL; | |
| 877 } | |
| 878 p->kind = Return_kind; | 864 p->kind = Return_kind; |
| 879 p->v.Return.value = value; | 865 p->v.Return.value = value; |
| 880 p->lineno = lineno; | 866 p->lineno = lineno; |
| 881 p->col_offset = col_offset; | 867 p->col_offset = col_offset; |
| 882 return p; | 868 return p; |
| 885 stmt_ty | 871 stmt_ty |
| 886 Delete(asdl_seq * targets, int lineno, int col_offset, PyArena *arena) | 872 Delete(asdl_seq * targets, int lineno, int col_offset, PyArena *arena) |
| 887 { | 873 { |
| 888 stmt_ty p; | 874 stmt_ty p; |
| 889 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 875 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 890 if (!p) { | 876 if (!p) |
| 891 PyErr_NoMemory(); | 877 return NULL; |
| 892 return NULL; | |
| 893 } | |
| 894 p->kind = Delete_kind; | 878 p->kind = Delete_kind; |
| 895 p->v.Delete.targets = targets; | 879 p->v.Delete.targets = targets; |
| 896 p->lineno = lineno; | 880 p->lineno = lineno; |
| 897 p->col_offset = col_offset; | 881 p->col_offset = col_offset; |
| 898 return p; | 882 return p; |
| 907 PyErr_SetString(PyExc_ValueError, | 891 PyErr_SetString(PyExc_ValueError, |
| 908 "field value is required for Assign"); | 892 "field value is required for Assign"); |
| 909 return NULL; | 893 return NULL; |
| 910 } | 894 } |
| 911 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 895 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 912 if (!p) { | 896 if (!p) |
| 913 PyErr_NoMemory(); | 897 return NULL; |
| 914 return NULL; | |
| 915 } | |
| 916 p->kind = Assign_kind; | 898 p->kind = Assign_kind; |
| 917 p->v.Assign.targets = targets; | 899 p->v.Assign.targets = targets; |
| 918 p->v.Assign.value = value; | 900 p->v.Assign.value = value; |
| 919 p->lineno = lineno; | 901 p->lineno = lineno; |
| 920 p->col_offset = col_offset; | 902 p->col_offset = col_offset; |
| 940 PyErr_SetString(PyExc_ValueError, | 922 PyErr_SetString(PyExc_ValueError, |
| 941 "field value is required for AugAssign"); | 923 "field value is required for AugAssign"); |
| 942 return NULL; | 924 return NULL; |
| 943 } | 925 } |
| 944 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 926 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 945 if (!p) { | 927 if (!p) |
| 946 PyErr_NoMemory(); | 928 return NULL; |
| 947 return NULL; | |
| 948 } | |
| 949 p->kind = AugAssign_kind; | 929 p->kind = AugAssign_kind; |
| 950 p->v.AugAssign.target = target; | 930 p->v.AugAssign.target = target; |
| 951 p->v.AugAssign.op = op; | 931 p->v.AugAssign.op = op; |
| 952 p->v.AugAssign.value = value; | 932 p->v.AugAssign.value = value; |
| 953 p->lineno = lineno; | 933 p->lineno = lineno; |
| 969 PyErr_SetString(PyExc_ValueError, | 949 PyErr_SetString(PyExc_ValueError, |
| 970 "field iter is required for For"); | 950 "field iter is required for For"); |
| 971 return NULL; | 951 return NULL; |
| 972 } | 952 } |
| 973 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 953 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 974 if (!p) { | 954 if (!p) |
| 975 PyErr_NoMemory(); | 955 return NULL; |
| 976 return NULL; | |
| 977 } | |
| 978 p->kind = For_kind; | 956 p->kind = For_kind; |
| 979 p->v.For.target = target; | 957 p->v.For.target = target; |
| 980 p->v.For.iter = iter; | 958 p->v.For.iter = iter; |
| 981 p->v.For.body = body; | 959 p->v.For.body = body; |
| 982 p->v.For.orelse = orelse; | 960 p->v.For.orelse = orelse; |
| 994 PyErr_SetString(PyExc_ValueError, | 972 PyErr_SetString(PyExc_ValueError, |
| 995 "field test is required for While"); | 973 "field test is required for While"); |
| 996 return NULL; | 974 return NULL; |
| 997 } | 975 } |
| 998 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 976 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 999 if (!p) { | 977 if (!p) |
| 1000 PyErr_NoMemory(); | 978 return NULL; |
| 1001 return NULL; | |
| 1002 } | |
| 1003 p->kind = While_kind; | 979 p->kind = While_kind; |
| 1004 p->v.While.test = test; | 980 p->v.While.test = test; |
| 1005 p->v.While.body = body; | 981 p->v.While.body = body; |
| 1006 p->v.While.orelse = orelse; | 982 p->v.While.orelse = orelse; |
| 1007 p->lineno = lineno; | 983 p->lineno = lineno; |
| 1018 PyErr_SetString(PyExc_ValueError, | 994 PyErr_SetString(PyExc_ValueError, |
| 1019 "field test is required for If"); | 995 "field test is required for If"); |
| 1020 return NULL; | 996 return NULL; |
| 1021 } | 997 } |
| 1022 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 998 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1023 if (!p) { | 999 if (!p) |
| 1024 PyErr_NoMemory(); | 1000 return NULL; |
| 1025 return NULL; | |
| 1026 } | |
| 1027 p->kind = If_kind; | 1001 p->kind = If_kind; |
| 1028 p->v.If.test = test; | 1002 p->v.If.test = test; |
| 1029 p->v.If.body = body; | 1003 p->v.If.body = body; |
| 1030 p->v.If.orelse = orelse; | 1004 p->v.If.orelse = orelse; |
| 1031 p->lineno = lineno; | 1005 p->lineno = lineno; |
| 1042 PyErr_SetString(PyExc_ValueError, | 1016 PyErr_SetString(PyExc_ValueError, |
| 1043 "field context_expr is required for With"); | 1017 "field context_expr is required for With"); |
| 1044 return NULL; | 1018 return NULL; |
| 1045 } | 1019 } |
| 1046 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 1020 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1047 if (!p) { | 1021 if (!p) |
| 1048 PyErr_NoMemory(); | 1022 return NULL; |
| 1049 return NULL; | |
| 1050 } | |
| 1051 p->kind = With_kind; | 1023 p->kind = With_kind; |
| 1052 p->v.With.context_expr = context_expr; | 1024 p->v.With.context_expr = context_expr; |
| 1053 p->v.With.optional_vars = optional_vars; | 1025 p->v.With.optional_vars = optional_vars; |
| 1054 p->v.With.body = body; | 1026 p->v.With.body = body; |
| 1055 p->lineno = lineno; | 1027 p->lineno = lineno; |
| 1061 Raise(expr_ty type, expr_ty inst, expr_ty tback, int lineno, int col_offset, | 1033 Raise(expr_ty type, expr_ty inst, expr_ty tback, int lineno, int col_offset, |
| 1062 PyArena *arena) | 1034 PyArena *arena) |
| 1063 { | 1035 { |
| 1064 stmt_ty p; | 1036 stmt_ty p; |
| 1065 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 1037 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1066 if (!p) { | 1038 if (!p) |
| 1067 PyErr_NoMemory(); | 1039 return NULL; |
| 1068 return NULL; | |
| 1069 } | |
| 1070 p->kind = Raise_kind; | 1040 p->kind = Raise_kind; |
| 1071 p->v.Raise.type = type; | 1041 p->v.Raise.type = type; |
| 1072 p->v.Raise.inst = inst; | 1042 p->v.Raise.inst = inst; |
| 1073 p->v.Raise.tback = tback; | 1043 p->v.Raise.tback = tback; |
| 1074 p->lineno = lineno; | 1044 p->lineno = lineno; |
| 1080 TryExcept(asdl_seq * body, asdl_seq * handlers, asdl_seq * orelse, int lineno, | 1050 TryExcept(asdl_seq * body, asdl_seq * handlers, asdl_seq * orelse, int lineno, |
| 1081 int col_offset, PyArena *arena) | 1051 int col_offset, PyArena *arena) |
| 1082 { | 1052 { |
| 1083 stmt_ty p; | 1053 stmt_ty p; |
| 1084 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 1054 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1085 if (!p) { | 1055 if (!p) |
| 1086 PyErr_NoMemory(); | 1056 return NULL; |
| 1087 return NULL; | |
| 1088 } | |
| 1089 p->kind = TryExcept_kind; | 1057 p->kind = TryExcept_kind; |
| 1090 p->v.TryExcept.body = body; | 1058 p->v.TryExcept.body = body; |
| 1091 p->v.TryExcept.handlers = handlers; | 1059 p->v.TryExcept.handlers = handlers; |
| 1092 p->v.TryExcept.orelse = orelse; | 1060 p->v.TryExcept.orelse = orelse; |
| 1093 p->lineno = lineno; | 1061 p->lineno = lineno; |
| 1099 TryFinally(asdl_seq * body, asdl_seq * finalbody, int lineno, int col_offset, | 1067 TryFinally(asdl_seq * body, asdl_seq * finalbody, int lineno, int col_offset, |
| 1100 PyArena *arena) | 1068 PyArena *arena) |
| 1101 { | 1069 { |
| 1102 stmt_ty p; | 1070 stmt_ty p; |
| 1103 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 1071 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1104 if (!p) { | 1072 if (!p) |
| 1105 PyErr_NoMemory(); | 1073 return NULL; |
| 1106 return NULL; | |
| 1107 } | |
| 1108 p->kind = TryFinally_kind; | 1074 p->kind = TryFinally_kind; |
| 1109 p->v.TryFinally.body = body; | 1075 p->v.TryFinally.body = body; |
| 1110 p->v.TryFinally.finalbody = finalbody; | 1076 p->v.TryFinally.finalbody = finalbody; |
| 1111 p->lineno = lineno; | 1077 p->lineno = lineno; |
| 1112 p->col_offset = col_offset; | 1078 p->col_offset = col_offset; |
| 1121 PyErr_SetString(PyExc_ValueError, | 1087 PyErr_SetString(PyExc_ValueError, |
| 1122 "field test is required for Assert"); | 1088 "field test is required for Assert"); |
| 1123 return NULL; | 1089 return NULL; |
| 1124 } | 1090 } |
| 1125 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 1091 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1126 if (!p) { | 1092 if (!p) |
| 1127 PyErr_NoMemory(); | 1093 return NULL; |
| 1128 return NULL; | |
| 1129 } | |
| 1130 p->kind = Assert_kind; | 1094 p->kind = Assert_kind; |
| 1131 p->v.Assert.test = test; | 1095 p->v.Assert.test = test; |
| 1132 p->v.Assert.msg = msg; | 1096 p->v.Assert.msg = msg; |
| 1133 p->lineno = lineno; | 1097 p->lineno = lineno; |
| 1134 p->col_offset = col_offset; | 1098 p->col_offset = col_offset; |
| 1138 stmt_ty | 1102 stmt_ty |
| 1139 Import(asdl_seq * names, int lineno, int col_offset, PyArena *arena) | 1103 Import(asdl_seq * names, int lineno, int col_offset, PyArena *arena) |
| 1140 { | 1104 { |
| 1141 stmt_ty p; | 1105 stmt_ty p; |
| 1142 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 1106 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1143 if (!p) { | 1107 if (!p) |
| 1144 PyErr_NoMemory(); | 1108 return NULL; |
| 1145 return NULL; | |
| 1146 } | |
| 1147 p->kind = Import_kind; | 1109 p->kind = Import_kind; |
| 1148 p->v.Import.names = names; | 1110 p->v.Import.names = names; |
| 1149 p->lineno = lineno; | 1111 p->lineno = lineno; |
| 1150 p->col_offset = col_offset; | 1112 p->col_offset = col_offset; |
| 1151 return p; | 1113 return p; |
| 1160 PyErr_SetString(PyExc_ValueError, | 1122 PyErr_SetString(PyExc_ValueError, |
| 1161 "field module is required for ImportFrom"); | 1123 "field module is required for ImportFrom"); |
| 1162 return NULL; | 1124 return NULL; |
| 1163 } | 1125 } |
| 1164 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 1126 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1165 if (!p) { | 1127 if (!p) |
| 1166 PyErr_NoMemory(); | 1128 return NULL; |
| 1167 return NULL; | |
| 1168 } | |
| 1169 p->kind = ImportFrom_kind; | 1129 p->kind = ImportFrom_kind; |
| 1170 p->v.ImportFrom.module = module; | 1130 p->v.ImportFrom.module = module; |
| 1171 p->v.ImportFrom.names = names; | 1131 p->v.ImportFrom.names = names; |
| 1172 p->v.ImportFrom.level = level; | 1132 p->v.ImportFrom.level = level; |
| 1173 p->lineno = lineno; | 1133 p->lineno = lineno; |
| 1178 stmt_ty | 1138 stmt_ty |
| 1179 Global(asdl_seq * names, int lineno, int col_offset, PyArena *arena) | 1139 Global(asdl_seq * names, int lineno, int col_offset, PyArena *arena) |
| 1180 { | 1140 { |
| 1181 stmt_ty p; | 1141 stmt_ty p; |
| 1182 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 1142 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1183 if (!p) { | 1143 if (!p) |
| 1184 PyErr_NoMemory(); | 1144 return NULL; |
| 1185 return NULL; | |
| 1186 } | |
| 1187 p->kind = Global_kind; | 1145 p->kind = Global_kind; |
| 1188 p->v.Global.names = names; | 1146 p->v.Global.names = names; |
| 1189 p->lineno = lineno; | 1147 p->lineno = lineno; |
| 1190 p->col_offset = col_offset; | 1148 p->col_offset = col_offset; |
| 1191 return p; | 1149 return p; |
| 1199 PyErr_SetString(PyExc_ValueError, | 1157 PyErr_SetString(PyExc_ValueError, |
| 1200 "field value is required for Expr"); | 1158 "field value is required for Expr"); |
| 1201 return NULL; | 1159 return NULL; |
| 1202 } | 1160 } |
| 1203 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 1161 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1204 if (!p) { | 1162 if (!p) |
| 1205 PyErr_NoMemory(); | 1163 return NULL; |
| 1206 return NULL; | |
| 1207 } | |
| 1208 p->kind = Expr_kind; | 1164 p->kind = Expr_kind; |
| 1209 p->v.Expr.value = value; | 1165 p->v.Expr.value = value; |
| 1210 p->lineno = lineno; | 1166 p->lineno = lineno; |
| 1211 p->col_offset = col_offset; | 1167 p->col_offset = col_offset; |
| 1212 return p; | 1168 return p; |
| 1215 stmt_ty | 1171 stmt_ty |
| 1216 Pass(int lineno, int col_offset, PyArena *arena) | 1172 Pass(int lineno, int col_offset, PyArena *arena) |
| 1217 { | 1173 { |
| 1218 stmt_ty p; | 1174 stmt_ty p; |
| 1219 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 1175 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1220 if (!p) { | 1176 if (!p) |
| 1221 PyErr_NoMemory(); | 1177 return NULL; |
| 1222 return NULL; | |
| 1223 } | |
| 1224 p->kind = Pass_kind; | 1178 p->kind = Pass_kind; |
| 1225 p->lineno = lineno; | 1179 p->lineno = lineno; |
| 1226 p->col_offset = col_offset; | 1180 p->col_offset = col_offset; |
| 1227 return p; | 1181 return p; |
| 1228 } | 1182 } |
| 1230 stmt_ty | 1184 stmt_ty |
| 1231 Break(int lineno, int col_offset, PyArena *arena) | 1185 Break(int lineno, int col_offset, PyArena *arena) |
| 1232 { | 1186 { |
| 1233 stmt_ty p; | 1187 stmt_ty p; |
| 1234 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 1188 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1235 if (!p) { | 1189 if (!p) |
| 1236 PyErr_NoMemory(); | 1190 return NULL; |
| 1237 return NULL; | |
| 1238 } | |
| 1239 p->kind = Break_kind; | 1191 p->kind = Break_kind; |
| 1240 p->lineno = lineno; | 1192 p->lineno = lineno; |
| 1241 p->col_offset = col_offset; | 1193 p->col_offset = col_offset; |
| 1242 return p; | 1194 return p; |
| 1243 } | 1195 } |
| 1245 stmt_ty | 1197 stmt_ty |
| 1246 Continue(int lineno, int col_offset, PyArena *arena) | 1198 Continue(int lineno, int col_offset, PyArena *arena) |
| 1247 { | 1199 { |
| 1248 stmt_ty p; | 1200 stmt_ty p; |
| 1249 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 1201 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1250 if (!p) { | 1202 if (!p) |
| 1251 PyErr_NoMemory(); | 1203 return NULL; |
| 1252 return NULL; | |
| 1253 } | |
| 1254 p->kind = Continue_kind; | 1204 p->kind = Continue_kind; |
| 1255 p->lineno = lineno; | 1205 p->lineno = lineno; |
| 1256 p->col_offset = col_offset; | 1206 p->col_offset = col_offset; |
| 1257 return p; | 1207 return p; |
| 1258 } | 1208 } |
| 1266 PyErr_SetString(PyExc_ValueError, | 1216 PyErr_SetString(PyExc_ValueError, |
| 1267 "field op is required for BoolOp"); | 1217 "field op is required for BoolOp"); |
| 1268 return NULL; | 1218 return NULL; |
| 1269 } | 1219 } |
| 1270 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1220 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1271 if (!p) { | 1221 if (!p) |
| 1272 PyErr_NoMemory(); | 1222 return NULL; |
| 1273 return NULL; | |
| 1274 } | |
| 1275 p->kind = BoolOp_kind; | 1223 p->kind = BoolOp_kind; |
| 1276 p->v.BoolOp.op = op; | 1224 p->v.BoolOp.op = op; |
| 1277 p->v.BoolOp.values = values; | 1225 p->v.BoolOp.values = values; |
| 1278 p->lineno = lineno; | 1226 p->lineno = lineno; |
| 1279 p->col_offset = col_offset; | 1227 p->col_offset = col_offset; |
| 1299 PyErr_SetString(PyExc_ValueError, | 1247 PyErr_SetString(PyExc_ValueError, |
| 1300 "field right is required for BinOp"); | 1248 "field right is required for BinOp"); |
| 1301 return NULL; | 1249 return NULL; |
| 1302 } | 1250 } |
| 1303 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1251 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1304 if (!p) { | 1252 if (!p) |
| 1305 PyErr_NoMemory(); | 1253 return NULL; |
| 1306 return NULL; | |
| 1307 } | |
| 1308 p->kind = BinOp_kind; | 1254 p->kind = BinOp_kind; |
| 1309 p->v.BinOp.left = left; | 1255 p->v.BinOp.left = left; |
| 1310 p->v.BinOp.op = op; | 1256 p->v.BinOp.op = op; |
| 1311 p->v.BinOp.right = right; | 1257 p->v.BinOp.right = right; |
| 1312 p->lineno = lineno; | 1258 p->lineno = lineno; |
| 1328 PyErr_SetString(PyExc_ValueError, | 1274 PyErr_SetString(PyExc_ValueError, |
| 1329 "field operand is required for UnaryOp"); | 1275 "field operand is required for UnaryOp"); |
| 1330 return NULL; | 1276 return NULL; |
| 1331 } | 1277 } |
| 1332 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1278 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1333 if (!p) { | 1279 if (!p) |
| 1334 PyErr_NoMemory(); | 1280 return NULL; |
| 1335 return NULL; | |
| 1336 } | |
| 1337 p->kind = UnaryOp_kind; | 1281 p->kind = UnaryOp_kind; |
| 1338 p->v.UnaryOp.op = op; | 1282 p->v.UnaryOp.op = op; |
| 1339 p->v.UnaryOp.operand = operand; | 1283 p->v.UnaryOp.operand = operand; |
| 1340 p->lineno = lineno; | 1284 p->lineno = lineno; |
| 1341 p->col_offset = col_offset; | 1285 p->col_offset = col_offset; |
| 1356 PyErr_SetString(PyExc_ValueError, | 1300 PyErr_SetString(PyExc_ValueError, |
| 1357 "field body is required for Lambda"); | 1301 "field body is required for Lambda"); |
| 1358 return NULL; | 1302 return NULL; |
| 1359 } | 1303 } |
| 1360 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1304 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1361 if (!p) { | 1305 if (!p) |
| 1362 PyErr_NoMemory(); | 1306 return NULL; |
| 1363 return NULL; | |
| 1364 } | |
| 1365 p->kind = Lambda_kind; | 1307 p->kind = Lambda_kind; |
| 1366 p->v.Lambda.args = args; | 1308 p->v.Lambda.args = args; |
| 1367 p->v.Lambda.body = body; | 1309 p->v.Lambda.body = body; |
| 1368 p->lineno = lineno; | 1310 p->lineno = lineno; |
| 1369 p->col_offset = col_offset; | 1311 p->col_offset = col_offset; |
| 1389 PyErr_SetString(PyExc_ValueError, | 1331 PyErr_SetString(PyExc_ValueError, |
| 1390 "field orelse is required for IfExp"); | 1332 "field orelse is required for IfExp"); |
| 1391 return NULL; | 1333 return NULL; |
| 1392 } | 1334 } |
| 1393 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1335 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1394 if (!p) { | 1336 if (!p) |
| 1395 PyErr_NoMemory(); | 1337 return NULL; |
| 1396 return NULL; | |
| 1397 } | |
| 1398 p->kind = IfExp_kind; | 1338 p->kind = IfExp_kind; |
| 1399 p->v.IfExp.test = test; | 1339 p->v.IfExp.test = test; |
| 1400 p->v.IfExp.body = body; | 1340 p->v.IfExp.body = body; |
| 1401 p->v.IfExp.orelse = orelse; | 1341 p->v.IfExp.orelse = orelse; |
| 1402 p->lineno = lineno; | 1342 p->lineno = lineno; |
| 1408 Dict(asdl_seq * keys, asdl_seq * values, int lineno, int col_offset, PyArena | 1348 Dict(asdl_seq * keys, asdl_seq * values, int lineno, int col_offset, PyArena |
| 1409 *arena) | 1349 *arena) |
| 1410 { | 1350 { |
| 1411 expr_ty p; | 1351 expr_ty p; |
| 1412 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1352 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1413 if (!p) { | 1353 if (!p) |
| 1414 PyErr_NoMemory(); | 1354 return NULL; |
| 1415 return NULL; | |
| 1416 } | |
| 1417 p->kind = Dict_kind; | 1355 p->kind = Dict_kind; |
| 1418 p->v.Dict.keys = keys; | 1356 p->v.Dict.keys = keys; |
| 1419 p->v.Dict.values = values; | 1357 p->v.Dict.values = values; |
| 1420 p->lineno = lineno; | 1358 p->lineno = lineno; |
| 1421 p->col_offset = col_offset; | 1359 p->col_offset = col_offset; |
| 1425 expr_ty | 1363 expr_ty |
| 1426 Set(asdl_seq * elts, int lineno, int col_offset, PyArena *arena) | 1364 Set(asdl_seq * elts, int lineno, int col_offset, PyArena *arena) |
| 1427 { | 1365 { |
| 1428 expr_ty p; | 1366 expr_ty p; |
| 1429 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1367 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1430 if (!p) { | 1368 if (!p) |
| 1431 PyErr_NoMemory(); | 1369 return NULL; |
| 1432 return NULL; | |
| 1433 } | |
| 1434 p->kind = Set_kind; | 1370 p->kind = Set_kind; |
| 1435 p->v.Set.elts = elts; | 1371 p->v.Set.elts = elts; |
| 1436 p->lineno = lineno; | 1372 p->lineno = lineno; |
| 1437 p->col_offset = col_offset; | 1373 p->col_offset = col_offset; |
| 1438 return p; | 1374 return p; |
| 1447 PyErr_SetString(PyExc_ValueError, | 1383 PyErr_SetString(PyExc_ValueError, |
| 1448 "field elt is required for ListComp"); | 1384 "field elt is required for ListComp"); |
| 1449 return NULL; | 1385 return NULL; |
| 1450 } | 1386 } |
| 1451 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1387 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1452 if (!p) { | 1388 if (!p) |
| 1453 PyErr_NoMemory(); | 1389 return NULL; |
| 1454 return NULL; | |
| 1455 } | |
| 1456 p->kind = ListComp_kind; | 1390 p->kind = ListComp_kind; |
| 1457 p->v.ListComp.elt = elt; | 1391 p->v.ListComp.elt = elt; |
| 1458 p->v.ListComp.generators = generators; | 1392 p->v.ListComp.generators = generators; |
| 1459 p->lineno = lineno; | 1393 p->lineno = lineno; |
| 1460 p->col_offset = col_offset; | 1394 p->col_offset = col_offset; |
| 1470 PyErr_SetString(PyExc_ValueError, | 1404 PyErr_SetString(PyExc_ValueError, |
| 1471 "field elt is required for GeneratorExp"); | 1405 "field elt is required for GeneratorExp"); |
| 1472 return NULL; | 1406 return NULL; |
| 1473 } | 1407 } |
| 1474 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1408 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1475 if (!p) { | 1409 if (!p) |
| 1476 PyErr_NoMemory(); | 1410 return NULL; |
| 1477 return NULL; | |
| 1478 } | |
| 1479 p->kind = GeneratorExp_kind; | 1411 p->kind = GeneratorExp_kind; |
| 1480 p->v.GeneratorExp.elt = elt; | 1412 p->v.GeneratorExp.elt = elt; |
| 1481 p->v.GeneratorExp.generators = generators; | 1413 p->v.GeneratorExp.generators = generators; |
| 1482 p->lineno = lineno; | 1414 p->lineno = lineno; |
| 1483 p->col_offset = col_offset; | 1415 p->col_offset = col_offset; |
| 1487 expr_ty | 1419 expr_ty |
| 1488 Yield(expr_ty value, int lineno, int col_offset, PyArena *arena) | 1420 Yield(expr_ty value, int lineno, int col_offset, PyArena *arena) |
| 1489 { | 1421 { |
| 1490 expr_ty p; | 1422 expr_ty p; |
| 1491 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1423 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1492 if (!p) { | 1424 if (!p) |
| 1493 PyErr_NoMemory(); | 1425 return NULL; |
| 1494 return NULL; | |
| 1495 } | |
| 1496 p->kind = Yield_kind; | 1426 p->kind = Yield_kind; |
| 1497 p->v.Yield.value = value; | 1427 p->v.Yield.value = value; |
| 1498 p->lineno = lineno; | 1428 p->lineno = lineno; |
| 1499 p->col_offset = col_offset; | 1429 p->col_offset = col_offset; |
| 1500 return p; | 1430 return p; |
| 1509 PyErr_SetString(PyExc_ValueError, | 1439 PyErr_SetString(PyExc_ValueError, |
| 1510 "field left is required for Compare"); | 1440 "field left is required for Compare"); |
| 1511 return NULL; | 1441 return NULL; |
| 1512 } | 1442 } |
| 1513 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1443 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1514 if (!p) { | 1444 if (!p) |
| 1515 PyErr_NoMemory(); | 1445 return NULL; |
| 1516 return NULL; | |
| 1517 } | |
| 1518 p->kind = Compare_kind; | 1446 p->kind = Compare_kind; |
| 1519 p->v.Compare.left = left; | 1447 p->v.Compare.left = left; |
| 1520 p->v.Compare.ops = ops; | 1448 p->v.Compare.ops = ops; |
| 1521 p->v.Compare.comparators = comparators; | 1449 p->v.Compare.comparators = comparators; |
| 1522 p->lineno = lineno; | 1450 p->lineno = lineno; |
| 1533 PyErr_SetString(PyExc_ValueError, | 1461 PyErr_SetString(PyExc_ValueError, |
| 1534 "field func is required for Call"); | 1462 "field func is required for Call"); |
| 1535 return NULL; | 1463 return NULL; |
| 1536 } | 1464 } |
| 1537 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1465 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1538 if (!p) { | 1466 if (!p) |
| 1539 PyErr_NoMemory(); | 1467 return NULL; |
| 1540 return NULL; | |
| 1541 } | |
| 1542 p->kind = Call_kind; | 1468 p->kind = Call_kind; |
| 1543 p->v.Call.func = func; | 1469 p->v.Call.func = func; |
| 1544 p->v.Call.args = args; | 1470 p->v.Call.args = args; |
| 1545 p->v.Call.keywords = keywords; | 1471 p->v.Call.keywords = keywords; |
| 1546 p->v.Call.starargs = starargs; | 1472 p->v.Call.starargs = starargs; |
| 1558 PyErr_SetString(PyExc_ValueError, | 1484 PyErr_SetString(PyExc_ValueError, |
| 1559 "field n is required for Num"); | 1485 "field n is required for Num"); |
| 1560 return NULL; | 1486 return NULL; |
| 1561 } | 1487 } |
| 1562 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1488 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1563 if (!p) { | 1489 if (!p) |
| 1564 PyErr_NoMemory(); | 1490 return NULL; |
| 1565 return NULL; | |
| 1566 } | |
| 1567 p->kind = Num_kind; | 1491 p->kind = Num_kind; |
| 1568 p->v.Num.n = n; | 1492 p->v.Num.n = n; |
| 1569 p->lineno = lineno; | 1493 p->lineno = lineno; |
| 1570 p->col_offset = col_offset; | 1494 p->col_offset = col_offset; |
| 1571 return p; | 1495 return p; |
| 1579 PyErr_SetString(PyExc_ValueError, | 1503 PyErr_SetString(PyExc_ValueError, |
| 1580 "field s is required for Str"); | 1504 "field s is required for Str"); |
| 1581 return NULL; | 1505 return NULL; |
| 1582 } | 1506 } |
| 1583 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1507 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1584 if (!p) { | 1508 if (!p) |
| 1585 PyErr_NoMemory(); | 1509 return NULL; |
| 1586 return NULL; | |
| 1587 } | |
| 1588 p->kind = Str_kind; | 1510 p->kind = Str_kind; |
| 1589 p->v.Str.s = s; | 1511 p->v.Str.s = s; |
| 1590 p->lineno = lineno; | 1512 p->lineno = lineno; |
| 1591 p->col_offset = col_offset; | 1513 p->col_offset = col_offset; |
| 1592 return p; | 1514 return p; |
| 1600 PyErr_SetString(PyExc_ValueError, | 1522 PyErr_SetString(PyExc_ValueError, |
| 1601 "field s is required for Bytes"); | 1523 "field s is required for Bytes"); |
| 1602 return NULL; | 1524 return NULL; |
| 1603 } | 1525 } |
| 1604 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1526 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1605 if (!p) { | 1527 if (!p) |
| 1606 PyErr_NoMemory(); | 1528 return NULL; |
| 1607 return NULL; | |
| 1608 } | |
| 1609 p->kind = Bytes_kind; | 1529 p->kind = Bytes_kind; |
| 1610 p->v.Bytes.s = s; | 1530 p->v.Bytes.s = s; |
| 1611 p->lineno = lineno; | 1531 p->lineno = lineno; |
| 1612 p->col_offset = col_offset; | 1532 p->col_offset = col_offset; |
| 1613 return p; | 1533 return p; |
| 1616 expr_ty | 1536 expr_ty |
| 1617 Ellipsis(int lineno, int col_offset, PyArena *arena) | 1537 Ellipsis(int lineno, int col_offset, PyArena *arena) |
| 1618 { | 1538 { |
| 1619 expr_ty p; | 1539 expr_ty p; |
| 1620 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1540 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1621 if (!p) { | 1541 if (!p) |
| 1622 PyErr_NoMemory(); | 1542 return NULL; |
| 1623 return NULL; | |
| 1624 } | |
| 1625 p->kind = Ellipsis_kind; | 1543 p->kind = Ellipsis_kind; |
| 1626 p->lineno = lineno; | 1544 p->lineno = lineno; |
| 1627 p->col_offset = col_offset; | 1545 p->col_offset = col_offset; |
| 1628 return p; | 1546 return p; |
| 1629 } | 1547 } |
| 1647 PyErr_SetString(PyExc_ValueError, | 1565 PyErr_SetString(PyExc_ValueError, |
| 1648 "field ctx is required for Attribute"); | 1566 "field ctx is required for Attribute"); |
| 1649 return NULL; | 1567 return NULL; |
| 1650 } | 1568 } |
| 1651 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1569 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1652 if (!p) { | 1570 if (!p) |
| 1653 PyErr_NoMemory(); | 1571 return NULL; |
| 1654 return NULL; | |
| 1655 } | |
| 1656 p->kind = Attribute_kind; | 1572 p->kind = Attribute_kind; |
| 1657 p->v.Attribute.value = value; | 1573 p->v.Attribute.value = value; |
| 1658 p->v.Attribute.attr = attr; | 1574 p->v.Attribute.attr = attr; |
| 1659 p->v.Attribute.ctx = ctx; | 1575 p->v.Attribute.ctx = ctx; |
| 1660 p->lineno = lineno; | 1576 p->lineno = lineno; |
| 1681 PyErr_SetString(PyExc_ValueError, | 1597 PyErr_SetString(PyExc_ValueError, |
| 1682 "field ctx is required for Subscript"); | 1598 "field ctx is required for Subscript"); |
| 1683 return NULL; | 1599 return NULL; |
| 1684 } | 1600 } |
| 1685 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1601 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1686 if (!p) { | 1602 if (!p) |
| 1687 PyErr_NoMemory(); | 1603 return NULL; |
| 1688 return NULL; | |
| 1689 } | |
| 1690 p->kind = Subscript_kind; | 1604 p->kind = Subscript_kind; |
| 1691 p->v.Subscript.value = value; | 1605 p->v.Subscript.value = value; |
| 1692 p->v.Subscript.slice = slice; | 1606 p->v.Subscript.slice = slice; |
| 1693 p->v.Subscript.ctx = ctx; | 1607 p->v.Subscript.ctx = ctx; |
| 1694 p->lineno = lineno; | 1608 p->lineno = lineno; |
| 1710 PyErr_SetString(PyExc_ValueError, | 1624 PyErr_SetString(PyExc_ValueError, |
| 1711 "field ctx is required for Name"); | 1625 "field ctx is required for Name"); |
| 1712 return NULL; | 1626 return NULL; |
| 1713 } | 1627 } |
| 1714 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1628 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1715 if (!p) { | 1629 if (!p) |
| 1716 PyErr_NoMemory(); | 1630 return NULL; |
| 1717 return NULL; | |
| 1718 } | |
| 1719 p->kind = Name_kind; | 1631 p->kind = Name_kind; |
| 1720 p->v.Name.id = id; | 1632 p->v.Name.id = id; |
| 1721 p->v.Name.ctx = ctx; | 1633 p->v.Name.ctx = ctx; |
| 1722 p->lineno = lineno; | 1634 p->lineno = lineno; |
| 1723 p->col_offset = col_offset; | 1635 p->col_offset = col_offset; |
| 1733 PyErr_SetString(PyExc_ValueError, | 1645 PyErr_SetString(PyExc_ValueError, |
| 1734 "field ctx is required for List"); | 1646 "field ctx is required for List"); |
| 1735 return NULL; | 1647 return NULL; |
| 1736 } | 1648 } |
| 1737 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1649 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1738 if (!p) { | 1650 if (!p) |
| 1739 PyErr_NoMemory(); | 1651 return NULL; |
| 1740 return NULL; | |
| 1741 } | |
| 1742 p->kind = List_kind; | 1652 p->kind = List_kind; |
| 1743 p->v.List.elts = elts; | 1653 p->v.List.elts = elts; |
| 1744 p->v.List.ctx = ctx; | 1654 p->v.List.ctx = ctx; |
| 1745 p->lineno = lineno; | 1655 p->lineno = lineno; |
| 1746 p->col_offset = col_offset; | 1656 p->col_offset = col_offset; |
| 1756 PyErr_SetString(PyExc_ValueError, | 1666 PyErr_SetString(PyExc_ValueError, |
| 1757 "field ctx is required for Tuple"); | 1667 "field ctx is required for Tuple"); |
| 1758 return NULL; | 1668 return NULL; |
| 1759 } | 1669 } |
| 1760 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1670 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1761 if (!p) { | 1671 if (!p) |
| 1762 PyErr_NoMemory(); | 1672 return NULL; |
| 1763 return NULL; | |
| 1764 } | |
| 1765 p->kind = Tuple_kind; | 1673 p->kind = Tuple_kind; |
| 1766 p->v.Tuple.elts = elts; | 1674 p->v.Tuple.elts = elts; |
| 1767 p->v.Tuple.ctx = ctx; | 1675 p->v.Tuple.ctx = ctx; |
| 1768 p->lineno = lineno; | 1676 p->lineno = lineno; |
| 1769 p->col_offset = col_offset; | 1677 p->col_offset = col_offset; |
| 1773 slice_ty | 1681 slice_ty |
| 1774 Slice(expr_ty lower, expr_ty upper, expr_ty step, PyArena *arena) | 1682 Slice(expr_ty lower, expr_ty upper, expr_ty step, PyArena *arena) |
| 1775 { | 1683 { |
| 1776 slice_ty p; | 1684 slice_ty p; |
| 1777 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); | 1685 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1778 if (!p) { | 1686 if (!p) |
| 1779 PyErr_NoMemory(); | 1687 return NULL; |
| 1780 return NULL; | |
| 1781 } | |
| 1782 p->kind = Slice_kind; | 1688 p->kind = Slice_kind; |
| 1783 p->v.Slice.lower = lower; | 1689 p->v.Slice.lower = lower; |
| 1784 p->v.Slice.upper = upper; | 1690 p->v.Slice.upper = upper; |
| 1785 p->v.Slice.step = step; | 1691 p->v.Slice.step = step; |
| 1786 return p; | 1692 return p; |
| 1789 slice_ty | 1695 slice_ty |
| 1790 ExtSlice(asdl_seq * dims, PyArena *arena) | 1696 ExtSlice(asdl_seq * dims, PyArena *arena) |
| 1791 { | 1697 { |
| 1792 slice_ty p; | 1698 slice_ty p; |
| 1793 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); | 1699 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1794 if (!p) { | 1700 if (!p) |
| 1795 PyErr_NoMemory(); | 1701 return NULL; |
| 1796 return NULL; | |
| 1797 } | |
| 1798 p->kind = ExtSlice_kind; | 1702 p->kind = ExtSlice_kind; |
| 1799 p->v.ExtSlice.dims = dims; | 1703 p->v.ExtSlice.dims = dims; |
| 1800 return p; | 1704 return p; |
| 1801 } | 1705 } |
| 1802 | 1706 |
| 1808 PyErr_SetString(PyExc_ValueError, | 1712 PyErr_SetString(PyExc_ValueError, |
| 1809 "field value is required for Index"); | 1713 "field value is required for Index"); |
| 1810 return NULL; | 1714 return NULL; |
| 1811 } | 1715 } |
| 1812 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); | 1716 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1813 if (!p) { | 1717 if (!p) |
| 1814 PyErr_NoMemory(); | 1718 return NULL; |
| 1815 return NULL; | |
| 1816 } | |
| 1817 p->kind = Index_kind; | 1719 p->kind = Index_kind; |
| 1818 p->v.Index.value = value; | 1720 p->v.Index.value = value; |
| 1819 return p; | 1721 return p; |
| 1820 } | 1722 } |
| 1821 | 1723 |
| 1832 PyErr_SetString(PyExc_ValueError, | 1734 PyErr_SetString(PyExc_ValueError, |
| 1833 "field iter is required for comprehension"); | 1735 "field iter is required for comprehension"); |
| 1834 return NULL; | 1736 return NULL; |
| 1835 } | 1737 } |
| 1836 p = (comprehension_ty)PyArena_Malloc(arena, sizeof(*p)); | 1738 p = (comprehension_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1837 if (!p) { | 1739 if (!p) |
| 1838 PyErr_NoMemory(); | 1740 return NULL; |
| 1839 return NULL; | |
| 1840 } | |
| 1841 p->target = target; | 1741 p->target = target; |
| 1842 p->iter = iter; | 1742 p->iter = iter; |
| 1843 p->ifs = ifs; | 1743 p->ifs = ifs; |
| 1844 return p; | 1744 return p; |
| 1845 } | 1745 } |
| 1848 excepthandler(expr_ty type, identifier name, asdl_seq * body, int lineno, int | 1748 excepthandler(expr_ty type, identifier name, asdl_seq * body, int lineno, int |
| 1849 col_offset, PyArena *arena) | 1749 col_offset, PyArena *arena) |
| 1850 { | 1750 { |
| 1851 excepthandler_ty p; | 1751 excepthandler_ty p; |
| 1852 p = (excepthandler_ty)PyArena_Malloc(arena, sizeof(*p)); | 1752 p = (excepthandler_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1853 if (!p) { | 1753 if (!p) |
| 1854 PyErr_NoMemory(); | 1754 return NULL; |
| 1855 return NULL; | |
| 1856 } | |
| 1857 p->type = type; | 1755 p->type = type; |
| 1858 p->name = name; | 1756 p->name = name; |
| 1859 p->body = body; | 1757 p->body = body; |
| 1860 p->lineno = lineno; | 1758 p->lineno = lineno; |
| 1861 p->col_offset = col_offset; | 1759 p->col_offset = col_offset; |
| 1867 asdl_seq * kwonlyargs, identifier kwarg, expr_ty kwargannotation, | 1765 asdl_seq * kwonlyargs, identifier kwarg, expr_ty kwargannotation, |
| 1868 asdl_seq * defaults, asdl_seq * kw_defaults, PyArena *arena) | 1766 asdl_seq * defaults, asdl_seq * kw_defaults, PyArena *arena) |
| 1869 { | 1767 { |
| 1870 arguments_ty p; | 1768 arguments_ty p; |
| 1871 p = (arguments_ty)PyArena_Malloc(arena, sizeof(*p)); | 1769 p = (arguments_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1872 if (!p) { | 1770 if (!p) |
| 1873 PyErr_NoMemory(); | 1771 return NULL; |
| 1874 return NULL; | |
| 1875 } | |
| 1876 p->args = args; | 1772 p->args = args; |
| 1877 p->vararg = vararg; | 1773 p->vararg = vararg; |
| 1878 p->varargannotation = varargannotation; | 1774 p->varargannotation = varargannotation; |
| 1879 p->kwonlyargs = kwonlyargs; | 1775 p->kwonlyargs = kwonlyargs; |
| 1880 p->kwarg = kwarg; | 1776 p->kwarg = kwarg; |
| 1892 PyErr_SetString(PyExc_ValueError, | 1788 PyErr_SetString(PyExc_ValueError, |
| 1893 "field arg is required for SimpleArg"); | 1789 "field arg is required for SimpleArg"); |
| 1894 return NULL; | 1790 return NULL; |
| 1895 } | 1791 } |
| 1896 p = (arg_ty)PyArena_Malloc(arena, sizeof(*p)); | 1792 p = (arg_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1897 if (!p) { | 1793 if (!p) |
| 1898 PyErr_NoMemory(); | 1794 return NULL; |
| 1899 return NULL; | |
| 1900 } | |
| 1901 p->kind = SimpleArg_kind; | 1795 p->kind = SimpleArg_kind; |
| 1902 p->v.SimpleArg.arg = arg; | 1796 p->v.SimpleArg.arg = arg; |
| 1903 p->v.SimpleArg.annotation = annotation; | 1797 p->v.SimpleArg.annotation = annotation; |
| 1904 return p; | 1798 return p; |
| 1905 } | 1799 } |
| 1907 arg_ty | 1801 arg_ty |
| 1908 NestedArgs(asdl_seq * args, PyArena *arena) | 1802 NestedArgs(asdl_seq * args, PyArena *arena) |
| 1909 { | 1803 { |
| 1910 arg_ty p; | 1804 arg_ty p; |
| 1911 p = (arg_ty)PyArena_Malloc(arena, sizeof(*p)); | 1805 p = (arg_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1912 if (!p) { | 1806 if (!p) |
| 1913 PyErr_NoMemory(); | 1807 return NULL; |
| 1914 return NULL; | |
| 1915 } | |
| 1916 p->kind = NestedArgs_kind; | 1808 p->kind = NestedArgs_kind; |
| 1917 p->v.NestedArgs.args = args; | 1809 p->v.NestedArgs.args = args; |
| 1918 return p; | 1810 return p; |
| 1919 } | 1811 } |
| 1920 | 1812 |
| 1931 PyErr_SetString(PyExc_ValueError, | 1823 PyErr_SetString(PyExc_ValueError, |
| 1932 "field value is required for keyword"); | 1824 "field value is required for keyword"); |
| 1933 return NULL; | 1825 return NULL; |
| 1934 } | 1826 } |
| 1935 p = (keyword_ty)PyArena_Malloc(arena, sizeof(*p)); | 1827 p = (keyword_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1936 if (!p) { | 1828 if (!p) |
| 1937 PyErr_NoMemory(); | 1829 return NULL; |
| 1938 return NULL; | |
| 1939 } | |
| 1940 p->arg = arg; | 1830 p->arg = arg; |
| 1941 p->value = value; | 1831 p->value = value; |
| 1942 return p; | 1832 return p; |
| 1943 } | 1833 } |
| 1944 | 1834 |
| 1950 PyErr_SetString(PyExc_ValueError, | 1840 PyErr_SetString(PyExc_ValueError, |
| 1951 "field name is required for alias"); | 1841 "field name is required for alias"); |
| 1952 return NULL; | 1842 return NULL; |
| 1953 } | 1843 } |
| 1954 p = (alias_ty)PyArena_Malloc(arena, sizeof(*p)); | 1844 p = (alias_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1955 if (!p) { | 1845 if (!p) |
| 1956 PyErr_NoMemory(); | 1846 return NULL; |
| 1957 return NULL; | |
| 1958 } | |
| 1959 p->name = name; | 1847 p->name = name; |
| 1960 p->asname = asname; | 1848 p->asname = asname; |
| 1961 return p; | 1849 return p; |
| 1962 } | 1850 } |
| 1963 | 1851 |
| 3123 if (!m) return; | 3011 if (!m) return; |
| 3124 d = PyModule_GetDict(m); | 3012 d = PyModule_GetDict(m); |
| 3125 if (PyDict_SetItemString(d, "AST", (PyObject*)AST_type) < 0) return; | 3013 if (PyDict_SetItemString(d, "AST", (PyObject*)AST_type) < 0) return; |
| 3126 if (PyModule_AddIntConstant(m, "PyCF_ONLY_AST", PyCF_ONLY_AST) < 0) | 3014 if (PyModule_AddIntConstant(m, "PyCF_ONLY_AST", PyCF_ONLY_AST) < 0) |
| 3127 return; | 3015 return; |
| 3128 if (PyModule_AddStringConstant(m, "__version__", "53872") < 0) | 3016 if (PyModule_AddStringConstant(m, "__version__", "53873") < 0) |
| 3129 return; | 3017 return; |
| 3130 if (PyDict_SetItemString(d, "mod", (PyObject*)mod_type) < 0) return; | 3018 if (PyDict_SetItemString(d, "mod", (PyObject*)mod_type) < 0) return; |
| 3131 if (PyDict_SetItemString(d, "Module", (PyObject*)Module_type) < 0) | 3019 if (PyDict_SetItemString(d, "Module", (PyObject*)Module_type) < 0) |
| 3132 return; | 3020 return; |
| 3133 if (PyDict_SetItemString(d, "Interactive", (PyObject*)Interactive_type) | 3021 if (PyDict_SetItemString(d, "Interactive", (PyObject*)Interactive_type) |
