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
8861b744
Commit
8861b744
authored
Jul 30, 1996
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changes for slice and ellipses
parent
3ecebf17
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
355 additions
and
181 deletions
+355
-181
Python/bltinmodule.c
Python/bltinmodule.c
+23
-0
Python/ceval.c
Python/ceval.c
+67
-13
Python/compile.c
Python/compile.c
+113
-64
Python/graminit.c
Python/graminit.c
+144
-103
Python/import.c
Python/import.c
+1
-1
Python/marshal.c
Python/marshal.c
+7
-0
No files found.
Python/bltinmodule.c
View file @
8861b744
...
...
@@ -879,6 +879,28 @@ builtin_list(self, args)
return
NULL
;
}
static
PyObject
*
builtin_slice
(
self
,
args
)
PyObject
*
self
;
PyObject
*
args
;
{
PyObject
*
start
,
*
stop
,
*
step
;
start
=
stop
=
step
=
NULL
;
if
(
!
PyArg_ParseTuple
(
args
,
"O|OO:slice"
,
&
start
,
&
stop
,
&
step
))
return
NULL
;
/*This swapping of stop and start is to maintain compatibility with
the range builtin.*/
if
(
stop
==
NULL
)
{
stop
=
start
;
start
=
NULL
;
}
return
PySlice_New
(
start
,
stop
,
step
);
}
static
object
*
builtin_locals
(
self
,
args
)
object
*
self
;
...
...
@@ -1514,6 +1536,7 @@ static struct methodlist builtin_methods[] = {
{
"repr"
,
builtin_repr
,
1
},
{
"round"
,
builtin_round
,
1
},
{
"setattr"
,
builtin_setattr
,
1
},
{
"slice"
,
builtin_slice
,
1
},
{
"str"
,
builtin_str
,
1
},
{
"tuple"
,
builtin_tuple
,
1
},
{
"type"
,
builtin_type
,
1
},
...
...
Python/ceval.c
View file @
8861b744
...
...
@@ -87,6 +87,7 @@ static object *apply_subscript PROTO((object *, object *));
static
object
*
loop_subscript
PROTO
((
object
*
,
object
*
));
static
int
slice_index
PROTO
((
object
*
,
int
,
int
*
));
static
object
*
apply_slice
PROTO
((
object
*
,
object
*
,
object
*
));
static
object
*
build_slice
PROTO
((
object
*
,
object
*
,
object
*
));
static
int
assign_subscript
PROTO
((
object
*
,
object
*
,
object
*
));
static
int
assign_slice
PROTO
((
object
*
,
object
*
,
object
*
,
object
*
));
static
int
cmp_exception
PROTO
((
object
*
,
object
*
));
...
...
@@ -187,6 +188,8 @@ restore_thread(x)
thread (the main thread) ever takes things out of the queue.
*/
static
int
ticker
=
0
;
/* main loop counter to do periodic things */
#define NPENDINGCALLS 32
static
struct
{
int
(
*
func
)
PROTO
((
ANY
*
));
...
...
@@ -215,6 +218,7 @@ Py_AddPendingCall(func, arg)
pendingcalls
[
i
].
func
=
func
;
pendingcalls
[
i
].
arg
=
arg
;
pendinglast
=
j
;
ticker
=
0
;
/* Signal main loop */
busy
=
0
;
/* XXX End critical section */
return
0
;
...
...
@@ -225,11 +229,15 @@ Py_MakePendingCalls()
{
static
int
busy
=
0
;
#ifdef WITH_THREAD
if
(
get_thread_ident
()
!=
main_thread
)
if
(
get_thread_ident
()
!=
main_thread
)
{
ticker
=
0
;
/* We're not done yet */
return
0
;
}
#endif
if
(
busy
)
if
(
busy
)
{
ticker
=
0
;
/* We're not done yet */
return
0
;
}
busy
=
1
;
for
(;;)
{
int
i
;
...
...
@@ -243,6 +251,7 @@ Py_MakePendingCalls()
pendingfirst
=
(
i
+
1
)
%
NPENDINGCALLS
;
if
(
func
(
arg
)
<
0
)
{
busy
=
0
;
ticker
=
0
;
/* We're not done yet */
return
-
1
;
}
}
...
...
@@ -281,6 +290,12 @@ eval_code(co, globals, locals)
/* Interpreter main loop */
#ifndef MAX_RECURSION_DEPTH
#define MAX_RECURSION_DEPTH 10000
#endif
static
int
recursion_depth
=
0
;
static
object
*
eval_code2
(
co
,
globals
,
locals
,
args
,
argcount
,
kws
,
kwcount
,
defs
,
defcount
,
owner
)
...
...
@@ -355,6 +370,13 @@ eval_code2(co, globals, locals,
#define SETLOCAL(i, value) do { XDECREF(GETLOCAL(i)); \
GETLOCAL(i) = value; } while (0)
#ifdef USE_STACKCHECK
if
(
recursion_depth
%
10
==
0
&&
PyOS_CheckStack
())
{
err_setstr
(
MemoryError
,
"Stack overflow"
);
return
NULL
;
}
#endif
if
(
globals
==
NULL
)
{
err_setstr
(
SystemError
,
"eval_code2: NULL globals"
);
return
NULL
;
...
...
@@ -514,6 +536,14 @@ eval_code2(co, globals, locals,
}
}
if
(
++
recursion_depth
>
MAX_RECURSION_DEPTH
)
{
--
recursion_depth
;
err_setstr
(
RuntimeError
,
"Maximum recursion depth exceeded"
);
current_frame
=
f
->
f_back
;
DECREF
(
f
);
return
NULL
;
}
next_instr
=
GETUSTRINGVALUE
(
f
->
f_code
->
co_code
);
stack_pointer
=
f
->
f_valuestack
;
...
...
@@ -522,22 +552,23 @@ eval_code2(co, globals, locals,
x
=
None
;
/* Not a reference, just anything non-NULL */
for
(;;)
{
static
int
ticker
;
/* Do periodic things.
Doing this every time through the loop would add
too much overhead (a function call per instruction).
So we do it only every Nth instruction. */
if
(
pendingfirst
!=
pendinglast
)
{
if
(
Py_MakePendingCalls
()
<
0
)
{
why
=
WHY_EXCEPTION
;
goto
on_error
;
}
}
So we do it only every Nth instruction.
The ticker is reset to zero if there are pending
calls (see Py_AddPendingCalls() and
Py_MakePendingCalls() above). */
if
(
--
ticker
<
0
)
{
ticker
=
sys_checkinterval
;
if
(
pendingfirst
!=
pendinglast
)
{
if
(
Py_MakePendingCalls
()
<
0
)
{
why
=
WHY_EXCEPTION
;
goto
on_error
;
}
}
if
(
sigcheck
())
{
why
=
WHY_EXCEPTION
;
goto
on_error
;
...
...
@@ -1630,7 +1661,22 @@ eval_code2(co, globals, locals,
}
PUSH
(
x
);
break
;
case
BUILD_SLICE
:
if
(
oparg
==
3
)
w
=
POP
();
else
w
=
NULL
;
v
=
POP
();
u
=
POP
();
x
=
build_slice
(
u
,
v
,
w
);
DECREF
(
u
);
DECREF
(
v
);
XDECREF
(
w
);
PUSH
(
x
);
break
;
default:
fprintf
(
stderr
,
"XXX lineno: %d, opcode: %d
\n
"
,
...
...
@@ -1793,6 +1839,7 @@ eval_code2(co, globals, locals,
current_frame
=
f
->
f_back
;
DECREF
(
f
);
--
recursion_depth
;
return
retval
;
}
...
...
@@ -2548,6 +2595,13 @@ slice_index(v, isize, pi)
return
0
;
}
static
object
*
build_slice
(
u
,
v
,
w
)
/* u:v:w */
object
*
u
,
*
v
,
*
w
;
{
return
PySlice_New
(
u
,
v
,
w
);
}
static
object
*
apply_slice
(
u
,
v
,
w
)
/* return u[v:w] */
object
*
u
,
*
v
,
*
w
;
...
...
Python/compile.c
View file @
8861b744
...
...
@@ -47,6 +47,10 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <ctype.h>
#include <errno.h>
#define OP_DELETE 0
#define OP_ASSIGN 1
#define OP_APPLY 2
#define OFF(x) offsetof(codeobject, x)
static
struct
memberlist
code_memberlist
[]
=
{
...
...
@@ -821,31 +825,6 @@ com_slice(c, n, op)
}
}
static
void
com_apply_subscript
(
c
,
n
)
struct
compiling
*
c
;
node
*
n
;
{
REQ
(
n
,
subscript
);
if
(
TYPE
(
CHILD
(
n
,
0
))
==
COLON
||
(
NCH
(
n
)
>
1
&&
TYPE
(
CHILD
(
n
,
1
))
==
COLON
))
{
/* It's a slice: [expr] ':' [expr] */
com_slice
(
c
,
n
,
SLICE
);
}
else
{
/* It's a list of subscripts */
if
(
NCH
(
n
)
==
1
)
com_node
(
c
,
CHILD
(
n
,
0
));
else
{
int
i
;
int
len
=
(
NCH
(
n
)
+
1
)
/
2
;
for
(
i
=
0
;
i
<
NCH
(
n
);
i
+=
2
)
com_node
(
c
,
CHILD
(
n
,
i
));
com_addoparg
(
c
,
BUILD_TUPLE
,
len
);
}
com_addbyte
(
c
,
BINARY_SUBSCR
);
}
}
static
int
com_argument
(
c
,
n
,
inkeywords
)
struct
compiling
*
c
;
...
...
@@ -923,6 +902,107 @@ com_select_member(c, n)
com_addopname
(
c
,
LOAD_ATTR
,
n
);
}
static
void
com_sliceobj
(
c
,
n
)
struct
compiling
*
c
;
node
*
n
;
{
int
i
=
0
;
int
ns
=
2
;
/* number of slice arguments */
int
first_missing
=
0
;
node
*
ch
;
/* first argument */
if
(
TYPE
(
CHILD
(
n
,
i
))
==
COLON
)
{
com_addoparg
(
c
,
LOAD_CONST
,
com_addconst
(
c
,
None
));
i
++
;
}
else
{
com_node
(
c
,
CHILD
(
n
,
i
));
i
++
;
REQ
(
CHILD
(
n
,
i
),
COLON
);
i
++
;
}
/* second argument */
if
(
i
<
NCH
(
n
)
&&
TYPE
(
CHILD
(
n
,
i
))
==
test
)
{
com_node
(
c
,
CHILD
(
n
,
i
));
i
++
;
}
else
com_addoparg
(
c
,
LOAD_CONST
,
com_addconst
(
c
,
None
));
/* remaining arguments */
for
(;
i
<
NCH
(
n
);
i
++
)
{
ns
++
;
ch
=
CHILD
(
n
,
i
);
REQ
(
ch
,
sliceop
);
if
(
NCH
(
ch
)
==
1
)
{
/* right argument of ':' missing */
com_addoparg
(
c
,
LOAD_CONST
,
com_addconst
(
c
,
None
));
}
else
com_node
(
c
,
CHILD
(
ch
,
1
));
}
com_addoparg
(
c
,
BUILD_SLICE
,
ns
);
}
static
void
com_subscript
(
c
,
n
)
struct
compiling
*
c
;
node
*
n
;
{
node
*
ch
;
REQ
(
n
,
subscript
);
ch
=
CHILD
(
n
,
0
);
/* check for rubber index */
if
(
TYPE
(
ch
)
==
DOT
&&
TYPE
(
CHILD
(
n
,
1
))
==
DOT
)
com_addoparg
(
c
,
LOAD_CONST
,
com_addconst
(
c
,
Py_Ellipses
));
else
{
/* check for slice */
if
((
TYPE
(
ch
)
==
COLON
||
NCH
(
n
)
>
1
))
com_sliceobj
(
c
,
n
);
else
{
REQ
(
ch
,
test
);
com_node
(
c
,
ch
);
}
}
}
static
void
com_subscriptlist
(
c
,
n
,
assigning
)
struct
compiling
*
c
;
node
*
n
;
int
assigning
;
{
int
i
,
op
;
REQ
(
n
,
subscriptlist
);
/* Check to make backward compatible slice behavior for '[i:j]' */
if
(
NCH
(
n
)
==
1
)
{
node
*
sub
=
CHILD
(
n
,
0
);
/* subscript */
/* Make it is a simple slice.
should have exactly one colon. */
if
((
TYPE
(
CHILD
(
sub
,
0
))
==
COLON
||
(
NCH
(
sub
)
>
1
&&
TYPE
(
CHILD
(
sub
,
1
))
==
COLON
))
&&
(
TYPE
(
CHILD
(
sub
,
NCH
(
sub
)
-
1
))
!=
sliceop
))
{
if
(
assigning
==
OP_APPLY
)
op
=
SLICE
;
else
op
=
((
assigning
==
OP_ASSIGN
)
?
STORE_SLICE
:
DELETE_SLICE
);
com_slice
(
c
,
sub
,
op
);
return
;
}
}
/* Else normal subscriptlist. Compile each subscript. */
for
(
i
=
0
;
i
<
NCH
(
n
);
i
+=
2
)
com_subscript
(
c
,
CHILD
(
n
,
i
));
/* Put multiple subscripts into a tuple */
if
(
NCH
(
n
)
>
1
)
com_addoparg
(
c
,
BUILD_TUPLE
,
(
NCH
(
n
)
+
1
)
/
2
);
if
(
assigning
==
OP_APPLY
)
op
=
BINARY_SUBSCR
;
else
op
=
((
assigning
==
OP_ASSIGN
)
?
STORE_SUBSCR
:
DELETE_SUBSCR
);
com_addbyte
(
c
,
op
);
}
static
void
com_apply_trailer
(
c
,
n
)
struct
compiling
*
c
;
...
...
@@ -937,7 +1017,7 @@ com_apply_trailer(c, n)
com_select_member
(
c
,
CHILD
(
n
,
1
));
break
;
case
LSQB
:
com_
apply_subscript
(
c
,
CHILD
(
n
,
1
)
);
com_
subscriptlist
(
c
,
CHILD
(
n
,
1
),
OP_APPLY
);
break
;
default:
err_setstr
(
SystemError
,
...
...
@@ -970,6 +1050,7 @@ com_factor(c, n)
struct
compiling
*
c
;
node
*
n
;
{
int
i
;
REQ
(
n
,
factor
);
if
(
TYPE
(
CHILD
(
n
,
0
))
==
PLUS
)
{
com_factor
(
c
,
CHILD
(
n
,
1
));
...
...
@@ -1364,33 +1445,6 @@ com_assign_attr(c, n, assigning)
com_addopname
(
c
,
assigning
?
STORE_ATTR
:
DELETE_ATTR
,
n
);
}
static
void
com_assign_slice
(
c
,
n
,
assigning
)
struct
compiling
*
c
;
node
*
n
;
int
assigning
;
{
com_slice
(
c
,
n
,
assigning
?
STORE_SLICE
:
DELETE_SLICE
);
}
static
void
com_assign_subscript
(
c
,
n
,
assigning
)
struct
compiling
*
c
;
node
*
n
;
int
assigning
;
{
if
(
NCH
(
n
)
==
1
)
com_node
(
c
,
CHILD
(
n
,
0
));
else
{
int
i
;
int
len
=
(
NCH
(
n
)
+
1
)
/
2
;
for
(
i
=
0
;
i
<
NCH
(
n
);
i
+=
2
)
com_node
(
c
,
CHILD
(
n
,
i
));
com_addoparg
(
c
,
BUILD_TUPLE
,
len
);
}
com_addbyte
(
c
,
assigning
?
STORE_SUBSCR
:
DELETE_SUBSCR
);
}
static
void
com_assign_trailer
(
c
,
n
,
assigning
)
struct
compiling
*
c
;
...
...
@@ -1406,13 +1460,8 @@ com_assign_trailer(c, n, assigning)
case
DOT
:
/* '.' NAME */
com_assign_attr
(
c
,
CHILD
(
n
,
1
),
assigning
);
break
;
case
LSQB
:
/* '[' subscript ']' */
n
=
CHILD
(
n
,
1
);
REQ
(
n
,
subscript
);
/* subscript: expr (',' expr)* | [expr] ':' [expr] */
if
(
TYPE
(
CHILD
(
n
,
0
))
==
COLON
||
(
NCH
(
n
)
>
1
&&
TYPE
(
CHILD
(
n
,
1
))
==
COLON
))
com_assign_slice
(
c
,
n
,
assigning
);
else
com_assign_subscript
(
c
,
n
,
assigning
);
case
LSQB
:
/* '[' subscriptlist ']' */
com_subscriptlist
(
c
,
CHILD
(
n
,
1
),
assigning
);
break
;
default:
err_setstr
(
SystemError
,
"unknown trailer type"
);
...
...
@@ -1585,7 +1634,7 @@ com_expr_stmt(c, n)
for
(
i
=
0
;
i
<
NCH
(
n
)
-
2
;
i
+=
2
)
{
if
(
i
+
2
<
NCH
(
n
)
-
2
)
com_addbyte
(
c
,
DUP_TOP
);
com_assign
(
c
,
CHILD
(
n
,
i
),
1
/*assign*/
);
com_assign
(
c
,
CHILD
(
n
,
i
),
OP_ASSIGN
);
}
}
}
...
...
@@ -1896,7 +1945,7 @@ com_for_stmt(c, n)
c
->
c_begin
=
c
->
c_nexti
;
com_addoparg
(
c
,
SET_LINENO
,
n
->
n_lineno
);
com_addfwref
(
c
,
FOR_LOOP
,
&
anchor
);
com_assign
(
c
,
CHILD
(
n
,
1
),
1
/*assigning*/
);
com_assign
(
c
,
CHILD
(
n
,
1
),
OP_ASSIGN
);
c
->
c_loops
++
;
com_node
(
c
,
CHILD
(
n
,
5
));
c
->
c_loops
--
;
...
...
@@ -2015,7 +2064,7 @@ com_try_except(c, n)
}
com_addbyte
(
c
,
POP_TOP
);
if
(
NCH
(
ch
)
>
3
)
com_assign
(
c
,
CHILD
(
ch
,
3
),
1
/*assigning*/
);
com_assign
(
c
,
CHILD
(
ch
,
3
),
OP_ASSIGN
);
else
com_addbyte
(
c
,
POP_TOP
);
com_addbyte
(
c
,
POP_TOP
);
...
...
@@ -2342,7 +2391,7 @@ com_node(c, n)
com_print_stmt
(
c
,
n
);
break
;
case
del_stmt
:
/* 'del' exprlist */
com_assign
(
c
,
CHILD
(
n
,
1
),
0
/*delete*/
);
com_assign
(
c
,
CHILD
(
n
,
1
),
OP_DELETE
);
break
;
case
pass_stmt
:
break
;
...
...
Python/graminit.c
View file @
8861b744
...
...
@@ -1031,169 +1031,204 @@ static state states_48[7] = {
{
1
,
arcs_48_5
},
{
1
,
arcs_48_6
},
};
static
arc
arcs_49_0
[
2
]
=
{
{
21
,
1
},
{
14
,
2
},
static
arc
arcs_49_0
[
1
]
=
{
{
121
,
1
},
};
static
arc
arcs_49_1
[
3
]
=
{
{
22
,
3
},
{
14
,
2
},
static
arc
arcs_49_1
[
2
]
=
{
{
22
,
2
},
{
0
,
1
},
};
static
arc
arcs_49_2
[
2
]
=
{
{
21
,
4
},
{
121
,
1
},
{
0
,
2
},
};
static
state
states_49
[
3
]
=
{
{
1
,
arcs_49_0
},
{
2
,
arcs_49_1
},
{
2
,
arcs_49_2
},
};
static
arc
arcs_50_0
[
3
]
=
{
{
52
,
1
},
{
21
,
2
},
{
14
,
3
},
};
static
arc
arcs_50_1
[
1
]
=
{
{
52
,
4
},
};
static
arc
arcs_50_2
[
2
]
=
{
{
14
,
3
},
{
0
,
2
},
};
static
arc
arcs_
49_3
[
2
]
=
{
static
arc
arcs_
50_3
[
3
]
=
{
{
21
,
5
},
{
122
,
6
},
{
0
,
3
},
};
static
arc
arcs_
49
_4
[
1
]
=
{
{
0
,
4
},
static
arc
arcs_
50
_4
[
1
]
=
{
{
52
,
6
},
};
static
arc
arcs_
49
_5
[
2
]
=
{
{
22
,
3
},
static
arc
arcs_
50
_5
[
2
]
=
{
{
122
,
6
},
{
0
,
5
},
};
static
state
states_49
[
6
]
=
{
{
2
,
arcs_49_0
},
{
3
,
arcs_49_1
},
{
2
,
arcs_49_2
},
{
2
,
arcs_49_3
},
{
1
,
arcs_49_4
},
{
2
,
arcs_49_5
},
static
arc
arcs_50_6
[
1
]
=
{
{
0
,
6
},
};
static
state
states_50
[
7
]
=
{
{
3
,
arcs_50_0
},
{
1
,
arcs_50_1
},
{
2
,
arcs_50_2
},
{
3
,
arcs_50_3
},
{
1
,
arcs_50_4
},
{
2
,
arcs_50_5
},
{
1
,
arcs_50_6
},
};
static
arc
arcs_51_0
[
1
]
=
{
{
14
,
1
},
};
static
arc
arcs_51_1
[
2
]
=
{
{
21
,
2
},
{
0
,
1
},
};
static
arc
arcs_50_0
[
1
]
=
{
static
arc
arcs_51_2
[
1
]
=
{
{
0
,
2
},
};
static
state
states_51
[
3
]
=
{
{
1
,
arcs_51_0
},
{
2
,
arcs_51_1
},
{
1
,
arcs_51_2
},
};
static
arc
arcs_52_0
[
1
]
=
{
{
57
,
1
},
};
static
arc
arcs_5
0
_1
[
2
]
=
{
static
arc
arcs_5
2
_1
[
2
]
=
{
{
22
,
2
},
{
0
,
1
},
};
static
arc
arcs_5
0
_2
[
2
]
=
{
static
arc
arcs_5
2
_2
[
2
]
=
{
{
57
,
1
},
{
0
,
2
},
};
static
state
states_5
0
[
3
]
=
{
{
1
,
arcs_5
0
_0
},
{
2
,
arcs_5
0
_1
},
{
2
,
arcs_5
0
_2
},
static
state
states_5
2
[
3
]
=
{
{
1
,
arcs_5
2
_0
},
{
2
,
arcs_5
2
_1
},
{
2
,
arcs_5
2
_2
},
};
static
arc
arcs_5
1
_0
[
1
]
=
{
static
arc
arcs_5
3
_0
[
1
]
=
{
{
21
,
1
},
};
static
arc
arcs_5
1
_1
[
2
]
=
{
static
arc
arcs_5
3
_1
[
2
]
=
{
{
22
,
2
},
{
0
,
1
},
};
static
arc
arcs_5
1
_2
[
2
]
=
{
static
arc
arcs_5
3
_2
[
2
]
=
{
{
21
,
1
},
{
0
,
2
},
};
static
state
states_5
1
[
3
]
=
{
{
1
,
arcs_5
1
_0
},
{
2
,
arcs_5
1
_1
},
{
2
,
arcs_5
1
_2
},
static
state
states_5
3
[
3
]
=
{
{
1
,
arcs_5
3
_0
},
{
2
,
arcs_5
3
_1
},
{
2
,
arcs_5
3
_2
},
};
static
arc
arcs_5
2
_0
[
1
]
=
{
static
arc
arcs_5
4
_0
[
1
]
=
{
{
21
,
1
},
};
static
arc
arcs_5
2
_1
[
1
]
=
{
static
arc
arcs_5
4
_1
[
1
]
=
{
{
14
,
2
},
};
static
arc
arcs_5
2
_2
[
1
]
=
{
static
arc
arcs_5
4
_2
[
1
]
=
{
{
21
,
3
},
};
static
arc
arcs_5
2
_3
[
2
]
=
{
static
arc
arcs_5
4
_3
[
2
]
=
{
{
22
,
4
},
{
0
,
3
},
};
static
arc
arcs_5
2
_4
[
2
]
=
{
static
arc
arcs_5
4
_4
[
2
]
=
{
{
21
,
1
},
{
0
,
4
},
};
static
state
states_5
2
[
5
]
=
{
{
1
,
arcs_5
2
_0
},
{
1
,
arcs_5
2
_1
},
{
1
,
arcs_5
2
_2
},
{
2
,
arcs_5
2
_3
},
{
2
,
arcs_5
2
_4
},
static
state
states_5
4
[
5
]
=
{
{
1
,
arcs_5
4
_0
},
{
1
,
arcs_5
4
_1
},
{
1
,
arcs_5
4
_2
},
{
2
,
arcs_5
4
_3
},
{
2
,
arcs_5
4
_4
},
};
static
arc
arcs_5
3
_0
[
1
]
=
{
{
12
1
,
1
},
static
arc
arcs_5
5
_0
[
1
]
=
{
{
12
3
,
1
},
};
static
arc
arcs_5
3
_1
[
1
]
=
{
static
arc
arcs_5
5
_1
[
1
]
=
{
{
12
,
2
},
};
static
arc
arcs_5
3
_2
[
2
]
=
{
static
arc
arcs_5
5
_2
[
2
]
=
{
{
16
,
3
},
{
14
,
4
},
};
static
arc
arcs_5
3
_3
[
1
]
=
{
static
arc
arcs_5
5
_3
[
1
]
=
{
{
9
,
5
},
};
static
arc
arcs_5
3
_4
[
1
]
=
{
static
arc
arcs_5
5
_4
[
1
]
=
{
{
15
,
6
},
};
static
arc
arcs_5
3
_5
[
1
]
=
{
static
arc
arcs_5
5
_5
[
1
]
=
{
{
18
,
7
},
};
static
arc
arcs_5
3
_6
[
1
]
=
{
static
arc
arcs_5
5
_6
[
1
]
=
{
{
0
,
6
},
};
static
arc
arcs_5
3
_7
[
1
]
=
{
static
arc
arcs_5
5
_7
[
1
]
=
{
{
14
,
4
},
};
static
state
states_5
3
[
8
]
=
{
{
1
,
arcs_5
3
_0
},
{
1
,
arcs_5
3
_1
},
{
2
,
arcs_5
3
_2
},
{
1
,
arcs_5
3
_3
},
{
1
,
arcs_5
3
_4
},
{
1
,
arcs_5
3
_5
},
{
1
,
arcs_5
3
_6
},
{
1
,
arcs_5
3
_7
},
static
state
states_5
5
[
8
]
=
{
{
1
,
arcs_5
5
_0
},
{
1
,
arcs_5
5
_1
},
{
2
,
arcs_5
5
_2
},
{
1
,
arcs_5
5
_3
},
{
1
,
arcs_5
5
_4
},
{
1
,
arcs_5
5
_5
},
{
1
,
arcs_5
5
_6
},
{
1
,
arcs_5
5
_7
},
};
static
arc
arcs_5
4
_0
[
1
]
=
{
{
12
2
,
1
},
static
arc
arcs_5
6
_0
[
1
]
=
{
{
12
4
,
1
},
};
static
arc
arcs_5
4
_1
[
2
]
=
{
static
arc
arcs_5
6
_1
[
2
]
=
{
{
22
,
2
},
{
0
,
1
},
};
static
arc
arcs_5
4
_2
[
2
]
=
{
{
12
2
,
1
},
static
arc
arcs_5
6
_2
[
2
]
=
{
{
12
4
,
1
},
{
0
,
2
},
};
static
state
states_5
4
[
3
]
=
{
{
1
,
arcs_5
4
_0
},
{
2
,
arcs_5
4
_1
},
{
2
,
arcs_5
4
_2
},
static
state
states_5
6
[
3
]
=
{
{
1
,
arcs_5
6
_0
},
{
2
,
arcs_5
6
_1
},
{
2
,
arcs_5
6
_2
},
};
static
arc
arcs_5
5
_0
[
1
]
=
{
static
arc
arcs_5
7
_0
[
1
]
=
{
{
21
,
1
},
};
static
arc
arcs_5
5
_1
[
2
]
=
{
static
arc
arcs_5
7
_1
[
2
]
=
{
{
20
,
2
},
{
0
,
1
},
};
static
arc
arcs_5
5
_2
[
1
]
=
{
static
arc
arcs_5
7
_2
[
1
]
=
{
{
21
,
3
},
};
static
arc
arcs_5
5
_3
[
1
]
=
{
static
arc
arcs_5
7
_3
[
1
]
=
{
{
0
,
3
},
};
static
state
states_5
5
[
4
]
=
{
{
1
,
arcs_5
5
_0
},
{
2
,
arcs_5
5
_1
},
{
1
,
arcs_5
5
_2
},
{
1
,
arcs_5
5
_3
},
static
state
states_5
7
[
4
]
=
{
{
1
,
arcs_5
7
_0
},
{
2
,
arcs_5
7
_1
},
{
1
,
arcs_5
7
_2
},
{
1
,
arcs_5
7
_3
},
};
static
dfa
dfas
[
5
6
]
=
{
static
dfa
dfas
[
5
8
]
=
{
{
256
,
"single_input"
,
0
,
3
,
states_0
,
"
\004\030\001\000\140\341\153\001\071\000\001\000\140\104\171\0
02
"
},
"
\004\030\001\000\140\341\153\001\071\000\001\000\140\104\171\0
10
"
},
{
257
,
"file_input"
,
0
,
2
,
states_1
,
"
\204\030\001\000\140\341\153\001\071\000\001\000\140\104\171\0
02
"
},
"
\204\030\001\000\140\341\153\001\071\000\001\000\140\104\171\0
10
"
},
{
258
,
"eval_input"
,
0
,
3
,
states_2
,
"
\000\020\001\000\000\000\000\000\000\000\001\000\140\104\171\000
"
},
{
259
,
"funcdef"
,
0
,
6
,
states_3
,
...
...
@@ -1207,7 +1242,7 @@ static dfa dfas[56] = {
{
263
,
"fplist"
,
0
,
3
,
states_7
,
"
\000\020\001\000\000\000\000\000\000\000\000\000\000\000\000\000
"
},
{
264
,
"stmt"
,
0
,
2
,
states_8
,
"
\000\030\001\000\140\341\153\001\071\000\001\000\140\104\171\0
02
"
},
"
\000\030\001\000\140\341\153\001\071\000\001\000\140\104\171\0
10
"
},
{
265
,
"simple_stmt"
,
0
,
4
,
states_9
,
"
\000\020\001\000\140\341\153\001\000\000\001\000\140\104\171\000
"
},
{
266
,
"small_stmt"
,
0
,
2
,
states_10
,
...
...
@@ -1243,7 +1278,7 @@ static dfa dfas[56] = {
{
281
,
"exec_stmt"
,
0
,
7
,
states_25
,
"
\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000
"
},
{
282
,
"compound_stmt"
,
0
,
2
,
states_26
,
"
\000\010\000\000\000\000\000\000\071\000\000\000\000\000\000\0
02
"
},
"
\000\010\000\000\000\000\000\000\071\000\000\000\000\000\000\0
10
"
},
{
283
,
"if_stmt"
,
0
,
8
,
states_27
,
"
\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000
"
},
{
284
,
"while_stmt"
,
0
,
8
,
states_28
,
...
...
@@ -1288,22 +1323,26 @@ static dfa dfas[56] = {
"
\000\000\000\000\000\000\000\000\000\000\000\000\000\000\100\000
"
},
{
304
,
"trailer"
,
0
,
7
,
states_48
,
"
\000\000\001\000\000\000\020\000\000\000\000\000\000\100\000\000
"
},
{
305
,
"subscript"
,
0
,
6
,
states_49
,
"
\000\120\001\000\000\000\000\000\000\000\001\000\140\104\171\000
"
},
{
306
,
"exprlist"
,
0
,
3
,
states_50
,
{
305
,
"subscriptlist"
,
0
,
3
,
states_49
,
"
\000\120\001\000\000\000\020\000\000\000\001\000\140\104\171\000
"
},
{
306
,
"subscript"
,
0
,
7
,
states_50
,
"
\000\120\001\000\000\000\020\000\000\000\001\000\140\104\171\000
"
},
{
307
,
"sliceop"
,
0
,
3
,
states_51
,
"
\000\100\000\000\000\000\000\000\000\000\000\000\000\000\000\000
"
},
{
308
,
"exprlist"
,
0
,
3
,
states_52
,
"
\000\020\001\000\000\000\000\000\000\000\000\000\140\104\071\000
"
},
{
30
7
,
"testlist"
,
0
,
3
,
states_51
,
{
30
9
,
"testlist"
,
0
,
3
,
states_53
,
"
\000\020\001\000\000\000\000\000\000\000\001\000\140\104\171\000
"
},
{
3
08
,
"dictmaker"
,
0
,
5
,
states_52
,
{
3
10
,
"dictmaker"
,
0
,
5
,
states_54
,
"
\000\020\001\000\000\000\000\000\000\000\001\000\140\104\171\000
"
},
{
3
09
,
"classdef"
,
0
,
8
,
states_53
,
"
\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\0
02
"
},
{
31
0
,
"arglist"
,
0
,
3
,
states_54
,
{
3
11
,
"classdef"
,
0
,
8
,
states_55
,
"
\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\0
10
"
},
{
31
2
,
"arglist"
,
0
,
3
,
states_56
,
"
\000\020\001\000\000\000\000\000\000\000\001\000\140\104\171\000
"
},
{
31
1
,
"argument"
,
0
,
4
,
states_55
,
{
31
3
,
"argument"
,
0
,
4
,
states_57
,
"
\000\020\001\000\000\000\000\000\000\000\001\000\140\104\171\000
"
},
};
static
label
labels
[
12
3
]
=
{
static
label
labels
[
12
5
]
=
{
{
0
,
"EMPTY"
},
{
256
,
0
},
{
4
,
0
},
...
...
@@ -1313,7 +1352,7 @@ static label labels[123] = {
{
264
,
0
},
{
0
,
0
},
{
258
,
0
},
{
30
7
,
0
},
{
30
9
,
0
},
{
259
,
0
},
{
1
,
"def"
},
{
1
,
0
},
...
...
@@ -1343,7 +1382,7 @@ static label labels[123] = {
{
281
,
0
},
{
1
,
"print"
},
{
1
,
"del"
},
{
30
6
,
0
},
{
30
8
,
0
},
{
1
,
"pass"
},
{
272
,
0
},
{
273
,
0
},
...
...
@@ -1367,7 +1406,7 @@ static label labels[123] = {
{
284
,
0
},
{
285
,
0
},
{
286
,
0
},
{
3
09
,
0
},
{
3
11
,
0
},
{
1
,
"if"
},
{
1
,
"elif"
},
{
1
,
"else"
},
...
...
@@ -1417,20 +1456,22 @@ static label labels[123] = {
{
9
,
0
},
{
10
,
0
},
{
26
,
0
},
{
3
08
,
0
},
{
3
10
,
0
},
{
27
,
0
},
{
25
,
0
},
{
2
,
0
},
{
3
,
0
},
{
1
,
"lambda"
},
{
31
0
,
0
},
{
31
2
,
0
},
{
305
,
0
},
{
306
,
0
},
{
307
,
0
},
{
1
,
"class"
},
{
31
1
,
0
},
{
31
3
,
0
},
};
grammar
gram
=
{
5
6
,
5
8
,
dfas
,
{
12
3
,
labels
},
{
12
5
,
labels
},
256
};
Python/import.c
View file @
8861b744
...
...
@@ -55,7 +55,7 @@ extern long getmtime(); /* In getmtime.c */
Apple MPW compiler swaps their values, botching string constants */
/* XXX Perhaps the magic number should be frozen and a version field
added to the .pyc file header? */
#define MAGIC (
1895
| ((long)'\r'<<16) | ((long)'\n'<<24))
#define MAGIC (
5892
| ((long)'\r'<<16) | ((long)'\n'<<24))
object
*
import_modules
;
/* This becomes sys.modules */
...
...
Python/marshal.c
View file @
8861b744
...
...
@@ -37,6 +37,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define TYPE_NULL '0'
#define TYPE_NONE 'N'
#define TYPE_ELLIPSES '.'
#define TYPE_INT 'i'
#define TYPE_FLOAT 'f'
#define TYPE_COMPLEX 'x'
...
...
@@ -129,6 +130,8 @@ w_object(v, p)
w_byte
(
TYPE_NULL
,
p
);
else
if
(
v
==
None
)
w_byte
(
TYPE_NONE
,
p
);
else
if
(
v
==
Py_Ellipses
)
w_byte
(
TYPE_ELLIPSES
,
p
);
else
if
(
is_intobject
(
v
))
{
w_byte
(
TYPE_INT
,
p
);
w_long
(
getintvalue
(
v
),
p
);
...
...
@@ -322,6 +325,10 @@ r_object(p)
INCREF
(
None
);
return
None
;
case
TYPE_ELLIPSES
:
INCREF
(
Py_Ellipses
);
return
Py_Ellipses
;
case
TYPE_INT
:
return
newintobject
(
r_long
(
p
));
...
...
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