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
aee8b65a
Commit
aee8b65a
authored
Aug 17, 2014
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
properly integrate Python class nodes into type inference
parent
9b566f8e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
8 deletions
+14
-8
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+12
-4
Cython/Compiler/FlowControl.py
Cython/Compiler/FlowControl.py
+2
-4
No files found.
Cython/Compiler/ExprNodes.py
View file @
aee8b65a
...
@@ -7163,14 +7163,18 @@ class ClassNode(ExprNode, ModuleNameMixin):
...
@@ -7163,14 +7163,18 @@ class ClassNode(ExprNode, ModuleNameMixin):
# module_name EncodedString Name of defining module
# module_name EncodedString Name of defining module
subexprs
=
[
'bases'
,
'doc'
]
subexprs
=
[
'bases'
,
'doc'
]
type
=
py_object_type
is_temp
=
True
def
infer_type
(
self
,
env
):
# TODO: could return 'type' in some cases
return
py_object_type
def
analyse_types
(
self
,
env
):
def
analyse_types
(
self
,
env
):
self
.
bases
=
self
.
bases
.
analyse_types
(
env
)
self
.
bases
=
self
.
bases
.
analyse_types
(
env
)
if
self
.
doc
:
if
self
.
doc
:
self
.
doc
=
self
.
doc
.
analyse_types
(
env
)
self
.
doc
=
self
.
doc
.
analyse_types
(
env
)
self
.
doc
=
self
.
doc
.
coerce_to_pyobject
(
env
)
self
.
doc
=
self
.
doc
.
coerce_to_pyobject
(
env
)
self
.
type
=
py_object_type
self
.
is_temp
=
1
env
.
use_utility_code
(
UtilityCode
.
load_cached
(
"CreateClass"
,
"ObjectHandling.c"
))
env
.
use_utility_code
(
UtilityCode
.
load_cached
(
"CreateClass"
,
"ObjectHandling.c"
))
return
self
return
self
...
@@ -7215,10 +7219,14 @@ class Py3ClassNode(ExprNode):
...
@@ -7215,10 +7219,14 @@ class Py3ClassNode(ExprNode):
# allow_py2_metaclass bool should look for Py2 metaclass
# allow_py2_metaclass bool should look for Py2 metaclass
subexprs
=
[]
subexprs
=
[]
type
=
py_object_type
is_temp
=
True
def
infer_type
(
self
,
env
):
# TODO: could return 'type' in some cases
return
py_object_type
def
analyse_types
(
self
,
env
):
def
analyse_types
(
self
,
env
):
self
.
type
=
py_object_type
self
.
is_temp
=
1
return
self
return
self
def
may_be_none
(
self
):
def
may_be_none
(
self
):
...
...
Cython/Compiler/FlowControl.py
View file @
aee8b65a
...
@@ -5,8 +5,7 @@ cython.declare(PyrexTypes=object, ExprNodes=object, Nodes=object,
...
@@ -5,8 +5,7 @@ cython.declare(PyrexTypes=object, ExprNodes=object, Nodes=object,
Builtin
=
object
,
InternalError
=
object
,
Builtin
=
object
,
InternalError
=
object
,
error
=
object
,
warning
=
object
,
error
=
object
,
warning
=
object
,
py_object_type
=
object
,
unspecified_type
=
object
,
py_object_type
=
object
,
unspecified_type
=
object
,
object_expr
=
object
,
object_expr_not_none
=
object
,
object_expr
=
object
,
fake_rhs_expr
=
object
,
TypedExprNode
=
object
)
fake_rhs_expr
=
object
,
TypedExprNode
=
object
)
from
.
import
Builtin
from
.
import
Builtin
from
.
import
ExprNodes
from
.
import
ExprNodes
...
@@ -29,7 +28,6 @@ class TypedExprNode(ExprNodes.ExprNode):
...
@@ -29,7 +28,6 @@ class TypedExprNode(ExprNodes.ExprNode):
return
self
.
_may_be_none
!=
False
return
self
.
_may_be_none
!=
False
object_expr
=
TypedExprNode
(
py_object_type
,
may_be_none
=
True
)
object_expr
=
TypedExprNode
(
py_object_type
,
may_be_none
=
True
)
object_expr_not_none
=
TypedExprNode
(
py_object_type
,
may_be_none
=
False
)
# Fake rhs to silence "unused variable" warning
# Fake rhs to silence "unused variable" warning
fake_rhs_expr
=
TypedExprNode
(
unspecified_type
)
fake_rhs_expr
=
TypedExprNode
(
unspecified_type
)
...
@@ -1287,7 +1285,7 @@ class ControlFlowAnalysis(CythonTransform):
...
@@ -1287,7 +1285,7 @@ class ControlFlowAnalysis(CythonTransform):
def
visit_PyClassDefNode
(
self
,
node
):
def
visit_PyClassDefNode
(
self
,
node
):
self
.
visitchildren
(
node
,
(
'dict'
,
'metaclass'
,
self
.
visitchildren
(
node
,
(
'dict'
,
'metaclass'
,
'mkw'
,
'bases'
,
'class_result'
))
'mkw'
,
'bases'
,
'class_result'
))
self
.
flow
.
mark_assignment
(
node
.
target
,
object_expr_not_none
,
self
.
flow
.
mark_assignment
(
node
.
target
,
node
.
classobj
,
self
.
env
.
lookup
(
node
.
name
))
self
.
env
.
lookup
(
node
.
name
))
self
.
env_stack
.
append
(
self
.
env
)
self
.
env_stack
.
append
(
self
.
env
)
self
.
env
=
node
.
scope
self
.
env
=
node
.
scope
...
...
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