Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
0cc56e5c
Kaydet (Commit)
0cc56e5c
authored
Nis 13, 2006
tarafından
Martin v. Löwis
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Introduce asdl_int_seq, to hold cmpop_ty.
üst
0f1955da
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
44 additions
and
23 deletions
+44
-23
Python-ast.h
Include/Python-ast.h
+2
-2
asdl.h
Include/asdl.h
+6
-0
asdl_c.py
Parser/asdl_c.py
+9
-3
Python-ast.c
Python/Python-ast.c
+3
-3
asdl.c
Python/asdl.c
+18
-1
ast.c
Python/ast.c
+4
-4
compile.c
Python/compile.c
+2
-10
No files found.
Include/Python-ast.h
Dosyayı görüntüle @
0cc56e5c
...
...
@@ -240,7 +240,7 @@ struct _expr {
struct
{
expr_ty
left
;
asdl_seq
*
ops
;
asdl_
int_
seq
*
ops
;
asdl_seq
*
comparators
;
}
Compare
;
...
...
@@ -409,7 +409,7 @@ expr_ty ListComp(expr_ty elt, asdl_seq * generators, int lineno, int
expr_ty
GeneratorExp
(
expr_ty
elt
,
asdl_seq
*
generators
,
int
lineno
,
int
col_offset
,
PyArena
*
arena
);
expr_ty
Yield
(
expr_ty
value
,
int
lineno
,
int
col_offset
,
PyArena
*
arena
);
expr_ty
Compare
(
expr_ty
left
,
asdl_seq
*
ops
,
asdl_seq
*
comparators
,
int
expr_ty
Compare
(
expr_ty
left
,
asdl_
int_
seq
*
ops
,
asdl_seq
*
comparators
,
int
lineno
,
int
col_offset
,
PyArena
*
arena
);
expr_ty
Call
(
expr_ty
func
,
asdl_seq
*
args
,
asdl_seq
*
keywords
,
expr_ty
starargs
,
expr_ty
kwargs
,
int
lineno
,
int
col_offset
,
PyArena
...
...
Include/asdl.h
Dosyayı görüntüle @
0cc56e5c
...
...
@@ -22,7 +22,13 @@ typedef struct {
void
*
elements
[
1
];
}
asdl_seq
;
typedef
struct
{
int
size
;
int
elements
[
1
];
}
asdl_int_seq
;
asdl_seq
*
asdl_seq_new
(
int
size
,
PyArena
*
arena
);
asdl_int_seq
*
asdl_int_seq_new
(
int
size
,
PyArena
*
arena
);
#define asdl_seq_GET(S, I) (S)->elements[(I)]
#define asdl_seq_LEN(S) ((S) == NULL ? 0 : (S)->size)
...
...
Parser/asdl_c.py
Dosyayı görüntüle @
0cc56e5c
...
...
@@ -188,7 +188,10 @@ class StructVisitor(EmitVisitor):
ctype
=
get_c_type
(
field
.
type
)
name
=
field
.
name
if
field
.
seq
:
self
.
emit
(
"asdl_seq *
%(name)
s;"
%
locals
(),
depth
)
if
field
.
type
.
value
in
(
'cmpop'
,):
self
.
emit
(
"asdl_int_seq *
%(name)
s;"
%
locals
(),
depth
)
else
:
self
.
emit
(
"asdl_seq *
%(name)
s;"
%
locals
(),
depth
)
else
:
self
.
emit
(
"
%(ctype)
s
%(name)
s;"
%
locals
(),
depth
)
...
...
@@ -234,7 +237,10 @@ class PrototypeVisitor(EmitVisitor):
name
=
f
.
name
# XXX should extend get_c_type() to handle this
if
f
.
seq
:
ctype
=
"asdl_seq *"
if
f
.
type
.
value
in
(
'cmpop'
,):
ctype
=
"asdl_int_seq *"
else
:
ctype
=
"asdl_seq *"
else
:
ctype
=
get_c_type
(
f
.
type
)
args
.
append
((
ctype
,
name
,
f
.
opt
or
f
.
seq
))
...
...
@@ -681,7 +687,7 @@ class ObjVisitor(PickleVisitor):
self
.
emit
(
"if (!value) goto failed;"
,
depth
+
1
)
self
.
emit
(
"for(i = 0; i < n; i++)"
,
depth
+
1
)
# This cannot fail, so no need for error handling
self
.
emit
(
"PyList_SET_ITEM(value, i, ast2obj_cmpop((cmpop_ty)
(int)
asdl_seq_GET(
%
s, i)));"
%
value
,
self
.
emit
(
"PyList_SET_ITEM(value, i, ast2obj_cmpop((cmpop_ty)asdl_seq_GET(
%
s, i)));"
%
value
,
depth
+
2
,
reflow
=
False
)
self
.
emit
(
"}"
,
depth
)
else
:
...
...
Python/Python-ast.c
Dosyayı görüntüle @
0cc56e5c
...
...
@@ -1503,8 +1503,8 @@ Yield(expr_ty value, int lineno, int col_offset, PyArena *arena)
}
expr_ty
Compare
(
expr_ty
left
,
asdl_
seq
*
ops
,
asdl_seq
*
comparators
,
int
lineno
,
int
col_offset
,
PyArena
*
arena
)
Compare
(
expr_ty
left
,
asdl_
int_seq
*
ops
,
asdl_seq
*
comparators
,
int
lineno
,
int
col_offset
,
PyArena
*
arena
)
{
expr_ty
p
;
if
(
!
left
)
{
...
...
@@ -2503,7 +2503,7 @@ ast2obj_expr(void* _o)
value
=
PyList_New
(
n
);
if
(
!
value
)
goto
failed
;
for
(
i
=
0
;
i
<
n
;
i
++
)
PyList_SET_ITEM
(
value
,
i
,
ast2obj_cmpop
((
cmpop_ty
)
(
int
)
asdl_seq_GET
(
o
->
v
.
Compare
.
ops
,
i
)));
PyList_SET_ITEM
(
value
,
i
,
ast2obj_cmpop
((
cmpop_ty
)
asdl_seq_GET
(
o
->
v
.
Compare
.
ops
,
i
)));
}
if
(
!
value
)
goto
failed
;
if
(
PyObject_SetAttrString
(
result
,
"ops"
,
value
)
==
-
1
)
...
...
Python/asdl.c
Dosyayı görüntüle @
0cc56e5c
...
...
@@ -8,7 +8,24 @@ asdl_seq_new(int size, PyArena *arena)
size_t
n
=
sizeof
(
asdl_seq
)
+
(
size
?
(
sizeof
(
void
*
)
*
(
size
-
1
))
:
0
);
seq
=
(
asdl_seq
*
)
PyArena_Malloc
(
arena
,
n
);
seq
=
(
asdl_seq
*
)
PyArena_Malloc
(
arena
,
n
);
if
(
!
seq
)
{
PyErr_NoMemory
();
return
NULL
;
}
memset
(
seq
,
0
,
n
);
seq
->
size
=
size
;
return
seq
;
}
asdl_int_seq
*
asdl_int_seq_new
(
int
size
,
PyArena
*
arena
)
{
asdl_seq
*
seq
=
NULL
;
size_t
n
=
sizeof
(
asdl_seq
)
+
(
size
?
(
sizeof
(
int
)
*
(
size
-
1
))
:
0
);
seq
=
(
asdl_seq
*
)
PyArena_Malloc
(
arena
,
n
);
if
(
!
seq
)
{
PyErr_NoMemory
();
return
NULL
;
...
...
Python/ast.c
Dosyayı görüntüle @
0cc56e5c
...
...
@@ -1600,8 +1600,9 @@ ast_for_expr(struct compiling *c, const node *n)
}
else
{
expr_ty
expression
;
asdl_seq
*
ops
,
*
cmps
;
ops
=
asdl_seq_new
(
NCH
(
n
)
/
2
,
c
->
c_arena
);
asdl_int_seq
*
ops
;
asdl_seq
*
cmps
;
ops
=
asdl_int_seq_new
(
NCH
(
n
)
/
2
,
c
->
c_arena
);
if
(
!
ops
)
return
NULL
;
cmps
=
asdl_seq_new
(
NCH
(
n
)
/
2
,
c
->
c_arena
);
...
...
@@ -1609,7 +1610,6 @@ ast_for_expr(struct compiling *c, const node *n)
return
NULL
;
}
for
(
i
=
1
;
i
<
NCH
(
n
);
i
+=
2
)
{
/* XXX cmpop_ty is just an enum */
cmpop_ty
newoperator
;
newoperator
=
ast_for_comp_op
(
CHILD
(
n
,
i
));
...
...
@@ -1622,7 +1622,7 @@ ast_for_expr(struct compiling *c, const node *n)
return
NULL
;
}
asdl_seq_SET
(
ops
,
i
/
2
,
(
void
*
)(
Py_uintptr_t
)
newoperator
);
asdl_seq_SET
(
ops
,
i
/
2
,
newoperator
);
asdl_seq_SET
(
cmps
,
i
/
2
,
expression
);
}
expression
=
ast_for_expr
(
c
,
CHILD
(
n
,
0
));
...
...
Python/compile.c
Dosyayı görüntüle @
0cc56e5c
...
...
@@ -3058,17 +3058,11 @@ compiler_compare(struct compiler *c, expr_ty e)
VISIT
(
c
,
expr
,
(
expr_ty
)
asdl_seq_GET
(
e
->
v
.
Compare
.
comparators
,
0
));
}
#ifdef __cplusplus
#define CMPCAST (intptr_t)
#else
#define CMPCAST
#endif
for
(
i
=
1
;
i
<
n
;
i
++
)
{
ADDOP
(
c
,
DUP_TOP
);
ADDOP
(
c
,
ROT_THREE
);
/* XXX We're casting a void* to cmpop_ty in the next stmt. */
ADDOP_I
(
c
,
COMPARE_OP
,
cmpop
((
cmpop_ty
)(
CMPCAST
asdl_seq_GET
(
cmpop
((
cmpop_ty
)(
asdl_seq_GET
(
e
->
v
.
Compare
.
ops
,
i
-
1
))));
ADDOP_JREL
(
c
,
JUMP_IF_FALSE
,
cleanup
);
NEXT_BLOCK
(
c
);
...
...
@@ -3079,9 +3073,7 @@ compiler_compare(struct compiler *c, expr_ty e)
}
VISIT
(
c
,
expr
,
(
expr_ty
)
asdl_seq_GET
(
e
->
v
.
Compare
.
comparators
,
n
-
1
));
ADDOP_I
(
c
,
COMPARE_OP
,
/* XXX We're casting a void* to cmpop_ty in the next stmt. */
cmpop
((
cmpop_ty
)(
CMPCAST
asdl_seq_GET
(
e
->
v
.
Compare
.
ops
,
n
-
1
))));
cmpop
((
cmpop_ty
)(
asdl_seq_GET
(
e
->
v
.
Compare
.
ops
,
n
-
1
))));
if
(
n
>
1
)
{
basicblock
*
end
=
compiler_new_block
(
c
);
if
(
end
==
NULL
)
...
...
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