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
9c8f7eaf
Kaydet (Commit)
9c8f7eaf
authored
Eki 28, 2003
tarafından
Armin Rigo
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed dis.disassemble_string().
Added dis.findlinestarts(). SF bug 811294
üst
3be6d5d3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
28 deletions
+24
-28
dis.py
Lib/dis.py
+24
-28
No files found.
Lib/dis.py
Dosyayı görüntüle @
9c8f7eaf
...
...
@@ -60,21 +60,8 @@ def distb(tb=None):
def
disassemble
(
co
,
lasti
=-
1
):
"""Disassemble a code object."""
code
=
co
.
co_code
byte_increments
=
[
ord
(
c
)
for
c
in
co
.
co_lnotab
[
0
::
2
]]
line_increments
=
[
ord
(
c
)
for
c
in
co
.
co_lnotab
[
1
::
2
]]
table_length
=
len
(
byte_increments
)
# == len(line_increments)
lineno
=
co
.
co_firstlineno
table_index
=
0
while
(
table_index
<
table_length
and
byte_increments
[
table_index
]
==
0
):
lineno
+=
line_increments
[
table_index
]
table_index
+=
1
addr
=
0
line_incr
=
0
labels
=
findlabels
(
code
)
linestarts
=
dict
(
findlinestarts
(
co
))
n
=
len
(
code
)
i
=
0
extended_arg
=
0
...
...
@@ -82,20 +69,10 @@ def disassemble(co, lasti=-1):
while
i
<
n
:
c
=
code
[
i
]
op
=
ord
(
c
)
if
i
>=
addr
:
lineno
+=
line_incr
while
table_index
<
table_length
:
addr
+=
byte_increments
[
table_index
]
line_incr
=
line_increments
[
table_index
]
table_index
+=
1
if
line_incr
:
break
else
:
addr
=
sys
.
maxint
if
i
in
linestarts
:
if
i
>
0
:
print
print
"
%3
d"
%
lineno
,
print
"
%3
d"
%
linestarts
[
i
]
,
else
:
print
' '
,
...
...
@@ -137,8 +114,6 @@ def disassemble_string(code, lasti=-1, varnames=None, names=None,
while
i
<
n
:
c
=
code
[
i
]
op
=
ord
(
c
)
if
op
==
opmap
[
'SET_LINENO'
]
and
i
>
0
:
print
# Extra blank line
if
i
==
lasti
:
print
'-->'
,
else
:
print
' '
,
if
i
in
labels
:
print
'>>'
,
...
...
@@ -199,6 +174,27 @@ def findlabels(code):
labels
.
append
(
label
)
return
labels
def
findlinestarts
(
code
):
"""Find the offsets in a byte code which are start of lines in the source.
Generate pairs (offset, lineno) as described in Python/compile.c.
"""
byte_increments
=
[
ord
(
c
)
for
c
in
code
.
co_lnotab
[
0
::
2
]]
line_increments
=
[
ord
(
c
)
for
c
in
code
.
co_lnotab
[
1
::
2
]]
lastlineno
=
None
lineno
=
code
.
co_firstlineno
addr
=
0
for
byte_incr
,
line_incr
in
zip
(
byte_increments
,
line_increments
):
if
byte_incr
:
if
lineno
!=
lastlineno
:
yield
(
addr
,
lineno
)
lastlineno
=
lineno
addr
+=
byte_incr
lineno
+=
line_incr
if
lineno
!=
lastlineno
:
yield
(
addr
,
lineno
)
def
_test
():
"""Simple test program to disassemble a file."""
...
...
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