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
Kirill Smelkov
cython
Commits
c7534618
Commit
c7534618
authored
Mar 01, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve code annotation for if- and switch-statements, minor code cleanups
parent
171f07ce
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
11 deletions
+14
-11
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+14
-11
No files found.
Cython/Compiler/Nodes.py
View file @
c7534618
...
...
@@ -5724,8 +5724,7 @@ class IfStatNode(StatNode):
self
.
else_clause
.
analyse_declarations
(
env
)
def
analyse_expressions
(
self
,
env
):
self
.
if_clauses
=
[
if_clause
.
analyse_expressions
(
env
)
for
if_clause
in
self
.
if_clauses
]
self
.
if_clauses
=
[
if_clause
.
analyse_expressions
(
env
)
for
if_clause
in
self
.
if_clauses
]
if
self
.
else_clause
:
self
.
else_clause
=
self
.
else_clause
.
analyse_expressions
(
env
)
return
self
...
...
@@ -5733,9 +5732,11 @@ class IfStatNode(StatNode):
def
generate_execution_code
(
self
,
code
):
code
.
mark_pos
(
self
.
pos
)
end_label
=
code
.
new_label
()
for
if_clause
in
self
.
if_clauses
:
if_clause
.
generate_execution_code
(
code
,
end_label
)
last
=
len
(
self
.
if_clauses
)
for
i
,
if_clause
in
enumerate
(
self
.
if_clauses
):
if_clause
.
generate_execution_code
(
code
,
end_label
,
is_last
=
i
==
last
)
if
self
.
else_clause
:
code
.
mark_pos
(
self
.
else_clause
.
pos
)
code
.
putln
(
"/*else*/ {"
)
self
.
else_clause
.
generate_execution_code
(
code
)
code
.
putln
(
"}"
)
...
...
@@ -5766,20 +5767,19 @@ class IfClauseNode(Node):
self
.
body
.
analyse_declarations
(
env
)
def
analyse_expressions
(
self
,
env
):
self
.
condition
=
\
self
.
condition
.
analyse_temp_boolean_expression
(
env
)
self
.
condition
=
self
.
condition
.
analyse_temp_boolean_expression
(
env
)
self
.
body
=
self
.
body
.
analyse_expressions
(
env
)
return
self
def
generate_execution_code
(
self
,
code
,
end_label
):
def
generate_execution_code
(
self
,
code
,
end_label
,
is_last
):
self
.
condition
.
generate_evaluation_code
(
code
)
code
.
putln
(
"if (%s) {"
%
self
.
condition
.
result
())
code
.
mark_pos
(
self
.
pos
)
code
.
putln
(
"if (%s) {"
%
self
.
condition
.
result
())
self
.
condition
.
generate_disposal_code
(
code
)
self
.
condition
.
free_temps
(
code
)
self
.
body
.
generate_execution_code
(
code
)
if
not
self
.
body
.
is_terminator
:
code
.
mark_pos
(
self
.
pos
,
trace
=
False
)
if
not
(
is_last
or
self
.
body
.
is_terminator
):
code
.
put_goto
(
end_label
)
code
.
putln
(
"}"
)
...
...
@@ -5806,6 +5806,7 @@ class SwitchCaseNode(StatNode):
cond
.
generate_evaluation_code
(
code
)
code
.
putln
(
"case %s:"
%
cond
.
result
())
self
.
body
.
generate_execution_code
(
code
)
code
.
mark_pos
(
self
.
pos
,
trace
=
False
)
code
.
putln
(
"break;"
)
def
generate_function_definitions
(
self
,
env
,
code
):
...
...
@@ -5818,6 +5819,7 @@ class SwitchCaseNode(StatNode):
cond
.
annotate
(
code
)
self
.
body
.
annotate
(
code
)
class
SwitchStatNode
(
StatNode
):
# Generated in the optimization of an if-elif-else node
#
...
...
@@ -5858,6 +5860,7 @@ class SwitchStatNode(StatNode):
if
self
.
else_clause
is
not
None
:
self
.
else_clause
.
annotate
(
code
)
class
LoopNode
(
object
):
pass
...
...
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