diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2002-01-01 19:59:11 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2002-01-01 19:59:11 (GMT) |
commit | 7198a525f3e926899ba238f6e6a2e6e9349b7de4 (patch) | |
tree | 37b0c13d1b96f38ea912acc9f9c2b7101ffb0e80 /Python | |
parent | 653d85fc86afa4b96bafcd1544d7ebf64e2ab6cd (diff) | |
download | cpython-7198a525f3e926899ba238f6e6a2e6e9349b7de4.zip cpython-7198a525f3e926899ba238f6e6a2e6e9349b7de4.tar.gz cpython-7198a525f3e926899ba238f6e6a2e6e9349b7de4.tar.bz2 |
Patch #494783: Rename cmp_op enumerators.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/ceval.c | 34 | ||||
-rw-r--r-- | Python/compile.c | 28 |
2 files changed, 33 insertions, 29 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index e7ca82b..c59f31c 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1785,14 +1785,14 @@ eval_frame(PyFrameObject *f) a = PyInt_AS_LONG(v); b = PyInt_AS_LONG(w); switch (oparg) { - case LT: res = a < b; break; - case LE: res = a <= b; break; - case EQ: res = a == b; break; - case NE: res = a != b; break; - case GT: res = a > b; break; - case GE: res = a >= b; break; - case IS: res = v == w; break; - case IS_NOT: res = v != w; break; + case PyCmp_LT: res = a < b; break; + case PyCmp_LE: res = a <= b; break; + case PyCmp_EQ: res = a == b; break; + case PyCmp_NE: res = a != b; break; + case PyCmp_GT: res = a > b; break; + case PyCmp_GE: res = a >= b; break; + case PyCmp_IS: res = v == w; break; + case PyCmp_IS_NOT: res = v != w; break; default: goto slow_compare; } x = res ? Py_True : Py_False; @@ -2986,6 +2986,10 @@ PyEval_MergeCompilerFlags(PyCompilerFlags *cf) result = 1; cf->cf_flags |= compilerflags; } + if (codeflags & CO_GENERATOR_ALLOWED) { + result = 1; + cf->cf_flags |= CO_GENERATOR_ALLOWED; + } } return result; } @@ -3470,21 +3474,21 @@ cmp_outcome(int op, register PyObject *v, register PyObject *w) { int res = 0; switch (op) { - case IS: - case IS_NOT: + case PyCmp_IS: + case PyCmp_IS_NOT: res = (v == w); - if (op == (int) IS_NOT) + if (op == (int) PyCmp_IS_NOT) res = !res; break; - case IN: - case NOT_IN: + case PyCmp_IN: + case PyCmp_NOT_IN: res = PySequence_Contains(w, v); if (res < 0) return NULL; - if (op == (int) NOT_IN) + if (op == (int) PyCmp_NOT_IN) res = !res; break; - case EXC_MATCH: + case PyCmp_EXC_MATCH: res = PyErr_GivenExceptionMatches(v, w); break; default: diff --git a/Python/compile.c b/Python/compile.c index 4421284..ca3a47d 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -702,7 +702,7 @@ com_addbyte(struct compiling *c, int byte) { /*fprintf(stderr, "%3d: %3d\n", c->c_nexti, byte);*/ assert(byte >= 0 && byte <= 255); - assert(c->c_code); + assert(c->c_code != 0); if (com_check_size(&c->c_code, c->c_nexti)) { c->c_errors++; return; @@ -2138,26 +2138,26 @@ cmp_type(node *n) if (NCH(n) == 1) { n = CHILD(n, 0); switch (TYPE(n)) { - case LESS: return LT; - case GREATER: return GT; + case LESS: return PyCmp_LT; + case GREATER: return PyCmp_GT; case EQEQUAL: /* == */ - case EQUAL: return EQ; - case LESSEQUAL: return LE; - case GREATEREQUAL: return GE; - case NOTEQUAL: return NE; /* <> or != */ - case NAME: if (strcmp(STR(n), "in") == 0) return IN; - if (strcmp(STR(n), "is") == 0) return IS; + case EQUAL: return PyCmp_EQ; + case LESSEQUAL: return PyCmp_LE; + case GREATEREQUAL: return PyCmp_GE; + case NOTEQUAL: return PyCmp_NE; /* <> or != */ + case NAME: if (strcmp(STR(n), "in") == 0) return PyCmp_IN; + if (strcmp(STR(n), "is") == 0) return PyCmp_IS; } } else if (NCH(n) == 2) { switch (TYPE(CHILD(n, 0))) { case NAME: if (strcmp(STR(CHILD(n, 1)), "in") == 0) - return NOT_IN; + return PyCmp_NOT_IN; if (strcmp(STR(CHILD(n, 0)), "is") == 0) - return IS_NOT; + return PyCmp_IS_NOT; } } - return BAD; + return PyCmp_BAD; } static void @@ -2214,7 +2214,7 @@ com_comparison(struct compiling *c, node *n) com_addbyte(c, ROT_THREE); } op = cmp_type(CHILD(n, i-1)); - if (op == BAD) { + if (op == PyCmp_BAD) { com_error(c, PyExc_SystemError, "com_comparison: unknown comparison op"); } @@ -3247,7 +3247,7 @@ com_try_except(struct compiling *c, node *n) com_addbyte(c, DUP_TOP); com_push(c, 1); com_node(c, CHILD(ch, 1)); - com_addoparg(c, COMPARE_OP, EXC_MATCH); + com_addoparg(c, COMPARE_OP, PyCmp_EXC_MATCH); com_pop(c, 1); com_addfwref(c, JUMP_IF_FALSE, &except_anchor); com_addbyte(c, POP_TOP); |