mirror of
https://github.com/python/cpython.git
synced 2025-09-14 04:37:29 +00:00
low-hanging fruit in Python/ - g++ still hates all the enum_kind declarations
in Python/Python-ast.c. Not sure what to do about those.
This commit is contained in:
parent
a62862120d
commit
a863d334aa
4 changed files with 24 additions and 22 deletions
|
@ -2328,6 +2328,8 @@ ast2obj_stmt(void* _o)
|
||||||
result = PyType_GenericNew(Continue_type, NULL, NULL);
|
result = PyType_GenericNew(Continue_type, NULL, NULL);
|
||||||
if (!result) goto failed;
|
if (!result) goto failed;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
;
|
||||||
}
|
}
|
||||||
value = ast2obj_int(o->lineno);
|
value = ast2obj_int(o->lineno);
|
||||||
if (!value) goto failed;
|
if (!value) goto failed;
|
||||||
|
|
38
Python/ast.c
38
Python/ast.c
|
@ -1365,7 +1365,7 @@ ast_for_binop(struct compiling *c, const node *n)
|
||||||
|
|
||||||
int i, nops;
|
int i, nops;
|
||||||
expr_ty expr1, expr2, result;
|
expr_ty expr1, expr2, result;
|
||||||
operator_ty operator;
|
operator_ty newoperator;
|
||||||
|
|
||||||
expr1 = ast_for_expr(c, CHILD(n, 0));
|
expr1 = ast_for_expr(c, CHILD(n, 0));
|
||||||
if (!expr1)
|
if (!expr1)
|
||||||
|
@ -1375,11 +1375,11 @@ ast_for_binop(struct compiling *c, const node *n)
|
||||||
if (!expr2)
|
if (!expr2)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
operator = get_operator(CHILD(n, 1));
|
newoperator = get_operator(CHILD(n, 1));
|
||||||
if (!operator)
|
if (!newoperator)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
result = BinOp(expr1, operator, expr2, LINENO(n), n->n_col_offset,
|
result = BinOp(expr1, newoperator, expr2, LINENO(n), n->n_col_offset,
|
||||||
c->c_arena);
|
c->c_arena);
|
||||||
if (!result)
|
if (!result)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1389,15 +1389,15 @@ ast_for_binop(struct compiling *c, const node *n)
|
||||||
expr_ty tmp_result, tmp;
|
expr_ty tmp_result, tmp;
|
||||||
const node* next_oper = CHILD(n, i * 2 + 1);
|
const node* next_oper = CHILD(n, i * 2 + 1);
|
||||||
|
|
||||||
operator = get_operator(next_oper);
|
newoperator = get_operator(next_oper);
|
||||||
if (!operator)
|
if (!newoperator)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
tmp = ast_for_expr(c, CHILD(n, i * 2 + 2));
|
tmp = ast_for_expr(c, CHILD(n, i * 2 + 2));
|
||||||
if (!tmp)
|
if (!tmp)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
tmp_result = BinOp(result, operator, tmp,
|
tmp_result = BinOp(result, newoperator, tmp,
|
||||||
LINENO(next_oper), next_oper->n_col_offset,
|
LINENO(next_oper), next_oper->n_col_offset,
|
||||||
c->c_arena);
|
c->c_arena);
|
||||||
if (!tmp)
|
if (!tmp)
|
||||||
|
@ -1610,10 +1610,10 @@ ast_for_expr(struct compiling *c, const node *n)
|
||||||
}
|
}
|
||||||
for (i = 1; i < NCH(n); i += 2) {
|
for (i = 1; i < NCH(n); i += 2) {
|
||||||
/* XXX cmpop_ty is just an enum */
|
/* XXX cmpop_ty is just an enum */
|
||||||
cmpop_ty operator;
|
cmpop_ty newoperator;
|
||||||
|
|
||||||
operator = ast_for_comp_op(CHILD(n, i));
|
newoperator = ast_for_comp_op(CHILD(n, i));
|
||||||
if (!operator) {
|
if (!newoperator) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1622,7 +1622,7 @@ ast_for_expr(struct compiling *c, const node *n)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
asdl_seq_SET(ops, i / 2, (void *)(Py_uintptr_t)operator);
|
asdl_seq_SET(ops, i / 2, (void *)(Py_uintptr_t)newoperator);
|
||||||
asdl_seq_SET(cmps, i / 2, expression);
|
asdl_seq_SET(cmps, i / 2, expression);
|
||||||
}
|
}
|
||||||
expression = ast_for_expr(c, CHILD(n, 0));
|
expression = ast_for_expr(c, CHILD(n, 0));
|
||||||
|
@ -1882,7 +1882,7 @@ ast_for_expr_stmt(struct compiling *c, const node *n)
|
||||||
}
|
}
|
||||||
else if (TYPE(CHILD(n, 1)) == augassign) {
|
else if (TYPE(CHILD(n, 1)) == augassign) {
|
||||||
expr_ty expr1, expr2;
|
expr_ty expr1, expr2;
|
||||||
operator_ty operator;
|
operator_ty newoperator;
|
||||||
node *ch = CHILD(n, 0);
|
node *ch = CHILD(n, 0);
|
||||||
|
|
||||||
if (TYPE(ch) == testlist)
|
if (TYPE(ch) == testlist)
|
||||||
|
@ -1924,11 +1924,11 @@ ast_for_expr_stmt(struct compiling *c, const node *n)
|
||||||
if (!expr2)
|
if (!expr2)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
operator = ast_for_augassign(CHILD(n, 1));
|
newoperator = ast_for_augassign(CHILD(n, 1));
|
||||||
if (!operator)
|
if (!newoperator)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return AugAssign(expr1, operator, expr2, LINENO(n), n->n_col_offset, c->c_arena);
|
return AugAssign(expr1, newoperator, expr2, LINENO(n), n->n_col_offset, c->c_arena);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int i;
|
int i;
|
||||||
|
@ -2541,8 +2541,8 @@ ast_for_if_stmt(struct compiling *c, const node *n)
|
||||||
int off = 5 + (n_elif - i - 1) * 4;
|
int off = 5 + (n_elif - i - 1) * 4;
|
||||||
expr_ty expression;
|
expr_ty expression;
|
||||||
asdl_seq *suite_seq;
|
asdl_seq *suite_seq;
|
||||||
asdl_seq *new = asdl_seq_new(1, c->c_arena);
|
asdl_seq *newobj = asdl_seq_new(1, c->c_arena);
|
||||||
if (!new)
|
if (!newobj)
|
||||||
return NULL;
|
return NULL;
|
||||||
expression = ast_for_expr(c, CHILD(n, off));
|
expression = ast_for_expr(c, CHILD(n, off));
|
||||||
if (!expression)
|
if (!expression)
|
||||||
|
@ -2551,10 +2551,10 @@ ast_for_if_stmt(struct compiling *c, const node *n)
|
||||||
if (!suite_seq)
|
if (!suite_seq)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
asdl_seq_SET(new, 0,
|
asdl_seq_SET(newobj, 0,
|
||||||
If(expression, suite_seq, orelse,
|
If(expression, suite_seq, orelse,
|
||||||
LINENO(CHILD(n, off)), CHILD(n, off)->n_col_offset, c->c_arena));
|
LINENO(CHILD(n, off)), CHILD(n, off)->n_col_offset, c->c_arena));
|
||||||
orelse = new;
|
orelse = newobj;
|
||||||
}
|
}
|
||||||
return If(ast_for_expr(c, CHILD(n, 1)),
|
return If(ast_for_expr(c, CHILD(n, 1)),
|
||||||
ast_for_suite(c, CHILD(n, 3)),
|
ast_for_suite(c, CHILD(n, 3)),
|
||||||
|
|
|
@ -507,7 +507,7 @@ PyEval_EvalFrame(PyFrameObject *f) {
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyEval_EvalFrameEx(PyFrameObject *f, int throw)
|
PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
|
||||||
{
|
{
|
||||||
#ifdef DXPAIRS
|
#ifdef DXPAIRS
|
||||||
int lastopcode = 0;
|
int lastopcode = 0;
|
||||||
|
@ -756,7 +756,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throw)
|
||||||
x = Py_None; /* Not a reference, just anything non-NULL */
|
x = Py_None; /* Not a reference, just anything non-NULL */
|
||||||
w = NULL;
|
w = NULL;
|
||||||
|
|
||||||
if (throw) { /* support for generator.throw() */
|
if (throwflag) { /* support for generator.throw() */
|
||||||
why = WHY_EXCEPTION;
|
why = WHY_EXCEPTION;
|
||||||
goto on_error;
|
goto on_error;
|
||||||
}
|
}
|
||||||
|
|
|
@ -893,7 +893,7 @@ SyntaxError__str__(PyObject *self, PyObject *args)
|
||||||
if (have_filename)
|
if (have_filename)
|
||||||
bufsize += PyString_GET_SIZE(filename);
|
bufsize += PyString_GET_SIZE(filename);
|
||||||
|
|
||||||
buffer = PyMem_MALLOC(bufsize);
|
buffer = (char *)PyMem_MALLOC(bufsize);
|
||||||
if (buffer != NULL) {
|
if (buffer != NULL) {
|
||||||
if (have_filename && have_lineno)
|
if (have_filename && have_lineno)
|
||||||
PyOS_snprintf(buffer, bufsize, "%s (%s, line %ld)",
|
PyOS_snprintf(buffer, bufsize, "%s (%s, line %ld)",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue