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
80d9a6ab
Commit
80d9a6ab
authored
Oct 06, 2008
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
from cython import foo
parent
b016353f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
10 deletions
+34
-10
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+4
-0
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+30
-10
No files found.
Cython/Compiler/ExprNodes.py
View file @
80d9a6ab
...
@@ -857,6 +857,7 @@ class NameNode(AtomicExprNode):
...
@@ -857,6 +857,7 @@ class NameNode(AtomicExprNode):
is_name
=
True
is_name
=
True
is_cython_module
=
False
is_cython_module
=
False
cython_attribute
=
None
skip_assignment_decref
=
False
skip_assignment_decref
=
False
entry
=
None
entry
=
None
...
@@ -864,6 +865,9 @@ class NameNode(AtomicExprNode):
...
@@ -864,6 +865,9 @@ class NameNode(AtomicExprNode):
node
=
NameNode
(
pos
)
node
=
NameNode
(
pos
)
node
.
analyse_types
(
env
,
entry
=
entry
)
node
.
analyse_types
(
env
,
entry
=
entry
)
return
node
return
node
def
as_cython_attribute
(
self
):
return
self
.
cython_attribute
create_analysed_rvalue
=
staticmethod
(
create_analysed_rvalue
)
create_analysed_rvalue
=
staticmethod
(
create_analysed_rvalue
)
...
...
Cython/Compiler/ParseTreeTransforms.py
View file @
80d9a6ab
...
@@ -300,16 +300,32 @@ class InterpretCompilerDirectives(CythonTransform):
...
@@ -300,16 +300,32 @@ class InterpretCompilerDirectives(CythonTransform):
newimp
=
[]
newimp
=
[]
for
pos
,
name
,
as_name
,
kind
in
node
.
imported_names
:
for
pos
,
name
,
as_name
,
kind
in
node
.
imported_names
:
if
name
in
Options
.
option_types
:
if
name
in
Options
.
option_types
:
if
as_name
is
None
:
as_name
=
name
self
.
option_names
[
as_name
]
=
name
self
.
option_names
[
as_name
]
=
name
if
kind
is
not
None
:
if
kind
is
not
None
:
self
.
context
.
nonfatal_error
(
PostParseError
(
pos
,
self
.
context
.
nonfatal_error
(
PostParseError
(
pos
,
"Compiler option imports must be plain imports"
))
"Compiler option imports must be plain imports"
))
return
None
else
:
else
:
newimp
.
append
((
pos
,
name
,
as_name
,
kind
))
newimp
.
append
((
pos
,
name
,
as_name
,
kind
))
node
.
imported_names
=
newimpo
if
not
newimp
:
return
None
node
.
imported_names
=
newimp
return
node
return
node
def
visit_FromImportStatNode
(
self
,
node
):
if
node
.
module
.
module_name
.
value
==
u"cython"
:
newimp
=
[]
for
true_name
,
name_node
in
node
.
items
:
if
true_name
in
Options
.
option_types
:
self
.
option_names
[
name_node
.
name
]
=
true_name
else
:
newimp
.
append
((
true_name
,
name_node
))
if
not
newimp
:
return
None
node
.
items
=
newimp
return
node
def
visit_SingleAssignmentNode
(
self
,
node
):
def
visit_SingleAssignmentNode
(
self
,
node
):
if
(
isinstance
(
node
.
rhs
,
ImportNode
)
and
if
(
isinstance
(
node
.
rhs
,
ImportNode
)
and
node
.
rhs
.
module_name
.
value
==
u'cython'
):
node
.
rhs
.
module_name
.
value
==
u'cython'
):
...
@@ -324,8 +340,10 @@ class InterpretCompilerDirectives(CythonTransform):
...
@@ -324,8 +340,10 @@ class InterpretCompilerDirectives(CythonTransform):
def
visit_NameNode
(
self
,
node
):
def
visit_NameNode
(
self
,
node
):
if
node
.
name
in
self
.
cython_module_names
:
if
node
.
name
in
self
.
cython_module_names
:
node
.
is_cython_module
=
True
node
.
is_cython_module
=
True
else
:
node
.
cython_attribute
=
self
.
option_names
.
get
(
node
.
name
)
return
node
return
node
def
visit_Node
(
self
,
node
):
def
visit_Node
(
self
,
node
):
self
.
visitchildren
(
node
)
self
.
visitchildren
(
node
)
return
node
return
node
...
@@ -336,13 +354,15 @@ class InterpretCompilerDirectives(CythonTransform):
...
@@ -336,13 +354,15 @@ class InterpretCompilerDirectives(CythonTransform):
# Otherwise, returns None
# Otherwise, returns None
optname
=
None
optname
=
None
if
isinstance
(
node
,
CallNode
):
if
isinstance
(
node
,
CallNode
):
if
(
isinstance
(
node
.
function
,
AttributeNode
)
and
self
.
visit
(
node
.
function
)
isinstance
(
node
.
function
.
obj
,
NameNode
)
and
optname
=
node
.
function
.
as_cython_attribute
()
node
.
function
.
obj
.
name
in
self
.
cython_module_names
):
# if (isinstance(node.function, AttributeNode) and
optname
=
node
.
function
.
attribute
# isinstance(node.function.obj, NameNode) and
elif
(
isinstance
(
node
.
function
,
NameNode
)
and
# node.function.obj.name in self.cython_module_names):
node
.
function
.
name
in
self
.
option_names
):
# optname = node.function.attribute
optname
=
self
.
option_names
[
node
.
function
.
name
]
# elif (isinstance(node.function, NameNode) and
# node.function.name in self.option_names):
# optname = self.option_names[node.function.name]
if
optname
:
if
optname
:
optiontype
=
Options
.
option_types
.
get
(
optname
)
optiontype
=
Options
.
option_types
.
get
(
optname
)
...
...
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