Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
3f7ac48b
Commit
3f7ac48b
authored
Aug 25, 2006
by
Brett Cannon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove the UNARY_CONVERT opcode (was used for backticks). Also bumped up the
import MAGIC number.
parent
bbf77970
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
4 additions
and
74 deletions
+4
-74
Doc/lib/libdis.tex
Doc/lib/libdis.tex
+0
-4
Include/Python-ast.h
Include/Python-ast.h
+2
-8
Include/opcode.h
Include/opcode.h
+0
-1
Lib/compiler/pycodegen.py
Lib/compiler/pycodegen.py
+0
-3
Lib/opcode.py
Lib/opcode.py
+0
-1
Parser/Python.asdl
Parser/Python.asdl
+0
-1
Python/Python-ast.c
Python/Python-ast.c
+0
-37
Python/ast.c
Python/ast.c
+0
-3
Python/ceval.c
Python/ceval.c
+0
-8
Python/import.c
Python/import.c
+2
-1
Python/peephole.c
Python/peephole.c
+0
-4
Python/symtable.c
Python/symtable.c
+0
-3
No files found.
Doc/lib/libdis.tex
View file @
3f7ac48b
...
@@ -165,10 +165,6 @@ Implements \code{TOS = -TOS}.
...
@@ -165,10 +165,6 @@ Implements \code{TOS = -TOS}.
Implements
\code
{
TOS = not TOS
}
.
Implements
\code
{
TOS = not TOS
}
.
\end{opcodedesc}
\end{opcodedesc}
\begin{opcodedesc}
{
UNARY
_
CONVERT
}{}
Implements
\code
{
TOS = `TOS`
}
.
\end{opcodedesc}
\begin{opcodedesc}
{
UNARY
_
INVERT
}{}
\begin{opcodedesc}
{
UNARY
_
INVERT
}{}
Implements
\code
{
TOS =
\~
{}
TOS
}
.
Implements
\code
{
TOS =
\~
{}
TOS
}
.
\end{opcodedesc}
\end{opcodedesc}
...
...
Include/Python-ast.h
View file @
3f7ac48b
...
@@ -186,9 +186,8 @@ struct _stmt {
...
@@ -186,9 +186,8 @@ struct _stmt {
enum
_expr_kind
{
BoolOp_kind
=
1
,
BinOp_kind
=
2
,
UnaryOp_kind
=
3
,
Lambda_kind
=
4
,
enum
_expr_kind
{
BoolOp_kind
=
1
,
BinOp_kind
=
2
,
UnaryOp_kind
=
3
,
Lambda_kind
=
4
,
IfExp_kind
=
5
,
Dict_kind
=
6
,
ListComp_kind
=
7
,
IfExp_kind
=
5
,
Dict_kind
=
6
,
ListComp_kind
=
7
,
GeneratorExp_kind
=
8
,
Yield_kind
=
9
,
Compare_kind
=
10
,
GeneratorExp_kind
=
8
,
Yield_kind
=
9
,
Compare_kind
=
10
,
Call_kind
=
11
,
Repr_kind
=
12
,
Num_kind
=
13
,
Str_kind
=
14
,
Call_kind
=
11
,
Num_kind
=
12
,
Str_kind
=
13
,
Attribute_kind
=
14
,
Attribute_kind
=
15
,
Subscript_kind
=
16
,
Name_kind
=
17
,
Subscript_kind
=
15
,
Name_kind
=
16
,
List_kind
=
17
,
Tuple_kind
=
18
};
List_kind
=
18
,
Tuple_kind
=
19
};
struct
_expr
{
struct
_expr
{
enum
_expr_kind
kind
;
enum
_expr_kind
kind
;
union
{
union
{
...
@@ -252,10 +251,6 @@ struct _expr {
...
@@ -252,10 +251,6 @@ struct _expr {
expr_ty
kwargs
;
expr_ty
kwargs
;
}
Call
;
}
Call
;
struct
{
expr_ty
value
;
}
Repr
;
struct
{
struct
{
object
n
;
object
n
;
}
Num
;
}
Num
;
...
@@ -414,7 +409,6 @@ expr_ty Compare(expr_ty left, asdl_int_seq * ops, asdl_seq * comparators, int
...
@@ -414,7 +409,6 @@ expr_ty Compare(expr_ty left, asdl_int_seq * ops, asdl_seq * comparators, int
expr_ty
Call
(
expr_ty
func
,
asdl_seq
*
args
,
asdl_seq
*
keywords
,
expr_ty
expr_ty
Call
(
expr_ty
func
,
asdl_seq
*
args
,
asdl_seq
*
keywords
,
expr_ty
starargs
,
expr_ty
kwargs
,
int
lineno
,
int
col_offset
,
PyArena
starargs
,
expr_ty
kwargs
,
int
lineno
,
int
col_offset
,
PyArena
*
arena
);
*
arena
);
expr_ty
Repr
(
expr_ty
value
,
int
lineno
,
int
col_offset
,
PyArena
*
arena
);
expr_ty
Num
(
object
n
,
int
lineno
,
int
col_offset
,
PyArena
*
arena
);
expr_ty
Num
(
object
n
,
int
lineno
,
int
col_offset
,
PyArena
*
arena
);
expr_ty
Str
(
string
s
,
int
lineno
,
int
col_offset
,
PyArena
*
arena
);
expr_ty
Str
(
string
s
,
int
lineno
,
int
col_offset
,
PyArena
*
arena
);
expr_ty
Attribute
(
expr_ty
value
,
identifier
attr
,
expr_context_ty
ctx
,
int
expr_ty
Attribute
(
expr_ty
value
,
identifier
attr
,
expr_context_ty
ctx
,
int
...
...
Include/opcode.h
View file @
3f7ac48b
...
@@ -18,7 +18,6 @@ extern "C" {
...
@@ -18,7 +18,6 @@ extern "C" {
#define UNARY_POSITIVE 10
#define UNARY_POSITIVE 10
#define UNARY_NEGATIVE 11
#define UNARY_NEGATIVE 11
#define UNARY_NOT 12
#define UNARY_NOT 12
#define UNARY_CONVERT 13
#define UNARY_INVERT 15
#define UNARY_INVERT 15
...
...
Lib/compiler/pycodegen.py
View file @
3f7ac48b
...
@@ -1207,9 +1207,6 @@ class CodeGenerator:
...
@@ -1207,9 +1207,6 @@ class CodeGenerator:
def
visitNot
(
self
,
node
):
def
visitNot
(
self
,
node
):
return
self
.
unaryOp
(
node
,
'UNARY_NOT'
)
return
self
.
unaryOp
(
node
,
'UNARY_NOT'
)
def
visitBackquote
(
self
,
node
):
return
self
.
unaryOp
(
node
,
'UNARY_CONVERT'
)
# bit ops
# bit ops
def
bitOp
(
self
,
nodes
,
op
):
def
bitOp
(
self
,
nodes
,
op
):
...
...
Lib/opcode.py
View file @
3f7ac48b
...
@@ -54,7 +54,6 @@ def_op('NOP', 9)
...
@@ -54,7 +54,6 @@ def_op('NOP', 9)
def_op
(
'UNARY_POSITIVE'
,
10
)
def_op
(
'UNARY_POSITIVE'
,
10
)
def_op
(
'UNARY_NEGATIVE'
,
11
)
def_op
(
'UNARY_NEGATIVE'
,
11
)
def_op
(
'UNARY_NOT'
,
12
)
def_op
(
'UNARY_NOT'
,
12
)
def_op
(
'UNARY_CONVERT'
,
13
)
def_op
(
'UNARY_INVERT'
,
15
)
def_op
(
'UNARY_INVERT'
,
15
)
...
...
Parser/Python.asdl
View file @
3f7ac48b
...
@@ -65,7 +65,6 @@ module Python version "$Revision$"
...
@@ -65,7 +65,6 @@ module Python version "$Revision$"
| Compare(expr left, cmpop* ops, expr* comparators)
| Compare(expr left, cmpop* ops, expr* comparators)
| Call(expr func, expr* args, keyword* keywords,
| Call(expr func, expr* args, keyword* keywords,
expr? starargs, expr? kwargs)
expr? starargs, expr? kwargs)
| Repr(expr value)
| Num(object n) -- a number as a PyObject.
| Num(object n) -- a number as a PyObject.
| Str(string s) -- need to specify raw, unicode, etc?
| Str(string s) -- need to specify raw, unicode, etc?
-- other literals? bools?
-- other literals? bools?
...
...
Python/Python-ast.c
View file @
3f7ac48b
...
@@ -206,10 +206,6 @@ static char *Call_fields[]={
...
@@ -206,10 +206,6 @@ static char *Call_fields[]={
"starargs"
,
"starargs"
,
"kwargs"
,
"kwargs"
,
};
};
static
PyTypeObject
*
Repr_type
;
static
char
*
Repr_fields
[]
=
{
"value"
,
};
static
PyTypeObject
*
Num_type
;
static
PyTypeObject
*
Num_type
;
static
char
*
Num_fields
[]
=
{
static
char
*
Num_fields
[]
=
{
"n"
,
"n"
,
...
@@ -532,8 +528,6 @@ static int init_types(void)
...
@@ -532,8 +528,6 @@ static int init_types(void)
if
(
!
Compare_type
)
return
0
;
if
(
!
Compare_type
)
return
0
;
Call_type
=
make_type
(
"Call"
,
expr_type
,
Call_fields
,
5
);
Call_type
=
make_type
(
"Call"
,
expr_type
,
Call_fields
,
5
);
if
(
!
Call_type
)
return
0
;
if
(
!
Call_type
)
return
0
;
Repr_type
=
make_type
(
"Repr"
,
expr_type
,
Repr_fields
,
1
);
if
(
!
Repr_type
)
return
0
;
Num_type
=
make_type
(
"Num"
,
expr_type
,
Num_fields
,
1
);
Num_type
=
make_type
(
"Num"
,
expr_type
,
Num_fields
,
1
);
if
(
!
Num_type
)
return
0
;
if
(
!
Num_type
)
return
0
;
Str_type
=
make_type
(
"Str"
,
expr_type
,
Str_fields
,
1
);
Str_type
=
make_type
(
"Str"
,
expr_type
,
Str_fields
,
1
);
...
@@ -1552,27 +1546,6 @@ Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, expr_ty starargs,
...
@@ -1552,27 +1546,6 @@ Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, expr_ty starargs,
return
p
;
return
p
;
}
}
expr_ty
Repr
(
expr_ty
value
,
int
lineno
,
int
col_offset
,
PyArena
*
arena
)
{
expr_ty
p
;
if
(
!
value
)
{
PyErr_SetString
(
PyExc_ValueError
,
"field value is required for Repr"
);
return
NULL
;
}
p
=
(
expr_ty
)
PyArena_Malloc
(
arena
,
sizeof
(
*
p
));
if
(
!
p
)
{
PyErr_NoMemory
();
return
NULL
;
}
p
->
kind
=
Repr_kind
;
p
->
v
.
Repr
.
value
=
value
;
p
->
lineno
=
lineno
;
p
->
col_offset
=
col_offset
;
return
p
;
}
expr_ty
expr_ty
Num
(
object
n
,
int
lineno
,
int
col_offset
,
PyArena
*
arena
)
Num
(
object
n
,
int
lineno
,
int
col_offset
,
PyArena
*
arena
)
{
{
...
@@ -2544,15 +2517,6 @@ ast2obj_expr(void* _o)
...
@@ -2544,15 +2517,6 @@ ast2obj_expr(void* _o)
goto
failed
;
goto
failed
;
Py_DECREF
(
value
);
Py_DECREF
(
value
);
break
;
break
;
case
Repr_kind
:
result
=
PyType_GenericNew
(
Repr_type
,
NULL
,
NULL
);
if
(
!
result
)
goto
failed
;
value
=
ast2obj_expr
(
o
->
v
.
Repr
.
value
);
if
(
!
value
)
goto
failed
;
if
(
PyObject_SetAttrString
(
result
,
"value"
,
value
)
==
-
1
)
goto
failed
;
Py_DECREF
(
value
);
break
;
case
Num_kind
:
case
Num_kind
:
result
=
PyType_GenericNew
(
Num_type
,
NULL
,
NULL
);
result
=
PyType_GenericNew
(
Num_type
,
NULL
,
NULL
);
if
(
!
result
)
goto
failed
;
if
(
!
result
)
goto
failed
;
...
@@ -3113,7 +3077,6 @@ init_ast(void)
...
@@ -3113,7 +3077,6 @@ init_ast(void)
if
(
PyDict_SetItemString
(
d
,
"Compare"
,
(
PyObject
*
)
Compare_type
)
<
0
)
if
(
PyDict_SetItemString
(
d
,
"Compare"
,
(
PyObject
*
)
Compare_type
)
<
0
)
return
;
return
;
if
(
PyDict_SetItemString
(
d
,
"Call"
,
(
PyObject
*
)
Call_type
)
<
0
)
return
;
if
(
PyDict_SetItemString
(
d
,
"Call"
,
(
PyObject
*
)
Call_type
)
<
0
)
return
;
if
(
PyDict_SetItemString
(
d
,
"Repr"
,
(
PyObject
*
)
Repr_type
)
<
0
)
return
;
if
(
PyDict_SetItemString
(
d
,
"Num"
,
(
PyObject
*
)
Num_type
)
<
0
)
return
;
if
(
PyDict_SetItemString
(
d
,
"Num"
,
(
PyObject
*
)
Num_type
)
<
0
)
return
;
if
(
PyDict_SetItemString
(
d
,
"Str"
,
(
PyObject
*
)
Str_type
)
<
0
)
return
;
if
(
PyDict_SetItemString
(
d
,
"Str"
,
(
PyObject
*
)
Str_type
)
<
0
)
return
;
if
(
PyDict_SetItemString
(
d
,
"Attribute"
,
(
PyObject
*
)
Attribute_type
)
<
if
(
PyDict_SetItemString
(
d
,
"Attribute"
,
(
PyObject
*
)
Attribute_type
)
<
...
...
Python/ast.c
View file @
3f7ac48b
...
@@ -401,9 +401,6 @@ set_context(expr_ty e, expr_context_ty ctx, const node *n)
...
@@ -401,9 +401,6 @@ set_context(expr_ty e, expr_context_ty ctx, const node *n)
case
Compare_kind
:
case
Compare_kind
:
expr_name
=
"comparison"
;
expr_name
=
"comparison"
;
break
;
break
;
case
Repr_kind
:
expr_name
=
"repr"
;
break
;
case
IfExp_kind
:
case
IfExp_kind
:
expr_name
=
"conditional expression"
;
expr_name
=
"conditional expression"
;
break
;
break
;
...
...
Python/ceval.c
View file @
3f7ac48b
...
@@ -1040,14 +1040,6 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
...
@@ -1040,14 +1040,6 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
STACKADJ
(
-
1
);
STACKADJ
(
-
1
);
break
;
break
;
case
UNARY_CONVERT
:
v
=
TOP
();
x
=
PyObject_Repr
(
v
);
Py_DECREF
(
v
);
SET_TOP
(
x
);
if
(
x
!=
NULL
)
continue
;
break
;
case
UNARY_INVERT
:
case
UNARY_INVERT
:
v
=
TOP
();
v
=
TOP
();
x
=
PyNumber_Invert
(
v
);
x
=
PyNumber_Invert
(
v
);
...
...
Python/import.c
View file @
3f7ac48b
...
@@ -65,9 +65,10 @@ extern time_t PyOS_GetLastModificationTime(char *, FILE *);
...
@@ -65,9 +65,10 @@ extern time_t PyOS_GetLastModificationTime(char *, FILE *);
Python 2.5c1: 62121 (fix wrong lnotab with for loops and
Python 2.5c1: 62121 (fix wrong lnotab with for loops and
storing constants that should have been removed)
storing constants that should have been removed)
Python 3000: 3000
Python 3000: 3000
3010 (removed UNARY_CONVERT)
.
.
*/
*/
#define MAGIC (30
0
0 | ((long)'\r'<<16) | ((long)'\n'<<24))
#define MAGIC (30
1
0 | ((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
...
...
Python/peephole.c
View file @
3f7ac48b
...
@@ -189,9 +189,6 @@ fold_unaryops_on_constants(unsigned char *codestr, PyObject *consts)
...
@@ -189,9 +189,6 @@ fold_unaryops_on_constants(unsigned char *codestr, PyObject *consts)
if
(
PyObject_IsTrue
(
v
)
==
1
)
if
(
PyObject_IsTrue
(
v
)
==
1
)
newconst
=
PyNumber_Negative
(
v
);
newconst
=
PyNumber_Negative
(
v
);
break
;
break
;
case
UNARY_CONVERT
:
newconst
=
PyObject_Repr
(
v
);
break
;
case
UNARY_INVERT
:
case
UNARY_INVERT
:
newconst
=
PyNumber_Invert
(
v
);
newconst
=
PyNumber_Invert
(
v
);
break
;
break
;
...
@@ -470,7 +467,6 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
...
@@ -470,7 +467,6 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
/* Fold unary ops on constants.
/* Fold unary ops on constants.
LOAD_CONST c1 UNARY_OP --> LOAD_CONST unary_op(c) */
LOAD_CONST c1 UNARY_OP --> LOAD_CONST unary_op(c) */
case
UNARY_NEGATIVE
:
case
UNARY_NEGATIVE
:
case
UNARY_CONVERT
:
case
UNARY_INVERT
:
case
UNARY_INVERT
:
if
(
lastlc
>=
1
&&
if
(
lastlc
>=
1
&&
ISBASICBLOCK
(
blocks
,
i
-
3
,
4
)
&&
ISBASICBLOCK
(
blocks
,
i
-
3
,
4
)
&&
...
...
Python/symtable.c
View file @
3f7ac48b
...
@@ -1182,9 +1182,6 @@ symtable_visit_expr(struct symtable *st, expr_ty e)
...
@@ -1182,9 +1182,6 @@ symtable_visit_expr(struct symtable *st, expr_ty e)
if
(
e
->
v
.
Call
.
kwargs
)
if
(
e
->
v
.
Call
.
kwargs
)
VISIT
(
st
,
expr
,
e
->
v
.
Call
.
kwargs
);
VISIT
(
st
,
expr
,
e
->
v
.
Call
.
kwargs
);
break
;
break
;
case
Repr_kind
:
VISIT
(
st
,
expr
,
e
->
v
.
Repr
.
value
);
break
;
case
Num_kind
:
case
Num_kind
:
case
Str_kind
:
case
Str_kind
:
/* Nothing to do here. */
/* Nothing to do here. */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment