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
eefaeb78
Commit
eefaeb78
authored
Nov 06, 2000
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move pruneNext method to correct object (doh!)
parent
314e3fb2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
48 deletions
+48
-48
Lib/compiler/pyassem.py
Lib/compiler/pyassem.py
+24
-24
Tools/compiler/compiler/pyassem.py
Tools/compiler/compiler/pyassem.py
+24
-24
No files found.
Lib/compiler/pyassem.py
View file @
eefaeb78
...
...
@@ -120,30 +120,6 @@ class FlowGraph:
l
.
extend
(
b
.
getContainedGraphs
())
return
l
_uncond_transfer
=
(
'RETURN_VALUE'
,
'RAISE_VARARGS'
,
'JUMP_ABSOLUTE'
,
'JUMP_FORWARD'
)
def
pruneNext
(
self
):
"""Remove bogus edge for unconditional transfers
Each block has a next edge that accounts for implicit control
transfers, e.g. from a JUMP_IF_FALSE to the block that will be
executed if the test is true.
These edges must remain for the current assembler code to
work. If they are removed, the dfs_postorder gets things in
weird orders. However, they shouldn't be there for other
purposes, e.g. conversion to SSA form. This method will
remove the next edge when it follows an unconditional control
transfer.
"""
try
:
op
,
arg
=
self
.
insts
[
-
1
]
except
(
IndexError
,
TypeError
):
return
if
op
in
self
.
_uncond_transfer
:
self
.
next
=
[]
def
dfs_postorder
(
b
,
seen
):
"""Depth-first search of tree rooted at b, return in postorder"""
order
=
[]
...
...
@@ -197,6 +173,30 @@ class Block:
self
.
next
.
append
(
block
)
assert
len
(
self
.
next
)
==
1
,
map
(
str
,
self
.
next
)
_uncond_transfer
=
(
'RETURN_VALUE'
,
'RAISE_VARARGS'
,
'JUMP_ABSOLUTE'
,
'JUMP_FORWARD'
)
def
pruneNext
(
self
):
"""Remove bogus edge for unconditional transfers
Each block has a next edge that accounts for implicit control
transfers, e.g. from a JUMP_IF_FALSE to the block that will be
executed if the test is true.
These edges must remain for the current assembler code to
work. If they are removed, the dfs_postorder gets things in
weird orders. However, they shouldn't be there for other
purposes, e.g. conversion to SSA form. This method will
remove the next edge when it follows an unconditional control
transfer.
"""
try
:
op
,
arg
=
self
.
insts
[
-
1
]
except
(
IndexError
,
ValueError
):
return
if
op
in
self
.
_uncond_transfer
:
self
.
next
=
[]
def
get_children
(
self
):
if
self
.
next
and
self
.
next
[
0
]
in
self
.
outEdges
:
self
.
outEdges
.
remove
(
self
.
next
[
0
])
...
...
Tools/compiler/compiler/pyassem.py
View file @
eefaeb78
...
...
@@ -120,30 +120,6 @@ class FlowGraph:
l
.
extend
(
b
.
getContainedGraphs
())
return
l
_uncond_transfer
=
(
'RETURN_VALUE'
,
'RAISE_VARARGS'
,
'JUMP_ABSOLUTE'
,
'JUMP_FORWARD'
)
def
pruneNext
(
self
):
"""Remove bogus edge for unconditional transfers
Each block has a next edge that accounts for implicit control
transfers, e.g. from a JUMP_IF_FALSE to the block that will be
executed if the test is true.
These edges must remain for the current assembler code to
work. If they are removed, the dfs_postorder gets things in
weird orders. However, they shouldn't be there for other
purposes, e.g. conversion to SSA form. This method will
remove the next edge when it follows an unconditional control
transfer.
"""
try
:
op
,
arg
=
self
.
insts
[
-
1
]
except
(
IndexError
,
TypeError
):
return
if
op
in
self
.
_uncond_transfer
:
self
.
next
=
[]
def
dfs_postorder
(
b
,
seen
):
"""Depth-first search of tree rooted at b, return in postorder"""
order
=
[]
...
...
@@ -197,6 +173,30 @@ class Block:
self
.
next
.
append
(
block
)
assert
len
(
self
.
next
)
==
1
,
map
(
str
,
self
.
next
)
_uncond_transfer
=
(
'RETURN_VALUE'
,
'RAISE_VARARGS'
,
'JUMP_ABSOLUTE'
,
'JUMP_FORWARD'
)
def
pruneNext
(
self
):
"""Remove bogus edge for unconditional transfers
Each block has a next edge that accounts for implicit control
transfers, e.g. from a JUMP_IF_FALSE to the block that will be
executed if the test is true.
These edges must remain for the current assembler code to
work. If they are removed, the dfs_postorder gets things in
weird orders. However, they shouldn't be there for other
purposes, e.g. conversion to SSA form. This method will
remove the next edge when it follows an unconditional control
transfer.
"""
try
:
op
,
arg
=
self
.
insts
[
-
1
]
except
(
IndexError
,
ValueError
):
return
if
op
in
self
.
_uncond_transfer
:
self
.
next
=
[]
def
get_children
(
self
):
if
self
.
next
and
self
.
next
[
0
]
in
self
.
outEdges
:
self
.
outEdges
.
remove
(
self
.
next
[
0
])
...
...
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