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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
aaa5c5f9
Commit
aaa5c5f9
authored
Dec 21, 2008
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
compile classes in Visitor.py into real extension classes
parent
6bb7b10d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
29 deletions
+28
-29
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+5
-17
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+2
-11
Cython/Compiler/Visitor.pxd
Cython/Compiler/Visitor.pxd
+15
-0
Cython/Compiler/Visitor.py
Cython/Compiler/Visitor.py
+6
-1
No files found.
Cython/Compiler/Optimize.py
View file @
aaa5c5f9
...
@@ -49,10 +49,7 @@ class IterationTransform(Visitor.VisitorTransform):
...
@@ -49,10 +49,7 @@ class IterationTransform(Visitor.VisitorTransform):
PyDict_Next_entry
=
Symtab
.
Entry
(
PyDict_Next_entry
=
Symtab
.
Entry
(
PyDict_Next_name
,
PyDict_Next_name
,
PyDict_Next_func_type
)
PyDict_Next_name
,
PyDict_Next_name
,
PyDict_Next_func_type
)
def
visit_Node
(
self
,
node
):
visit_Node
=
Visitor
.
VisitorTransform
.
recurse_to_children
# descend into statements (loops) and nodes (comprehensions)
self
.
visitchildren
(
node
)
return
node
def
visit_ModuleNode
(
self
,
node
):
def
visit_ModuleNode
(
self
,
node
):
self
.
current_scope
=
node
.
scope
self
.
current_scope
=
node
.
scope
...
@@ -361,10 +358,7 @@ class SwitchTransform(Visitor.VisitorTransform):
...
@@ -361,10 +358,7 @@ class SwitchTransform(Visitor.VisitorTransform):
cases
=
cases
,
cases
=
cases
,
else_clause
=
node
.
else_clause
)
else_clause
=
node
.
else_clause
)
visit_Node
=
Visitor
.
VisitorTransform
.
recurse_to_children
def
visit_Node
(
self
,
node
):
self
.
visitchildren
(
node
)
return
node
class
FlattenInListTransform
(
Visitor
.
VisitorTransform
,
SkipDeclarations
):
class
FlattenInListTransform
(
Visitor
.
VisitorTransform
,
SkipDeclarations
):
...
@@ -417,9 +411,7 @@ class FlattenInListTransform(Visitor.VisitorTransform, SkipDeclarations):
...
@@ -417,9 +411,7 @@ class FlattenInListTransform(Visitor.VisitorTransform, SkipDeclarations):
condition
=
reduce
(
concat
,
conds
)
condition
=
reduce
(
concat
,
conds
)
return
UtilNodes
.
EvalWithTempExprNode
(
lhs
,
condition
)
return
UtilNodes
.
EvalWithTempExprNode
(
lhs
,
condition
)
def
visit_Node
(
self
,
node
):
visit_Node
=
Visitor
.
VisitorTransform
.
recurse_to_children
self
.
visitchildren
(
node
)
return
node
class
FlattenBuiltinTypeCreation
(
Visitor
.
VisitorTransform
):
class
FlattenBuiltinTypeCreation
(
Visitor
.
VisitorTransform
):
...
@@ -534,9 +526,7 @@ class FlattenBuiltinTypeCreation(Visitor.VisitorTransform):
...
@@ -534,9 +526,7 @@ class FlattenBuiltinTypeCreation(Visitor.VisitorTransform):
return
node
return
node
return
node
.
arg
return
node
.
arg
def
visit_Node
(
self
,
node
):
visit_Node
=
Visitor
.
VisitorTransform
.
recurse_to_children
self
.
visitchildren
(
node
)
return
node
class
ConstantFolding
(
Visitor
.
VisitorTransform
,
SkipDeclarations
):
class
ConstantFolding
(
Visitor
.
VisitorTransform
,
SkipDeclarations
):
...
@@ -614,9 +604,7 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations):
...
@@ -614,9 +604,7 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations):
self
.
current_scope
=
old_scope
self
.
current_scope
=
old_scope
return
node
return
node
def
visit_Node
(
self
,
node
):
visit_Node
=
Visitor
.
VisitorTransform
.
recurse_to_children
self
.
visitchildren
(
node
)
return
node
class
FinalOptimizePhase
(
Visitor
.
CythonTransform
):
class
FinalOptimizePhase
(
Visitor
.
CythonTransform
):
...
...
Cython/Compiler/ParseTreeTransforms.py
View file @
aaa5c5f9
...
@@ -21,9 +21,7 @@ class NameNodeCollector(TreeVisitor):
...
@@ -21,9 +21,7 @@ class NameNodeCollector(TreeVisitor):
super
(
NameNodeCollector
,
self
).
__init__
()
super
(
NameNodeCollector
,
self
).
__init__
()
self
.
name_nodes
=
[]
self
.
name_nodes
=
[]
def
visit_Node
(
self
,
node
):
visit_Node
=
TreeVisitor
.
visitchildren
self
.
visitchildren
(
node
)
return
node
def
visit_NameNode
(
self
,
node
):
def
visit_NameNode
(
self
,
node
):
self
.
name_nodes
.
append
(
node
)
self
.
name_nodes
.
append
(
node
)
...
@@ -423,10 +421,6 @@ class InterpretCompilerDirectives(CythonTransform, SkipDeclarations):
...
@@ -423,10 +421,6 @@ class InterpretCompilerDirectives(CythonTransform, SkipDeclarations):
node
.
cython_attribute
=
self
.
option_names
.
get
(
node
.
name
)
node
.
cython_attribute
=
self
.
option_names
.
get
(
node
.
name
)
return
node
return
node
def
visit_Node
(
self
,
node
):
self
.
visitchildren
(
node
)
return
node
def
try_to_parse_option
(
self
,
node
):
def
try_to_parse_option
(
self
,
node
):
# If node is the contents of an option (in a with statement or
# If node is the contents of an option (in a with statement or
# decorator), returns (optionname, value).
# decorator), returns (optionname, value).
...
@@ -595,10 +589,7 @@ class ComprehensionTransform(VisitorTransform):
...
@@ -595,10 +589,7 @@ class ComprehensionTransform(VisitorTransform):
self
.
visitchildren
(
node
)
self
.
visitchildren
(
node
)
return
node
return
node
def
visit_Node
(
self
,
node
):
visit_Node
=
VisitorTransform
.
recurse_to_children
# descend into statements (loops) and nodes (comprehensions)
self
.
visitchildren
(
node
)
return
node
def
visit_ComprehensionNode
(
self
,
node
):
def
visit_ComprehensionNode
(
self
,
node
):
if
type
(
node
.
loop
)
not
in
(
Nodes
.
ForInStatNode
,
if
type
(
node
.
loop
)
not
in
(
Nodes
.
ForInStatNode
,
...
...
Cython/Compiler/Visitor.pxd
0 → 100644
View file @
aaa5c5f9
cdef
class
BasicVisitor
:
cdef
object
dispatch_table
cpdef
visit
(
self
,
obj
)
cdef
class
TreeVisitor
(
BasicVisitor
):
cdef
public
access_path
cpdef
visitchild
(
self
,
child
,
parent
,
attrname
,
idx
)
cdef
class
VisitorTransform
(
TreeVisitor
):
cpdef
visitchildren
(
self
,
parent
,
attrs
=*
)
cpdef
recurse_to_children
(
self
,
node
)
cdef
class
CythonTransform
(
VisitorTransform
):
cdef
public
context
cdef
public
current_directives
Cython/Compiler/Visitor.py
View file @
aaa5c5f9
...
@@ -143,7 +143,8 @@ class VisitorTransform(TreeVisitor):
...
@@ -143,7 +143,8 @@ class VisitorTransform(TreeVisitor):
are within a StatListNode or similar before doing this.)
are within a StatListNode or similar before doing this.)
"""
"""
def
visitchildren
(
self
,
parent
,
attrs
=
None
):
def
visitchildren
(
self
,
parent
,
attrs
=
None
):
result
=
super
(
VisitorTransform
,
self
).
visitchildren
(
parent
,
attrs
)
# result = super(VisitorTransform, self).visitchildren(parent, attrs)
result
=
TreeVisitor
.
visitchildren
(
self
,
parent
,
attrs
)
for
attr
,
newnode
in
result
.
iteritems
():
for
attr
,
newnode
in
result
.
iteritems
():
if
not
isinstance
(
newnode
,
list
):
if
not
isinstance
(
newnode
,
list
):
setattr
(
parent
,
attr
,
newnode
)
setattr
(
parent
,
attr
,
newnode
)
...
@@ -159,6 +160,10 @@ class VisitorTransform(TreeVisitor):
...
@@ -159,6 +160,10 @@ class VisitorTransform(TreeVisitor):
setattr
(
parent
,
attr
,
newlist
)
setattr
(
parent
,
attr
,
newlist
)
return
result
return
result
def
recurse_to_children
(
self
,
node
):
self
.
visitchildren
(
node
)
return
node
def
__call__
(
self
,
root
):
def
__call__
(
self
,
root
):
return
self
.
visit
(
root
)
return
self
.
visit
(
root
)
...
...
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