summaryrefslogtreecommitdiffstats
path: root/Parser/node.c
diff options
context:
space:
mode:
Diffstat (limited to 'Parser/node.c')
-rw-r--r--Parser/node.c32
1 files changed, 4 insertions, 28 deletions
diff --git a/Parser/node.c b/Parser/node.c
index f1b70e0..0dea30f 100644
--- a/Parser/node.c
+++ b/Parser/node.c
@@ -13,8 +13,6 @@ PyNode_New(int type)
n->n_type = type;
n->n_str = NULL;
n->n_lineno = 0;
- n->n_end_lineno = 0;
- n->n_end_col_offset = -1;
n->n_nchildren = 0;
n->n_child = NULL;
return n;
@@ -72,39 +70,19 @@ fancy_roundup(int n)
* Note that this would be straightforward if a node stored its current
* capacity. The code is tricky to avoid that.
*/
-#define XXXROUNDUP(n) ((n) <= 1 ? (n) : \
- (n) <= 128 ? (int)_Py_SIZE_ROUND_UP((n), 4) : \
+#define XXXROUNDUP(n) ((n) <= 1 ? (n) : \
+ (n) <= 128 ? (((n) + 3) & ~3) : \
fancy_roundup(n))
-void
-_PyNode_FinalizeEndPos(node *n)
-{
- int nch = NCH(n);
- node *last;
- if (nch == 0) {
- return;
- }
- last = CHILD(n, nch - 1);
- _PyNode_FinalizeEndPos(last);
- n->n_end_lineno = last->n_end_lineno;
- n->n_end_col_offset = last->n_end_col_offset;
-}
-
int
-PyNode_AddChild(node *n1, int type, char *str, int lineno, int col_offset,
- int end_lineno, int end_col_offset)
+PyNode_AddChild(register node *n1, int type, char *str, int lineno, int col_offset)
{
const int nch = n1->n_nchildren;
int current_capacity;
int required_capacity;
node *n;
- // finalize end position of previous node (if any)
- if (nch > 0) {
- _PyNode_FinalizeEndPos(CHILD(n1, nch - 1));
- }
-
if (nch == INT_MAX || nch < 0)
return E_OVERFLOW;
@@ -113,7 +91,7 @@ PyNode_AddChild(node *n1, int type, char *str, int lineno, int col_offset,
if (current_capacity < 0 || required_capacity < 0)
return E_OVERFLOW;
if (current_capacity < required_capacity) {
- if ((size_t)required_capacity > SIZE_MAX / sizeof(node)) {
+ if (required_capacity > PY_SIZE_MAX / sizeof(node)) {
return E_NOMEM;
}
n = n1->n_child;
@@ -129,8 +107,6 @@ PyNode_AddChild(node *n1, int type, char *str, int lineno, int col_offset,
n->n_str = str;
n->n_lineno = lineno;
n->n_col_offset = col_offset;
- n->n_end_lineno = end_lineno; // this and below will be updates after all children are added.
- n->n_end_col_offset = end_col_offset;
n->n_nchildren = 0;
n->n_child = NULL;
return 0;