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
92f39720
Kaydet (Commit)
92f39720
authored
Eyl 01, 2000
tarafından
Jeremy Hylton
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
patch by Neil Schemenauer to improve (fix?) line number generation
üst
3620857d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
34 deletions
+64
-34
pyassem.py
Lib/compiler/pyassem.py
+26
-15
pycodegen.py
Lib/compiler/pycodegen.py
+6
-2
pyassem.py
Tools/compiler/compiler/pyassem.py
+26
-15
pycodegen.py
Tools/compiler/compiler/pycodegen.py
+6
-2
No files found.
Lib/compiler/pyassem.py
Dosyayı görüntüle @
92f39720
...
@@ -419,21 +419,32 @@ class LineAddrTable:
...
@@ -419,21 +419,32 @@ class LineAddrTable:
# compute deltas
# compute deltas
addr
=
self
.
codeOffset
-
self
.
lastoff
addr
=
self
.
codeOffset
-
self
.
lastoff
line
=
lineno
-
self
.
lastline
line
=
lineno
-
self
.
lastline
while
addr
>
0
or
line
>
0
:
# Python assumes that lineno always increases with
# write the values in 1-byte chunks that sum
# increasing bytecode address (lnotab is unsigned char).
# to desired value
# Depending on when SET_LINENO instructions are emitted
trunc_addr
=
addr
# this is not always true. Consider the code:
trunc_line
=
line
# a = (1,
if
trunc_addr
>
255
:
# b)
trunc_addr
=
255
# In the bytecode stream, the assignment to "a" occurs
if
trunc_line
>
255
:
# after the loading of "b". This works with the C Python
trunc_line
=
255
# compiler because it only generates a SET_LINENO instruction
self
.
lnotab
.
append
(
trunc_addr
)
# for the assignment.
self
.
lnotab
.
append
(
trunc_line
)
if
line
>
0
:
addr
=
addr
-
trunc_addr
while
addr
>
0
or
line
>
0
:
line
=
line
-
trunc_line
# write the values in 1-byte chunks that sum
self
.
lastline
=
lineno
# to desired value
self
.
lastoff
=
self
.
codeOffset
trunc_addr
=
addr
trunc_line
=
line
if
trunc_addr
>
255
:
trunc_addr
=
255
if
trunc_line
>
255
:
trunc_line
=
255
self
.
lnotab
.
append
(
trunc_addr
)
self
.
lnotab
.
append
(
trunc_line
)
addr
=
addr
-
trunc_addr
line
=
line
-
trunc_line
self
.
lastline
=
lineno
self
.
lastoff
=
self
.
codeOffset
def
getCode
(
self
):
def
getCode
(
self
):
return
string
.
join
(
self
.
code
,
''
)
return
string
.
join
(
self
.
code
,
''
)
...
...
Lib/compiler/pycodegen.py
Dosyayı görüntüle @
92f39720
...
@@ -70,6 +70,7 @@ class CodeGenerator:
...
@@ -70,6 +70,7 @@ class CodeGenerator:
self
.
loops
=
misc
.
Stack
()
self
.
loops
=
misc
.
Stack
()
self
.
curStack
=
0
self
.
curStack
=
0
self
.
maxStack
=
0
self
.
maxStack
=
0
self
.
last_lineno
=
None
self
.
_setupGraphDelegation
()
self
.
_setupGraphDelegation
()
def
_setupGraphDelegation
(
self
):
def
_setupGraphDelegation
(
self
):
...
@@ -107,7 +108,8 @@ class CodeGenerator:
...
@@ -107,7 +108,8 @@ class CodeGenerator:
self
.
emit
(
prefix
+
'_GLOBAL'
,
name
)
self
.
emit
(
prefix
+
'_GLOBAL'
,
name
)
def
set_lineno
(
self
,
node
):
def
set_lineno
(
self
,
node
):
"""Emit SET_LINENO if node has lineno attribute
"""Emit SET_LINENO if node has lineno attribute and it is
different than the last lineno emitted.
Returns true if SET_LINENO was emitted.
Returns true if SET_LINENO was emitted.
...
@@ -117,8 +119,9 @@ class CodeGenerator:
...
@@ -117,8 +119,9 @@ class CodeGenerator:
then, this method works around missing line numbers.
then, this method works around missing line numbers.
"""
"""
lineno
=
getattr
(
node
,
'lineno'
,
None
)
lineno
=
getattr
(
node
,
'lineno'
,
None
)
if
lineno
is
not
None
:
if
lineno
is
not
None
and
lineno
!=
self
.
last_lineno
:
self
.
emit
(
'SET_LINENO'
,
lineno
)
self
.
emit
(
'SET_LINENO'
,
lineno
)
self
.
last_lineno
=
lineno
return
1
return
1
return
0
return
0
...
@@ -414,6 +417,7 @@ class CodeGenerator:
...
@@ -414,6 +417,7 @@ class CodeGenerator:
pass
pass
def
visitName
(
self
,
node
):
def
visitName
(
self
,
node
):
self
.
set_lineno
(
node
)
self
.
loadName
(
node
.
name
)
self
.
loadName
(
node
.
name
)
def
visitPass
(
self
,
node
):
def
visitPass
(
self
,
node
):
...
...
Tools/compiler/compiler/pyassem.py
Dosyayı görüntüle @
92f39720
...
@@ -419,21 +419,32 @@ class LineAddrTable:
...
@@ -419,21 +419,32 @@ class LineAddrTable:
# compute deltas
# compute deltas
addr
=
self
.
codeOffset
-
self
.
lastoff
addr
=
self
.
codeOffset
-
self
.
lastoff
line
=
lineno
-
self
.
lastline
line
=
lineno
-
self
.
lastline
while
addr
>
0
or
line
>
0
:
# Python assumes that lineno always increases with
# write the values in 1-byte chunks that sum
# increasing bytecode address (lnotab is unsigned char).
# to desired value
# Depending on when SET_LINENO instructions are emitted
trunc_addr
=
addr
# this is not always true. Consider the code:
trunc_line
=
line
# a = (1,
if
trunc_addr
>
255
:
# b)
trunc_addr
=
255
# In the bytecode stream, the assignment to "a" occurs
if
trunc_line
>
255
:
# after the loading of "b". This works with the C Python
trunc_line
=
255
# compiler because it only generates a SET_LINENO instruction
self
.
lnotab
.
append
(
trunc_addr
)
# for the assignment.
self
.
lnotab
.
append
(
trunc_line
)
if
line
>
0
:
addr
=
addr
-
trunc_addr
while
addr
>
0
or
line
>
0
:
line
=
line
-
trunc_line
# write the values in 1-byte chunks that sum
self
.
lastline
=
lineno
# to desired value
self
.
lastoff
=
self
.
codeOffset
trunc_addr
=
addr
trunc_line
=
line
if
trunc_addr
>
255
:
trunc_addr
=
255
if
trunc_line
>
255
:
trunc_line
=
255
self
.
lnotab
.
append
(
trunc_addr
)
self
.
lnotab
.
append
(
trunc_line
)
addr
=
addr
-
trunc_addr
line
=
line
-
trunc_line
self
.
lastline
=
lineno
self
.
lastoff
=
self
.
codeOffset
def
getCode
(
self
):
def
getCode
(
self
):
return
string
.
join
(
self
.
code
,
''
)
return
string
.
join
(
self
.
code
,
''
)
...
...
Tools/compiler/compiler/pycodegen.py
Dosyayı görüntüle @
92f39720
...
@@ -70,6 +70,7 @@ class CodeGenerator:
...
@@ -70,6 +70,7 @@ class CodeGenerator:
self
.
loops
=
misc
.
Stack
()
self
.
loops
=
misc
.
Stack
()
self
.
curStack
=
0
self
.
curStack
=
0
self
.
maxStack
=
0
self
.
maxStack
=
0
self
.
last_lineno
=
None
self
.
_setupGraphDelegation
()
self
.
_setupGraphDelegation
()
def
_setupGraphDelegation
(
self
):
def
_setupGraphDelegation
(
self
):
...
@@ -107,7 +108,8 @@ class CodeGenerator:
...
@@ -107,7 +108,8 @@ class CodeGenerator:
self
.
emit
(
prefix
+
'_GLOBAL'
,
name
)
self
.
emit
(
prefix
+
'_GLOBAL'
,
name
)
def
set_lineno
(
self
,
node
):
def
set_lineno
(
self
,
node
):
"""Emit SET_LINENO if node has lineno attribute
"""Emit SET_LINENO if node has lineno attribute and it is
different than the last lineno emitted.
Returns true if SET_LINENO was emitted.
Returns true if SET_LINENO was emitted.
...
@@ -117,8 +119,9 @@ class CodeGenerator:
...
@@ -117,8 +119,9 @@ class CodeGenerator:
then, this method works around missing line numbers.
then, this method works around missing line numbers.
"""
"""
lineno
=
getattr
(
node
,
'lineno'
,
None
)
lineno
=
getattr
(
node
,
'lineno'
,
None
)
if
lineno
is
not
None
:
if
lineno
is
not
None
and
lineno
!=
self
.
last_lineno
:
self
.
emit
(
'SET_LINENO'
,
lineno
)
self
.
emit
(
'SET_LINENO'
,
lineno
)
self
.
last_lineno
=
lineno
return
1
return
1
return
0
return
0
...
@@ -414,6 +417,7 @@ class CodeGenerator:
...
@@ -414,6 +417,7 @@ class CodeGenerator:
pass
pass
def
visitName
(
self
,
node
):
def
visitName
(
self
,
node
):
self
.
set_lineno
(
node
)
self
.
loadName
(
node
.
name
)
self
.
loadName
(
node
.
name
)
def
visitPass
(
self
,
node
):
def
visitPass
(
self
,
node
):
...
...
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