Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
2b14ac40
Commit
2b14ac40
authored
Sep 15, 2011
by
Vitja Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Track scope node as well as env
parent
77a4a0e7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
3 deletions
+21
-3
Cython/Compiler/Visitor.py
Cython/Compiler/Visitor.py
+21
-3
No files found.
Cython/Compiler/Visitor.py
View file @
2b14ac40
...
@@ -319,18 +319,36 @@ class EnvTransform(CythonTransform):
...
@@ -319,18 +319,36 @@ class EnvTransform(CythonTransform):
This transformation keeps a stack of the environments.
This transformation keeps a stack of the environments.
"""
"""
def
__call__
(
self
,
root
):
def
__call__
(
self
,
root
):
self
.
env_stack
=
[
root
.
scope
]
self
.
env_stack
=
[
(
root
,
root
.
scope
)
]
return
super
(
EnvTransform
,
self
).
__call__
(
root
)
return
super
(
EnvTransform
,
self
).
__call__
(
root
)
def
current_env
(
self
):
def
current_env
(
self
):
return
self
.
env_stack
[
-
1
]
return
self
.
env_stack
[
-
1
][
1
]
def
current_scope_node
(
self
):
return
self
.
env_stack
[
-
1
][
0
]
def
visit_FuncDefNode
(
self
,
node
):
def
visit_FuncDefNode
(
self
,
node
):
self
.
env_stack
.
append
(
node
.
local_scope
)
self
.
env_stack
.
append
((
node
,
node
.
local_scope
))
self
.
visitchildren
(
node
)
self
.
env_stack
.
pop
()
return
node
def
visit_ClassDefNode
(
self
,
node
):
self
.
env_stack
.
append
((
node
,
node
.
scope
))
self
.
visitchildren
(
node
)
self
.
visitchildren
(
node
)
self
.
env_stack
.
pop
()
self
.
env_stack
.
pop
()
return
node
return
node
def
visit_ScopedExprNode
(
self
,
node
):
if
node
.
expr_scope
:
self
.
env_stack
.
append
((
node
,
node
.
expr_scope
))
self
.
visitchildren
(
node
)
self
.
env_stack
.
pop
()
else
:
self
.
visitchildren
(
node
)
return
node
class
RecursiveNodeReplacer
(
VisitorTransform
):
class
RecursiveNodeReplacer
(
VisitorTransform
):
"""
"""
...
...
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