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
d9172bdf
Commit
d9172bdf
authored
Feb 28, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve annotation for generated try-except code
parent
1b3eacbe
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
7 deletions
+11
-7
Cython/Compiler/Annotate.py
Cython/Compiler/Annotate.py
+2
-2
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+5
-4
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+4
-1
No files found.
Cython/Compiler/Annotate.py
View file @
d9172bdf
...
@@ -41,9 +41,9 @@ class AnnotationCCodeWriter(CCodeWriter):
...
@@ -41,9 +41,9 @@ class AnnotationCCodeWriter(CCodeWriter):
CCodeWriter
.
write
(
self
,
s
)
CCodeWriter
.
write
(
self
,
s
)
self
.
annotation_buffer
.
write
(
s
)
self
.
annotation_buffer
.
write
(
s
)
def
mark_pos
(
self
,
pos
):
def
mark_pos
(
self
,
pos
,
trace
=
True
):
if
pos
is
not
None
:
if
pos
is
not
None
:
CCodeWriter
.
mark_pos
(
self
,
pos
)
CCodeWriter
.
mark_pos
(
self
,
pos
,
trace
)
if
self
.
last_annotated_pos
:
if
self
.
last_annotated_pos
:
source_desc
,
line
,
_
=
self
.
last_annotated_pos
source_desc
,
line
,
_
=
self
.
last_annotated_pos
pos_code
=
self
.
code
[
source_desc
.
filename
]
pos_code
=
self
.
code
[
source_desc
.
filename
]
...
...
Cython/Compiler/Code.py
View file @
d9172bdf
...
@@ -1563,20 +1563,21 @@ class CCodeWriter(object):
...
@@ -1563,20 +1563,21 @@ class CCodeWriter(object):
self
.
write
(
"
\
n
"
)
self
.
write
(
"
\
n
"
)
self
.
bol
=
1
self
.
bol
=
1
def
mark_pos
(
self
,
pos
):
def
mark_pos
(
self
,
pos
,
trace
=
True
):
if
pos
is
None
:
if
pos
is
None
:
return
return
if
self
.
last_marked_pos
and
self
.
last_marked_pos
[:
2
]
==
pos
[:
2
]:
if
self
.
last_marked_pos
and
self
.
last_marked_pos
[:
2
]
==
pos
[:
2
]:
return
return
self
.
last_pos
=
pos
self
.
last_pos
=
(
pos
,
trace
)
def
emit_marker
(
self
):
def
emit_marker
(
self
):
pos
=
self
.
last_marked_pos
=
self
.
last_pos
pos
,
trace
=
self
.
last_pos
self
.
last_marked_pos
=
pos
self
.
last_pos
=
None
self
.
last_pos
=
None
self
.
write
(
"
\
n
"
)
self
.
write
(
"
\
n
"
)
self
.
indent
()
self
.
indent
()
self
.
write
(
"/* %s */
\
n
"
%
self
.
_build_marker
(
pos
))
self
.
write
(
"/* %s */
\
n
"
%
self
.
_build_marker
(
pos
))
if
self
.
funcstate
and
self
.
funcstate
.
can_trace
and
self
.
globalstate
.
directives
[
'linetrace'
]:
if
trace
and
self
.
funcstate
and
self
.
funcstate
.
can_trace
and
self
.
globalstate
.
directives
[
'linetrace'
]:
self
.
indent
()
self
.
indent
()
self
.
write
(
'__Pyx_TraceLine(%d,%d,%s)
\
n
'
%
(
self
.
write
(
'__Pyx_TraceLine(%d,%d,%s)
\
n
'
%
(
pos
[
1
],
not
self
.
funcstate
.
gil_owned
,
self
.
error_goto
(
pos
)))
pos
[
1
],
not
self
.
funcstate
.
gil_owned
,
self
.
error_goto
(
pos
)))
...
...
Cython/Compiler/Nodes.py
View file @
d9172bdf
...
@@ -6505,7 +6505,6 @@ class TryExceptStatNode(StatNode):
...
@@ -6505,7 +6505,6 @@ class TryExceptStatNode(StatNode):
gil_message
=
"Try-except statement"
gil_message
=
"Try-except statement"
def
generate_execution_code
(
self
,
code
):
def
generate_execution_code
(
self
,
code
):
code
.
mark_pos
(
self
.
pos
)
old_return_label
=
code
.
return_label
old_return_label
=
code
.
return_label
old_break_label
=
code
.
break_label
old_break_label
=
code
.
break_label
old_continue_label
=
code
.
continue_label
old_continue_label
=
code
.
continue_label
...
@@ -6521,6 +6520,7 @@ class TryExceptStatNode(StatNode):
...
@@ -6521,6 +6520,7 @@ class TryExceptStatNode(StatNode):
exc_save_vars
=
[
code
.
funcstate
.
allocate_temp
(
py_object_type
,
False
)
exc_save_vars
=
[
code
.
funcstate
.
allocate_temp
(
py_object_type
,
False
)
for
_
in
xrange
(
3
)]
for
_
in
xrange
(
3
)]
code
.
mark_pos
(
self
.
pos
)
code
.
putln
(
"{"
)
code
.
putln
(
"{"
)
save_exc
=
code
.
insertion_point
()
save_exc
=
code
.
insertion_point
()
code
.
putln
(
code
.
putln
(
...
@@ -6529,6 +6529,7 @@ class TryExceptStatNode(StatNode):
...
@@ -6529,6 +6529,7 @@ class TryExceptStatNode(StatNode):
code
.
break_label
=
try_break_label
code
.
break_label
=
try_break_label
code
.
continue_label
=
try_continue_label
code
.
continue_label
=
try_continue_label
self
.
body
.
generate_execution_code
(
code
)
self
.
body
.
generate_execution_code
(
code
)
code
.
mark_pos
(
self
.
pos
,
trace
=
False
)
code
.
putln
(
code
.
putln
(
"}"
)
"}"
)
temps_to_clean_up
=
code
.
funcstate
.
all_free_managed_temps
()
temps_to_clean_up
=
code
.
funcstate
.
all_free_managed_temps
()
...
@@ -6559,6 +6560,7 @@ class TryExceptStatNode(StatNode):
...
@@ -6559,6 +6560,7 @@ class TryExceptStatNode(StatNode):
code
.
return_label
=
except_return_label
code
.
return_label
=
except_return_label
normal_case_terminates
=
self
.
body
.
is_terminator
normal_case_terminates
=
self
.
body
.
is_terminator
if
self
.
else_clause
:
if
self
.
else_clause
:
code
.
mark_pos
(
self
.
else_clause
.
pos
)
code
.
putln
(
code
.
putln
(
"/*else:*/ {"
)
"/*else:*/ {"
)
self
.
else_clause
.
generate_execution_code
(
code
)
self
.
else_clause
.
generate_execution_code
(
code
)
...
@@ -6589,6 +6591,7 @@ class TryExceptStatNode(StatNode):
...
@@ -6589,6 +6591,7 @@ class TryExceptStatNode(StatNode):
if
not
normal_case_terminates
and
not
code
.
label_used
(
try_end_label
):
if
not
normal_case_terminates
and
not
code
.
label_used
(
try_end_label
):
code
.
put_goto
(
try_end_label
)
code
.
put_goto
(
try_end_label
)
code
.
put_label
(
exit_label
)
code
.
put_label
(
exit_label
)
code
.
mark_pos
(
self
.
pos
,
trace
=
False
)
restore_saved_exception
()
restore_saved_exception
()
code
.
put_goto
(
old_label
)
code
.
put_goto
(
old_label
)
...
...
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