diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2010-06-17 12:33:22 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2010-06-17 12:33:22 (GMT) |
commit | d35a32e12eb7e3cf863cff80218e10c9bf3f351f (patch) | |
tree | cd4fd1e5290e5e24c488533464aee681c2d42083 /Python | |
parent | a1b3740d042206efada2b8e1d97349c4d95e34e1 (diff) | |
download | cpython-d35a32e12eb7e3cf863cff80218e10c9bf3f351f.zip cpython-d35a32e12eb7e3cf863cff80218e10c9bf3f351f.tar.gz cpython-d35a32e12eb7e3cf863cff80218e10c9bf3f351f.tar.bz2 |
Issue #9011: Remove buggy and unnecessary ST->AST compilation code
dealing with unary minus applied to a constant. The removed code was
mutating the ST, causing a second compilation to fail. (The peephole
optimizer already takes care of optimizing this case, so there's no
lost optimization opportunity here.)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/ast.c | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/Python/ast.c b/Python/ast.c index 0703abc..34dc30f 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -1678,34 +1678,8 @@ ast_for_trailer(struct compiling *c, const node *n, expr_ty left_expr) static expr_ty ast_for_factor(struct compiling *c, const node *n) { - node *pfactor, *ppower, *patom, *pnum; expr_ty expression; - /* If the unary - operator is applied to a constant, don't generate - a UNARY_NEGATIVE opcode. Just store the approriate value as a - constant. The peephole optimizer already does something like - this but it doesn't handle the case where the constant is - (sys.maxint - 1). In that case, we want a PyIntObject, not a - PyLongObject. - */ - if (TYPE(CHILD(n, 0)) == MINUS - && NCH(n) == 2 - && TYPE((pfactor = CHILD(n, 1))) == factor - && NCH(pfactor) == 1 - && TYPE((ppower = CHILD(pfactor, 0))) == power - && NCH(ppower) == 1 - && TYPE((patom = CHILD(ppower, 0))) == atom - && TYPE((pnum = CHILD(patom, 0))) == NUMBER) { - char *s = PyObject_MALLOC(strlen(STR(pnum)) + 2); - if (s == NULL) - return NULL; - s[0] = '-'; - strcpy(s + 1, STR(pnum)); - PyObject_FREE(STR(pnum)); - STR(pnum) = s; - return ast_for_atom(c, patom); - } - expression = ast_for_expr(c, CHILD(n, 1)); if (!expression) return NULL; |