Kaydet (Commit) 0be5aab0 authored tarafından Thomas Wouters's avatar Thomas Wouters

Merge UNPACK_LIST and UNPACK_TUPLE into a single UNPACK_SEQUENCE, since they

did the same anyway.

I'm not sure what to do with Tools/compiler/compiler/* -- that isn't part of
distutils, is it ? Should it try to be compatible with old bytecode version ?
üst a8d7341f
...@@ -337,14 +337,14 @@ Implements \code{del name}, where \var{namei} is the index into ...@@ -337,14 +337,14 @@ Implements \code{del name}, where \var{namei} is the index into
\member{co_names} attribute of the code object. \member{co_names} attribute of the code object.
\end{opcodedesc} \end{opcodedesc}
\begin{opcodedesc}{UNPACK_TUPLE}{count} \begin{opcodedesc}{UNPACK_SEQUENCE}{count}
Unpacks TOS into \var{count} individual values, which are put onto Unpacks TOS into \var{count} individual values, which are put onto
the stack right-to-left. the stack right-to-left.
\end{opcodedesc} \end{opcodedesc}
\begin{opcodedesc}{UNPACK_LIST}{count} %\begin{opcodedesc}{UNPACK_LIST}{count}
Unpacks TOS into \var{count} individual values. %This opcode is obsolete.
\end{opcodedesc} %\end{opcodedesc}
%\begin{opcodedesc}{UNPACK_ARG}{count} %\begin{opcodedesc}{UNPACK_ARG}{count}
%This opcode is obsolete. %This opcode is obsolete.
......
...@@ -76,8 +76,8 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. ...@@ -76,8 +76,8 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#define STORE_NAME 90 /* Index in name list */ #define STORE_NAME 90 /* Index in name list */
#define DELETE_NAME 91 /* "" */ #define DELETE_NAME 91 /* "" */
#define UNPACK_TUPLE 92 /* Number of tuple items */ #define UNPACK_SEQUENCE 92 /* Number of sequence items */
#define UNPACK_LIST 93 /* Number of list items */
#define STORE_ATTR 95 /* Index in name list */ #define STORE_ATTR 95 /* Index in name list */
#define DELETE_ATTR 96 /* "" */ #define DELETE_ATTR 96 /* "" */
#define STORE_GLOBAL 97 /* "" */ #define STORE_GLOBAL 97 /* "" */
......
...@@ -206,8 +206,8 @@ HAVE_ARGUMENT = 90 # Opcodes from here have an argument: ...@@ -206,8 +206,8 @@ HAVE_ARGUMENT = 90 # Opcodes from here have an argument:
name_op('STORE_NAME', 90) # Index in name list name_op('STORE_NAME', 90) # Index in name list
name_op('DELETE_NAME', 91) # "" name_op('DELETE_NAME', 91) # ""
def_op('UNPACK_TUPLE', 92) # Number of tuple items def_op('UNPACK_SEQUENCE', 92) # Number of tuple items
def_op('UNPACK_LIST', 93) # Number of list items
name_op('STORE_ATTR', 95) # Index in name list name_op('STORE_ATTR', 95) # Index in name list
name_op('DELETE_ATTR', 96) # "" name_op('DELETE_ATTR', 96) # ""
name_op('STORE_GLOBAL', 97) # "" name_op('STORE_GLOBAL', 97) # ""
......
...@@ -1165,8 +1165,7 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals, ...@@ -1165,8 +1165,7 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
default: switch (opcode) { default: switch (opcode) {
#endif #endif
case UNPACK_TUPLE: case UNPACK_SEQUENCE:
case UNPACK_LIST:
v = POP(); v = POP();
if (PyTuple_Check(v)) { if (PyTuple_Check(v)) {
if (PyTuple_Size(v) != oparg) { if (PyTuple_Size(v) != oparg) {
......
...@@ -1729,27 +1729,14 @@ com_assign_trailer(struct compiling *c, node *n, int assigning) ...@@ -1729,27 +1729,14 @@ com_assign_trailer(struct compiling *c, node *n, int assigning)
} }
static void static void
com_assign_tuple(struct compiling *c, node *n, int assigning) com_assign_sequence(struct compiling *c, node *n, int assigning)
{ {
int i; int i;
if (TYPE(n) != testlist) if (TYPE(n) != testlist)
REQ(n, exprlist); REQ(n, exprlist);
if (assigning) { if (assigning) {
i = (NCH(n)+1)/2; i = (NCH(n)+1)/2;
com_addoparg(c, UNPACK_TUPLE, i); com_addoparg(c, UNPACK_SEQUENCE, i);
com_push(c, i-1);
}
for (i = 0; i < NCH(n); i += 2)
com_assign(c, CHILD(n, i), assigning);
}
static void
com_assign_list(struct compiling *c, node *n, int assigning)
{
int i;
if (assigning) {
i = (NCH(n)+1)/2;
com_addoparg(c, UNPACK_LIST, i);
com_push(c, i-1); com_push(c, i-1);
} }
for (i = 0; i < NCH(n); i += 2) for (i = 0; i < NCH(n); i += 2)
...@@ -1775,7 +1762,7 @@ com_assign(struct compiling *c, node *n, int assigning) ...@@ -1775,7 +1762,7 @@ com_assign(struct compiling *c, node *n, int assigning)
case exprlist: case exprlist:
case testlist: case testlist:
if (NCH(n) > 1) { if (NCH(n) > 1) {
com_assign_tuple(c, n, assigning); com_assign_sequence(c, n, assigning);
return; return;
} }
n = CHILD(n, 0); n = CHILD(n, 0);
...@@ -1843,7 +1830,7 @@ com_assign(struct compiling *c, node *n, int assigning) ...@@ -1843,7 +1830,7 @@ com_assign(struct compiling *c, node *n, int assigning)
"can't assign to []"); "can't assign to []");
return; return;
} }
com_assign_list(c, n, assigning); com_assign_sequence(c, n, assigning);
return; return;
case NAME: case NAME:
com_assign_name(c, CHILD(n, 0), assigning); com_assign_name(c, CHILD(n, 0), assigning);
...@@ -2869,7 +2856,7 @@ com_fplist(struct compiling *c, node *n) ...@@ -2869,7 +2856,7 @@ com_fplist(struct compiling *c, node *n)
} }
else { else {
int i = (NCH(n)+1)/2; int i = (NCH(n)+1)/2;
com_addoparg(c, UNPACK_TUPLE, i); com_addoparg(c, UNPACK_SEQUENCE, i);
com_push(c, i-1); com_push(c, i-1);
for (i = 0; i < NCH(n); i += 2) for (i = 0; i < NCH(n); i += 2)
com_fpdef(c, CHILD(n, i)); com_fpdef(c, CHILD(n, i));
......
...@@ -66,7 +66,7 @@ extern time_t PyOS_GetLastModificationTime(char *, FILE *); ...@@ -66,7 +66,7 @@ extern time_t PyOS_GetLastModificationTime(char *, FILE *);
/* XXX Perhaps the magic number should be frozen and a version field /* XXX Perhaps the magic number should be frozen and a version field
added to the .pyc file header? */ added to the .pyc file header? */
/* New way to come up with the magic number: (YEAR-1995), MONTH, DAY */ /* New way to come up with the magic number: (YEAR-1995), MONTH, DAY */
#define MAGIC (50428 | ((long)'\r'<<16) | ((long)'\n'<<24)) #define MAGIC (50811 | ((long)'\r'<<16) | ((long)'\n'<<24))
/* Magic word as global; note that _PyImport_Init() can change the /* Magic word as global; note that _PyImport_Init() can change the
value of this global to accommodate for alterations of how the value of this global to accommodate for alterations of how the
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment