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
Boxiang Sun
cython
Commits
ebea5bf9
Commit
ebea5bf9
authored
Nov 12, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
let PostParse transform inherit from ScopeTrackingTransform to avoid code duplication
parent
5932f48a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
24 deletions
+4
-24
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+4
-24
No files found.
Cython/Compiler/ParseTreeTransforms.py
View file @
ebea5bf9
from
Cython.Compiler.Visitor
import
VisitorTransform
,
TreeVisitor
from
Cython.Compiler.Visitor
import
CythonTransform
,
EnvTransform
from
Cython.Compiler.Visitor
import
CythonTransform
,
EnvTransform
,
ScopeTrackingTransform
from
Cython.Compiler.ModuleNode
import
ModuleNode
from
Cython.Compiler.Nodes
import
*
from
Cython.Compiler.ExprNodes
import
*
...
...
@@ -130,7 +130,7 @@ class PostParseError(CompileError): pass
ERR_CDEF_INCLASS
=
'Cannot assign default value to fields in cdef classes, structs or unions'
ERR_BUF_DEFAULTS
=
'Invalid buffer defaults specification (see docs)'
ERR_INVALID_SPECIALATTR_TYPE
=
'Special attributes must not have a type declared'
class
PostParse
(
Cython
Transform
):
class
PostParse
(
ScopeTracking
Transform
):
"""
Basic interpretation of the parse tree, as well as validity
checking that can be done on a very basic level on the parse
...
...
@@ -175,28 +175,8 @@ class PostParse(CythonTransform):
}
def
visit_ModuleNode
(
self
,
node
):
self
.
scope_type
=
'module'
self
.
scope_node
=
node
self
.
lambda_counter
=
1
self
.
visitchildren
(
node
)
return
node
def
visit_scope
(
self
,
node
,
scope_type
):
prev
=
self
.
scope_type
,
self
.
scope_node
self
.
scope_type
=
scope_type
self
.
scope_node
=
node
self
.
visitchildren
(
node
)
self
.
scope_type
,
self
.
scope_node
=
prev
return
node
def
visit_ClassDefNode
(
self
,
node
):
return
self
.
visit_scope
(
node
,
'class'
)
def
visit_FuncDefNode
(
self
,
node
):
return
self
.
visit_scope
(
node
,
'function'
)
def
visit_CStructOrUnionDefNode
(
self
,
node
):
return
self
.
visit_scope
(
node
,
'struct'
)
return
super
(
PostParse
,
self
).
visit_ModuleNode
(
node
)
def
visit_LambdaNode
(
self
,
node
):
# unpack a lambda expression into the corresponding DefNode
...
...
@@ -239,7 +219,7 @@ class PostParse(CythonTransform):
declbase
=
declbase
.
base
if
isinstance
(
declbase
,
CNameDeclaratorNode
):
if
declbase
.
default
is
not
None
:
if
self
.
scope_type
in
(
'class'
,
'struct'
):
if
self
.
scope_type
in
(
'c
class'
,
'pyc
lass'
,
'struct'
):
if
isinstance
(
self
.
scope_node
,
CClassDefNode
):
handler
=
self
.
specialattribute_handlers
.
get
(
decl
.
name
)
if
handler
:
...
...
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