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
15d12dc5
Commit
15d12dc5
authored
Dec 02, 2008
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
cde600a1
a0654d24
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
140 additions
and
45 deletions
+140
-45
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+2
-1
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+109
-42
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+23
-0
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+6
-2
No files found.
Cython/Compiler/Code.py
View file @
15d12dc5
...
@@ -150,8 +150,9 @@ class FunctionState(object):
...
@@ -150,8 +150,9 @@ class FunctionState(object):
freelist
=
self
.
temps_free
.
get
((
type
,
manage_ref
))
freelist
=
self
.
temps_free
.
get
((
type
,
manage_ref
))
if
freelist
is
None
:
if
freelist
is
None
:
freelist
=
[]
freelist
=
[]
self
.
temps_free
[(
type
,
manage_ref
)]
=
freelist
self
.
temps_free
[(
type
,
manage_ref
)]
=
freelist
if
name
in
freelist
:
raise
RuntimeError
(
"Temp %s freed twice!"
%
name
)
freelist
.
append
(
name
)
freelist
.
append
(
name
)
if
DebugFlags
.
debug_temp_code_comments
:
if
DebugFlags
.
debug_temp_code_comments
:
self
.
owner
.
putln
(
"/* %s released */"
%
name
)
self
.
owner
.
putln
(
"/* %s released */"
%
name
)
...
...
Cython/Compiler/ExprNodes.py
View file @
15d12dc5
This diff is collapsed.
Click to expand it.
Cython/Compiler/Nodes.py
View file @
15d12dc5
...
@@ -2444,6 +2444,7 @@ class PyClassDefNode(ClassDefNode):
...
@@ -2444,6 +2444,7 @@ class PyClassDefNode(ClassDefNode):
self
.
body
.
generate_execution_code
(
code
)
self
.
body
.
generate_execution_code
(
code
)
self
.
target
.
generate_assignment_code
(
self
.
classobj
,
code
)
self
.
target
.
generate_assignment_code
(
self
.
classobj
,
code
)
self
.
dict
.
generate_disposal_code
(
code
)
self
.
dict
.
generate_disposal_code
(
code
)
self
.
dict
.
free_temps
(
code
)
class
CClassDefNode
(
ClassDefNode
):
class
CClassDefNode
(
ClassDefNode
):
...
@@ -2659,6 +2660,7 @@ class ExprStatNode(StatNode):
...
@@ -2659,6 +2660,7 @@ class ExprStatNode(StatNode):
if
not
self
.
expr
.
is_temp
and
self
.
expr
.
result
():
if
not
self
.
expr
.
is_temp
and
self
.
expr
.
result
():
code
.
putln
(
"%s;"
%
self
.
expr
.
result
())
code
.
putln
(
"%s;"
%
self
.
expr
.
result
())
self
.
expr
.
generate_disposal_code
(
code
)
self
.
expr
.
generate_disposal_code
(
code
)
self
.
expr
.
free_temps
(
code
)
def
annotate
(
self
,
code
):
def
annotate
(
self
,
code
):
self
.
expr
.
annotate
(
code
)
self
.
expr
.
annotate
(
code
)
...
@@ -2884,6 +2886,7 @@ class CascadedAssignmentNode(AssignmentNode):
...
@@ -2884,6 +2886,7 @@ class CascadedAssignmentNode(AssignmentNode):
lhs
.
generate_assignment_code
(
rhs
,
code
)
lhs
.
generate_assignment_code
(
rhs
,
code
)
# Assignment has disposed of the cloned RHS
# Assignment has disposed of the cloned RHS
self
.
rhs
.
generate_disposal_code
(
code
)
self
.
rhs
.
generate_disposal_code
(
code
)
self
.
rhs
.
free_temps
(
code
)
def
annotate
(
self
,
code
):
def
annotate
(
self
,
code
):
for
i
in
range
(
len
(
self
.
lhs_list
)):
for
i
in
range
(
len
(
self
.
lhs_list
)):
...
@@ -3016,7 +3019,9 @@ class InPlaceAssignmentNode(AssignmentNode):
...
@@ -3016,7 +3019,9 @@ class InPlaceAssignmentNode(AssignmentNode):
code
.
error_goto_if_null
(
self
.
result_value
.
py_result
(),
self
.
pos
)))
code
.
error_goto_if_null
(
self
.
result_value
.
py_result
(),
self
.
pos
)))
self
.
result_value
.
generate_evaluation_code
(
code
)
# May be a type check...
self
.
result_value
.
generate_evaluation_code
(
code
)
# May be a type check...
self
.
rhs
.
generate_disposal_code
(
code
)
self
.
rhs
.
generate_disposal_code
(
code
)
self
.
rhs
.
free_temps
(
code
)
self
.
dup
.
generate_disposal_code
(
code
)
self
.
dup
.
generate_disposal_code
(
code
)
self
.
dup
.
free_temps
(
code
)
self
.
lhs
.
generate_assignment_code
(
self
.
result_value
,
code
)
self
.
lhs
.
generate_assignment_code
(
self
.
result_value
,
code
)
else
:
else
:
c_op
=
self
.
operator
c_op
=
self
.
operator
...
@@ -3034,8 +3039,10 @@ class InPlaceAssignmentNode(AssignmentNode):
...
@@ -3034,8 +3039,10 @@ class InPlaceAssignmentNode(AssignmentNode):
self
.
dup
.
generate_result_code
(
code
)
self
.
dup
.
generate_result_code
(
code
)
code
.
putln
(
"%s %s= %s;"
%
(
self
.
lhs
.
result
(),
c_op
,
self
.
rhs
.
result
())
)
code
.
putln
(
"%s %s= %s;"
%
(
self
.
lhs
.
result
(),
c_op
,
self
.
rhs
.
result
())
)
self
.
rhs
.
generate_disposal_code
(
code
)
self
.
rhs
.
generate_disposal_code
(
code
)
self
.
rhs
.
free_temps
(
code
)
if
self
.
dup
.
is_temp
:
if
self
.
dup
.
is_temp
:
self
.
dup
.
generate_subexpr_disposal_code
(
code
)
self
.
dup
.
generate_subexpr_disposal_code
(
code
)
self
.
dup
.
free_subexpr_temps
(
code
)
def
create_dup_node
(
self
,
env
):
def
create_dup_node
(
self
,
env
):
import
ExprNodes
import
ExprNodes
...
@@ -3065,6 +3072,8 @@ class InPlaceAssignmentNode(AssignmentNode):
...
@@ -3065,6 +3072,8 @@ class InPlaceAssignmentNode(AssignmentNode):
index
=
index
,
index
=
index
,
indices
=
indices
,
indices
=
indices
,
is_temp
=
self
.
dup
.
is_temp
)
is_temp
=
self
.
dup
.
is_temp
)
else
:
assert
False
self
.
lhs
=
target_lhs
self
.
lhs
=
target_lhs
return
self
.
dup
return
self
.
dup
...
@@ -3117,6 +3126,7 @@ class PrintStatNode(StatNode):
...
@@ -3117,6 +3126,7 @@ class PrintStatNode(StatNode):
self
.
append_newline
,
self
.
append_newline
,
code
.
error_goto
(
self
.
pos
)))
code
.
error_goto
(
self
.
pos
)))
self
.
arg_tuple
.
generate_disposal_code
(
code
)
self
.
arg_tuple
.
generate_disposal_code
(
code
)
self
.
arg_tuple
.
free_temps
(
code
)
def
annotate
(
self
,
code
):
def
annotate
(
self
,
code
):
self
.
arg_tuple
.
annotate
(
code
)
self
.
arg_tuple
.
annotate
(
code
)
...
@@ -3152,6 +3162,7 @@ class ExecStatNode(StatNode):
...
@@ -3152,6 +3162,7 @@ class ExecStatNode(StatNode):
(
self
.
temp_result
,)
+
args
))
(
self
.
temp_result
,)
+
args
))
for
arg
in
self
.
args
:
for
arg
in
self
.
args
:
arg
.
generate_disposal_code
(
code
)
arg
.
generate_disposal_code
(
code
)
arg
.
free_temps
(
code
)
code
.
putln
(
code
.
putln
(
code
.
error_goto_if_null
(
self
.
temp_result
,
self
.
pos
))
code
.
error_goto_if_null
(
self
.
temp_result
,
self
.
pos
))
code
.
put_decref_clear
(
self
.
temp_result
,
py_object_type
)
code
.
put_decref_clear
(
self
.
temp_result
,
py_object_type
)
...
@@ -3287,6 +3298,7 @@ class ReturnStatNode(StatNode):
...
@@ -3287,6 +3298,7 @@ class ReturnStatNode(StatNode):
Naming
.
retval_cname
,
Naming
.
retval_cname
,
self
.
value
.
result_as
(
self
.
return_type
)))
self
.
value
.
result_as
(
self
.
return_type
)))
self
.
value
.
generate_post_assignment_code
(
code
)
self
.
value
.
generate_post_assignment_code
(
code
)
self
.
value
.
free_temps
(
code
)
else
:
else
:
if
self
.
return_type
.
is_pyobject
:
if
self
.
return_type
.
is_pyobject
:
code
.
put_init_to_py_none
(
Naming
.
retval_cname
,
self
.
return_type
)
code
.
put_init_to_py_none
(
Naming
.
retval_cname
,
self
.
return_type
)
...
@@ -3372,10 +3384,13 @@ class RaiseStatNode(StatNode):
...
@@ -3372,10 +3384,13 @@ class RaiseStatNode(StatNode):
"__Pyx_ReRaise();"
)
"__Pyx_ReRaise();"
)
if
self
.
exc_type
:
if
self
.
exc_type
:
self
.
exc_type
.
generate_disposal_code
(
code
)
self
.
exc_type
.
generate_disposal_code
(
code
)
self
.
exc_type
.
free_temps
(
code
)
if
self
.
exc_value
:
if
self
.
exc_value
:
self
.
exc_value
.
generate_disposal_code
(
code
)
self
.
exc_value
.
generate_disposal_code
(
code
)
self
.
exc_value
.
free_temps
(
code
)
if
self
.
exc_tb
:
if
self
.
exc_tb
:
self
.
exc_tb
.
generate_disposal_code
(
code
)
self
.
exc_tb
.
generate_disposal_code
(
code
)
self
.
exc_tb
.
free_temps
(
code
)
code
.
putln
(
code
.
putln
(
code
.
error_goto
(
self
.
pos
))
code
.
error_goto
(
self
.
pos
))
...
@@ -3442,6 +3457,7 @@ class AssertStatNode(StatNode):
...
@@ -3442,6 +3457,7 @@ class AssertStatNode(StatNode):
"PyErr_SetObject(PyExc_AssertionError, %s);"
%
"PyErr_SetObject(PyExc_AssertionError, %s);"
%
self
.
value
.
py_result
())
self
.
value
.
py_result
())
self
.
value
.
generate_disposal_code
(
code
)
self
.
value
.
generate_disposal_code
(
code
)
self
.
value
.
free_temps
(
code
)
else
:
else
:
code
.
putln
(
code
.
putln
(
"PyErr_SetNone(PyExc_AssertionError);"
)
"PyErr_SetNone(PyExc_AssertionError);"
)
...
@@ -3450,6 +3466,7 @@ class AssertStatNode(StatNode):
...
@@ -3450,6 +3466,7 @@ class AssertStatNode(StatNode):
code
.
putln
(
code
.
putln
(
"}"
)
"}"
)
self
.
cond
.
generate_disposal_code
(
code
)
self
.
cond
.
generate_disposal_code
(
code
)
self
.
cond
.
free_temps
(
code
)
code
.
putln
(
"#endif"
)
code
.
putln
(
"#endif"
)
def
annotate
(
self
,
code
):
def
annotate
(
self
,
code
):
...
@@ -3756,6 +3773,7 @@ class ForInStatNode(LoopNode, StatNode):
...
@@ -3756,6 +3773,7 @@ class ForInStatNode(LoopNode, StatNode):
code
.
put_label
(
break_label
)
code
.
put_label
(
break_label
)
self
.
iterator
.
release_counter_temp
(
code
)
self
.
iterator
.
release_counter_temp
(
code
)
self
.
iterator
.
generate_disposal_code
(
code
)
self
.
iterator
.
generate_disposal_code
(
code
)
self
.
iterator
.
free_temps
(
code
)
def
annotate
(
self
,
code
):
def
annotate
(
self
,
code
):
self
.
target
.
annotate
(
code
)
self
.
target
.
annotate
(
code
)
...
@@ -3878,9 +3896,12 @@ class ForFromStatNode(LoopNode, StatNode):
...
@@ -3878,9 +3896,12 @@ class ForFromStatNode(LoopNode, StatNode):
code
.
putln
(
"}"
)
code
.
putln
(
"}"
)
code
.
put_label
(
break_label
)
code
.
put_label
(
break_label
)
self
.
bound1
.
generate_disposal_code
(
code
)
self
.
bound1
.
generate_disposal_code
(
code
)
self
.
bound1
.
free_temps
(
code
)
self
.
bound2
.
generate_disposal_code
(
code
)
self
.
bound2
.
generate_disposal_code
(
code
)
self
.
bound2
.
free_temps
(
code
)
if
self
.
step
is
not
None
:
if
self
.
step
is
not
None
:
self
.
step
.
generate_disposal_code
(
code
)
self
.
step
.
generate_disposal_code
(
code
)
self
.
step
.
free_temps
(
code
)
relation_table
=
{
relation_table
=
{
# {relop : (initial offset, increment op)}
# {relop : (initial offset, increment op)}
...
@@ -4103,6 +4124,7 @@ class ExceptClauseNode(Node):
...
@@ -4103,6 +4124,7 @@ class ExceptClauseNode(Node):
self
.
match_flag
,
self
.
match_flag
,
self
.
pattern
.
py_result
()))
self
.
pattern
.
py_result
()))
self
.
pattern
.
generate_disposal_code
(
code
)
self
.
pattern
.
generate_disposal_code
(
code
)
self
.
pattern
.
free_temps
(
code
)
code
.
putln
(
code
.
putln
(
"if (%s) {"
%
"if (%s) {"
%
self
.
match_flag
)
self
.
match_flag
)
...
@@ -4539,6 +4561,7 @@ class FromImportStatNode(StatNode):
...
@@ -4539,6 +4561,7 @@ class FromImportStatNode(StatNode):
code
.
error_goto_if_null
(
self
.
item
.
result
(),
self
.
pos
)))
code
.
error_goto_if_null
(
self
.
item
.
result
(),
self
.
pos
)))
target
.
generate_assignment_code
(
self
.
item
,
code
)
target
.
generate_assignment_code
(
self
.
item
,
code
)
self
.
module
.
generate_disposal_code
(
code
)
self
.
module
.
generate_disposal_code
(
code
)
self
.
module
.
free_temps
(
code
)
...
...
Cython/Compiler/Optimize.py
View file @
15d12dc5
...
@@ -8,9 +8,13 @@ import TypeSlots
...
@@ -8,9 +8,13 @@ import TypeSlots
import
Symtab
import
Symtab
from
StringEncoding
import
EncodedString
from
StringEncoding
import
EncodedString
#def unwrap_node(node):
# while isinstance(node, ExprNodes.PersistentNode):
# node = node.arg
# return node
# Temporary hack while PersistentNode is out of order
def
unwrap_node
(
node
):
def
unwrap_node
(
node
):
while
isinstance
(
node
,
ExprNodes
.
PersistentNode
):
node
=
node
.
arg
return
node
return
node
def
is_common_value
(
a
,
b
):
def
is_common_value
(
a
,
b
):
...
...
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