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
c462cf06
Commit
c462cf06
authored
Aug 15, 2008
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cloneable buffer IndexNode (preparations for buffer inplace operators)
parent
45271704
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
9 deletions
+36
-9
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+15
-6
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+21
-3
No files found.
Cython/Compiler/ExprNodes.py
View file @
c462cf06
...
@@ -1369,6 +1369,10 @@ class IndexNode(ExprNode):
...
@@ -1369,6 +1369,10 @@ class IndexNode(ExprNode):
# Note: This might be cleaned up by having IndexNode
# Note: This might be cleaned up by having IndexNode
# parsed in a saner way and only construct the tuple if
# parsed in a saner way and only construct the tuple if
# needed.
# needed.
# Note that this function must leave IndexNode in a cloneable state.
# For buffers, self.index is packed out on the initial analysis, and
# when cloning self.indices is copied.
self
.
is_buffer_access
=
False
self
.
is_buffer_access
=
False
self
.
base
.
analyse_types
(
env
)
self
.
base
.
analyse_types
(
env
)
...
@@ -1379,11 +1383,16 @@ class IndexNode(ExprNode):
...
@@ -1379,11 +1383,16 @@ class IndexNode(ExprNode):
skip_child_analysis
=
False
skip_child_analysis
=
False
buffer_access
=
False
buffer_access
=
False
if
self
.
base
.
type
.
is_buffer
:
if
self
.
base
.
type
.
is_buffer
:
assert
isinstance
(
self
.
base
,
NameNode
)
assert
hasattr
(
self
.
base
,
"entry"
)
# Must be a NameNode-like node
if
isinstance
(
self
.
index
,
TupleNode
)
:
if
self
.
indices
:
indices
=
self
.
ind
ex
.
arg
s
indices
=
self
.
ind
ice
s
else
:
else
:
indices
=
[
self
.
index
]
# On cloning, indices is cloned. Otherwise, unpack index into indices
assert
not
isinstance
(
self
.
index
,
CloneNode
)
if
isinstance
(
self
.
index
,
TupleNode
):
indices
=
self
.
index
.
args
else
:
indices
=
[
self
.
index
]
if
len
(
indices
)
==
self
.
base
.
type
.
ndim
:
if
len
(
indices
)
==
self
.
base
.
type
.
ndim
:
buffer_access
=
True
buffer_access
=
True
skip_child_analysis
=
True
skip_child_analysis
=
True
...
@@ -1469,7 +1478,7 @@ class IndexNode(ExprNode):
...
@@ -1469,7 +1478,7 @@ class IndexNode(ExprNode):
def
generate_subexpr_evaluation_code
(
self
,
code
):
def
generate_subexpr_evaluation_code
(
self
,
code
):
self
.
base
.
generate_evaluation_code
(
code
)
self
.
base
.
generate_evaluation_code
(
code
)
if
self
.
index
is
not
None
:
if
not
self
.
indices
:
self
.
index
.
generate_evaluation_code
(
code
)
self
.
index
.
generate_evaluation_code
(
code
)
else
:
else
:
for
i
in
self
.
indices
:
for
i
in
self
.
indices
:
...
@@ -1477,7 +1486,7 @@ class IndexNode(ExprNode):
...
@@ -1477,7 +1486,7 @@ class IndexNode(ExprNode):
def
generate_subexpr_disposal_code
(
self
,
code
):
def
generate_subexpr_disposal_code
(
self
,
code
):
self
.
base
.
generate_disposal_code
(
code
)
self
.
base
.
generate_disposal_code
(
code
)
if
self
.
index
is
not
None
:
if
not
self
.
indices
:
self
.
index
.
generate_disposal_code
(
code
)
self
.
index
.
generate_disposal_code
(
code
)
else
:
else
:
for
i
in
self
.
indices
:
for
i
in
self
.
indices
:
...
...
Cython/Compiler/Nodes.py
View file @
c462cf06
...
@@ -2555,11 +2555,29 @@ class InPlaceAssignmentNode(AssignmentNode):
...
@@ -2555,11 +2555,29 @@ class InPlaceAssignmentNode(AssignmentNode):
self
.
dup
=
self
.
lhs
self
.
dup
=
self
.
lhs
self
.
dup
.
analyse_types
(
env
)
self
.
dup
.
analyse_types
(
env
)
if
isinstance
(
self
.
lhs
,
ExprNodes
.
NameNode
):
if
isinstance
(
self
.
lhs
,
ExprNodes
.
NameNode
):
target_lhs
=
ExprNodes
.
NameNode
(
self
.
dup
.
pos
,
name
=
self
.
dup
.
name
,
is_temp
=
self
.
dup
.
is_temp
,
entry
=
self
.
dup
.
entry
)
target_lhs
=
ExprNodes
.
NameNode
(
self
.
dup
.
pos
,
name
=
self
.
dup
.
name
,
is_temp
=
self
.
dup
.
is_temp
,
entry
=
self
.
dup
.
entry
)
elif
isinstance
(
self
.
lhs
,
ExprNodes
.
AttributeNode
):
elif
isinstance
(
self
.
lhs
,
ExprNodes
.
AttributeNode
):
target_lhs
=
ExprNodes
.
AttributeNode
(
self
.
dup
.
pos
,
obj
=
ExprNodes
.
CloneNode
(
self
.
lhs
.
obj
),
attribute
=
self
.
dup
.
attribute
,
is_temp
=
self
.
dup
.
is_temp
)
target_lhs
=
ExprNodes
.
AttributeNode
(
self
.
dup
.
pos
,
obj
=
ExprNodes
.
CloneNode
(
self
.
lhs
.
obj
),
attribute
=
self
.
dup
.
attribute
,
is_temp
=
self
.
dup
.
is_temp
)
elif
isinstance
(
self
.
lhs
,
ExprNodes
.
IndexNode
):
elif
isinstance
(
self
.
lhs
,
ExprNodes
.
IndexNode
):
target_lhs
=
ExprNodes
.
IndexNode
(
self
.
dup
.
pos
,
base
=
ExprNodes
.
CloneNode
(
self
.
dup
.
base
),
index
=
ExprNodes
.
CloneNode
(
self
.
lhs
.
index
),
is_temp
=
self
.
dup
.
is_temp
)
if
self
.
lhs
.
index
:
index
=
ExprNodes
.
CloneNode
(
self
.
lhs
.
index
)
else
:
index
=
None
if
self
.
lhs
.
indices
:
indices
=
[
ExprNodes
.
CloneNode
(
x
)
for
x
in
self
.
lhs
.
indices
]
else
:
indices
=
[]
target_lhs
=
ExprNodes
.
IndexNode
(
self
.
dup
.
pos
,
base
=
ExprNodes
.
CloneNode
(
self
.
dup
.
base
),
index
=
index
,
indices
=
indices
,
is_temp
=
self
.
dup
.
is_temp
)
self
.
lhs
=
target_lhs
self
.
lhs
=
target_lhs
return
self
.
dup
return
self
.
dup
...
...
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