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
3279d914
Commit
3279d914
authored
Oct 15, 2011
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
work around missing temp variable declaration when a multiplied tuple ends up as cached constant
parent
6fc4bd3c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
3 deletions
+21
-3
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+13
-3
tests/run/consts.pyx
tests/run/consts.pyx
+8
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
3279d914
...
@@ -4432,8 +4432,17 @@ class SequenceNode(ExprNode):
...
@@ -4432,8 +4432,17 @@ class SequenceNode(ExprNode):
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
put_gotref
(
self
.
py_result
())
code
.
put_gotref
(
self
.
py_result
())
if
mult
:
if
mult
:
counter
=
code
.
funcstate
.
allocate_temp
(
self
.
mult_factor
.
type
,
manage_ref
=
False
)
# FIXME: can't use a temp variable here as the code may
offset
=
'%s * %s + '
%
(
counter
,
arg_count
)
# end up in the constant building function. Temps
# currently don't work there.
#counter = code.funcstate.allocate_temp(self.mult_factor.type, manage_ref=False)
counter
=
'__pyx_n'
code
.
putln
(
'{ Py_ssize_t %s;'
%
counter
)
if
arg_count
==
1
:
offset
=
counter
+
' + '
else
:
offset
=
'%s * %s + '
%
(
counter
,
arg_count
)
code
.
putln
(
'for (%s=0; %s < %s; %s++) {'
%
(
code
.
putln
(
'for (%s=0; %s < %s; %s++) {'
%
(
counter
,
counter
,
mult
,
counter
counter
,
counter
,
mult
,
counter
))
))
...
@@ -4452,7 +4461,8 @@ class SequenceNode(ExprNode):
...
@@ -4452,7 +4461,8 @@ class SequenceNode(ExprNode):
code
.
put_giveref
(
arg
.
py_result
())
code
.
put_giveref
(
arg
.
py_result
())
if
mult
:
if
mult
:
code
.
putln
(
'}'
)
code
.
putln
(
'}'
)
code
.
funcstate
.
release_temp
(
counter
)
#code.funcstate.release_temp(counter)
code
.
putln
(
'}'
)
def
generate_subexpr_disposal_code
(
self
,
code
):
def
generate_subexpr_disposal_code
(
self
,
code
):
if
self
.
mult_factor
:
if
self
.
mult_factor
:
...
...
tests/run/consts.pyx
View file @
3279d914
...
@@ -167,6 +167,14 @@ def multiplied_lists_with_side_effects():
...
@@ -167,6 +167,14 @@ def multiplied_lists_with_side_effects():
"""
"""
return
[
side_effect
(
1
),
side_effect
(
2
),
side_effect
(
3
)]
*
5
return
[
side_effect
(
1
),
side_effect
(
2
),
side_effect
(
3
)]
*
5
@
cython
.
test_fail_if_path_exists
(
"//MulNode"
)
def
multiplied_const_tuple
():
"""
>>> multiplied_const_tuple() == (1,2) * 5
True
"""
return
(
1
,
2
)
*
5
@
cython
.
test_fail_if_path_exists
(
"//PrimaryCmpNode"
)
@
cython
.
test_fail_if_path_exists
(
"//PrimaryCmpNode"
)
def
compile_time_DEF
():
def
compile_time_DEF
():
"""
"""
...
...
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