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
12603c41
Kaydet (Commit)
12603c41
authored
Nis 01, 2006
tarafından
Jeremy Hylton
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Expand comments on line numbers and blocks.
Reorder compiler_set_lineno() call for consistency.
üst
7034f6b7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
6 deletions
+21
-6
compile.c
Python/compile.c
+21
-6
No files found.
Python/compile.c
Dosyayı görüntüle @
12603c41
...
@@ -58,8 +58,9 @@ struct instr {
...
@@ -58,8 +58,9 @@ struct instr {
};
};
typedef
struct
basicblock_
{
typedef
struct
basicblock_
{
/* next block in the list of blocks for a unit (don't confuse with
/* Each basicblock in a compilation unit is linked via b_list in the
* b_next) */
reverse order that the block are allocated. b_list points to the next
block, not to be confused with b_next, which is next by control flow. */
struct
basicblock_
*
b_list
;
struct
basicblock_
*
b_list
;
/* number of instructions used */
/* number of instructions used */
int
b_iused
;
int
b_iused
;
...
@@ -114,7 +115,9 @@ struct compiler_unit {
...
@@ -114,7 +115,9 @@ struct compiler_unit {
PyObject
*
u_private
;
/* for private name mangling */
PyObject
*
u_private
;
/* for private name mangling */
int
u_argcount
;
/* number of arguments for block */
int
u_argcount
;
/* number of arguments for block */
basicblock
*
u_blocks
;
/* pointer to list of blocks */
/* Pointer to the most recently allocated block. By following b_list
members, you can reach all early allocated blocks. */
basicblock
*
u_blocks
;
basicblock
*
u_curblock
;
/* pointer to current block */
basicblock
*
u_curblock
;
/* pointer to current block */
int
u_tmpname
;
/* temporary variables for list comps */
int
u_tmpname
;
/* temporary variables for list comps */
...
@@ -1194,7 +1197,7 @@ compiler_new_block(struct compiler *c)
...
@@ -1194,7 +1197,7 @@ compiler_new_block(struct compiler *c)
return
NULL
;
return
NULL
;
}
}
memset
((
void
*
)
b
,
0
,
sizeof
(
basicblock
));
memset
((
void
*
)
b
,
0
,
sizeof
(
basicblock
));
assert
(
b
->
b_next
==
NULL
);
/* Extend the singly linked list of blocks with new block. */
b
->
b_list
=
u
->
u_blocks
;
b
->
b_list
=
u
->
u_blocks
;
u
->
u_blocks
=
b
;
u
->
u_blocks
=
b
;
return
b
;
return
b
;
...
@@ -1267,6 +1270,13 @@ compiler_next_instr(struct compiler *c, basicblock *b)
...
@@ -1267,6 +1270,13 @@ compiler_next_instr(struct compiler *c, basicblock *b)
return
b
->
b_iused
++
;
return
b
->
b_iused
++
;
}
}
/* Set the i_lineno member of the instruction at offse off if the
line number for the current expression/statement (?) has not
already been set. If it has been set, the call has no effect.
Every time a new node is b
*/
static
void
static
void
compiler_set_lineno
(
struct
compiler
*
c
,
int
off
)
compiler_set_lineno
(
struct
compiler
*
c
,
int
off
)
{
{
...
@@ -1609,7 +1619,6 @@ compiler_addop_j(struct compiler *c, int opcode, basicblock *b, int absolute)
...
@@ -1609,7 +1619,6 @@ compiler_addop_j(struct compiler *c, int opcode, basicblock *b, int absolute)
off
=
compiler_next_instr
(
c
,
c
->
u
->
u_curblock
);
off
=
compiler_next_instr
(
c
,
c
->
u
->
u_curblock
);
if
(
off
<
0
)
if
(
off
<
0
)
return
0
;
return
0
;
compiler_set_lineno
(
c
,
off
);
i
=
&
c
->
u
->
u_curblock
->
b_instr
[
off
];
i
=
&
c
->
u
->
u_curblock
->
b_instr
[
off
];
i
->
i_opcode
=
opcode
;
i
->
i_opcode
=
opcode
;
i
->
i_target
=
b
;
i
->
i_target
=
b
;
...
@@ -1618,6 +1627,7 @@ compiler_addop_j(struct compiler *c, int opcode, basicblock *b, int absolute)
...
@@ -1618,6 +1627,7 @@ compiler_addop_j(struct compiler *c, int opcode, basicblock *b, int absolute)
i
->
i_jabs
=
1
;
i
->
i_jabs
=
1
;
else
else
i
->
i_jrel
=
1
;
i
->
i_jrel
=
1
;
compiler_set_lineno
(
c
,
off
);
return
1
;
return
1
;
}
}
...
@@ -2230,7 +2240,7 @@ compiler_while(struct compiler *c, stmt_ty s)
...
@@ -2230,7 +2240,7 @@ compiler_while(struct compiler *c, stmt_ty s)
ADDOP
(
c
,
POP_BLOCK
);
ADDOP
(
c
,
POP_BLOCK
);
}
}
compiler_pop_fblock
(
c
,
LOOP
,
loop
);
compiler_pop_fblock
(
c
,
LOOP
,
loop
);
if
(
orelse
!=
NULL
)
if
(
orelse
!=
NULL
)
/* what if orelse is just pass? */
VISIT_SEQ
(
c
,
stmt
,
s
->
v
.
While
.
orelse
);
VISIT_SEQ
(
c
,
stmt
,
s
->
v
.
While
.
orelse
);
compiler_use_next_block
(
c
,
end
);
compiler_use_next_block
(
c
,
end
);
...
@@ -2610,8 +2620,10 @@ compiler_visit_stmt(struct compiler *c, stmt_ty s)
...
@@ -2610,8 +2620,10 @@ compiler_visit_stmt(struct compiler *c, stmt_ty s)
{
{
int
i
,
n
;
int
i
,
n
;
/* Always assign a lineno to the next instruction for a stmt. */
c
->
u
->
u_lineno
=
s
->
lineno
;
c
->
u
->
u_lineno
=
s
->
lineno
;
c
->
u
->
u_lineno_set
=
false
;
c
->
u
->
u_lineno_set
=
false
;
switch
(
s
->
kind
)
{
switch
(
s
->
kind
)
{
case
FunctionDef_kind
:
case
FunctionDef_kind
:
return
compiler_function
(
c
,
s
);
return
compiler_function
(
c
,
s
);
...
@@ -3486,6 +3498,9 @@ compiler_visit_expr(struct compiler *c, expr_ty e)
...
@@ -3486,6 +3498,9 @@ compiler_visit_expr(struct compiler *c, expr_ty e)
{
{
int
i
,
n
;
int
i
,
n
;
/* If expr e has a different line number than the last expr/stmt,
set a new line number for the next instruction.
*/
if
(
e
->
lineno
>
c
->
u
->
u_lineno
)
{
if
(
e
->
lineno
>
c
->
u
->
u_lineno
)
{
c
->
u
->
u_lineno
=
e
->
lineno
;
c
->
u
->
u_lineno
=
e
->
lineno
;
c
->
u
->
u_lineno_set
=
false
;
c
->
u
->
u_lineno_set
=
false
;
...
...
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