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
c815cb28
Commit
c815cb28
authored
Aug 01, 2015
by
Ian Henriksen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Basic exception handling for assignment operations.
parent
e44e1bfc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
10 deletions
+36
-10
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+21
-8
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+15
-2
No files found.
Cython/Compiler/ExprNodes.py
View file @
c815cb28
...
...
@@ -716,7 +716,8 @@ class ExprNode(Node):
else
:
self
.
generate_subexpr_disposal_code
(
code
)
def
generate_assignment_code
(
self
,
rhs
,
code
,
overloaded_assignment
=
False
):
def
generate_assignment_code
(
self
,
rhs
,
code
,
overloaded_assignment
=
False
,
exception_check
=
None
,
exception_value
=
None
):
# Stub method for nodes which are not legal as
# the LHS of an assignment. An error will have
# been reported earlier.
...
...
@@ -2039,7 +2040,8 @@ class NameNode(AtomicExprNode):
if
null_code
and
raise_unbound
and
(
entry
.
type
.
is_pyobject
or
memslice_check
):
code
.
put_error_if_unbound
(
self
.
pos
,
entry
,
self
.
in_nogil_context
)
def
generate_assignment_code
(
self
,
rhs
,
code
,
overloaded_assignment
=
False
):
def
generate_assignment_code
(
self
,
rhs
,
code
,
overloaded_assignment
=
False
,
exception_check
=
None
,
exception_value
=
None
):
#print "NameNode.generate_assignment_code:", self.name ###
entry
=
self
.
entry
if
entry
is
None
:
...
...
@@ -2129,8 +2131,15 @@ class NameNode(AtomicExprNode):
code
.
put_giveref
(
rhs
.
py_result
())
if
not
self
.
type
.
is_memoryviewslice
:
if
not
assigned
:
result
=
rhs
.
result
()
if
overloaded_assignment
else
rhs
.
result_as
(
self
.
ctype
())
code
.
putln
(
'%s = %s;'
%
(
self
.
result
(),
result
))
if
overloaded_assignment
:
result
=
rhs
.
result
()
if
exception_check
==
'+'
:
translate_cpp_exception
(
code
,
self
.
pos
,
'%s = %s;'
%
(
self
.
result
(),
result
),
exception_value
,
self
.
in_nogil_context
)
else
:
code
.
putln
(
'%s = %s;'
%
(
self
.
result
(),
result
))
else
:
result
=
rhs
.
result_as
(
self
.
ctype
())
code
.
putln
(
'%s = %s;'
%
(
self
.
result
(),
result
))
if
debug_disposal_code
:
print
(
"NameNode.generate_assignment_code:"
)
print
(
"...generating post-assignment code for %s"
%
rhs
)
...
...
@@ -3600,7 +3609,8 @@ class IndexNode(_IndexingBaseNode):
self
.
extra_index_params
(
code
),
code
.
error_goto
(
self
.
pos
)))
def
generate_assignment_code
(
self
,
rhs
,
code
,
overloaded_assignment
=
False
):
def
generate_assignment_code
(
self
,
rhs
,
code
,
overloaded_assignment
=
False
,
exception_check
=
None
,
exception_value
=
None
):
self
.
generate_subexpr_evaluation_code
(
code
)
if
self
.
type
.
is_pyobject
:
...
...
@@ -4422,7 +4432,8 @@ class SliceIndexNode(ExprNode):
code
.
error_goto_if_null
(
result
,
self
.
pos
)))
code
.
put_gotref
(
self
.
py_result
())
def
generate_assignment_code
(
self
,
rhs
,
code
,
overloaded_assignment
=
False
):
def
generate_assignment_code
(
self
,
rhs
,
code
,
overloaded_assignment
=
False
,
exception_check
=
None
,
exception_value
=
None
):
self
.
generate_subexpr_evaluation_code
(
code
)
if
self
.
type
.
is_pyobject
:
code
.
globalstate
.
use_utility_code
(
self
.
set_slice_utility_code
)
...
...
@@ -6374,7 +6385,8 @@ class AttributeNode(ExprNode):
else
:
ExprNode
.
generate_disposal_code
(
self
,
code
)
def
generate_assignment_code
(
self
,
rhs
,
code
,
overloaded_assignment
=
False
):
def
generate_assignment_code
(
self
,
rhs
,
code
,
overloaded_assignment
=
False
,
exception_check
=
None
,
exception_value
=
None
):
self
.
obj
.
generate_evaluation_code
(
code
)
if
self
.
is_py_attr
:
code
.
globalstate
.
use_utility_code
(
...
...
@@ -6711,7 +6723,8 @@ class SequenceNode(ExprNode):
if
self
.
mult_factor
:
self
.
mult_factor
.
generate_disposal_code
(
code
)
def
generate_assignment_code
(
self
,
rhs
,
code
,
overloaded_assignment
=
False
):
def
generate_assignment_code
(
self
,
rhs
,
code
,
overloaded_assignment
=
False
,
exception_check
=
None
,
exception_value
=
None
):
if
self
.
starred_assignment
:
self
.
generate_starred_assignment_code
(
rhs
,
code
)
else
:
...
...
Cython/Compiler/Nodes.py
View file @
c815cb28
...
...
@@ -4797,6 +4797,8 @@ class SingleAssignmentNode(AssignmentNode):
# rhs ExprNode Right hand side
# first bool Is this guaranteed the first assignment to lhs?
# is_overloaded_assignment bool Is this assignment done via an overloaded operator=
# exception_check
# exception_value
child_attrs
=
[
"lhs"
,
"rhs"
]
first
=
False
...
...
@@ -4910,6 +4912,10 @@ class SingleAssignmentNode(AssignmentNode):
if
op
:
rhs
=
self
.
rhs
self
.
is_overloaded_assignment
=
True
self
.
exception_check
=
op
.
type
.
exception_check
self
.
exception_value
=
op
.
type
.
exception_value
if
self
.
exception_check
==
'+'
and
self
.
exception_value
is
None
:
env
.
use_utility_code
(
UtilityCode
.
load_cached
(
"CppExceptionConversion"
,
"CppSupport.cpp"
))
else
:
rhs
=
self
.
rhs
.
coerce_to
(
self
.
lhs
.
type
,
env
)
else
:
...
...
@@ -5062,8 +5068,15 @@ class SingleAssignmentNode(AssignmentNode):
self
.
rhs
.
generate_evaluation_code
(
code
)
def
generate_assignment_code
(
self
,
code
,
overloaded_assignment
=
False
):
self
.
lhs
.
generate_assignment_code
(
self
.
rhs
,
code
,
overloaded_assignment
=
self
.
is_overloaded_assignment
)
if
self
.
is_overloaded_assignment
:
self
.
lhs
.
generate_assignment_code
(
self
.
rhs
,
code
,
overloaded_assignment
=
self
.
is_overloaded_assignment
,
exception_check
=
self
.
exception_check
,
exception_value
=
self
.
exception_value
)
else
:
self
.
lhs
.
generate_assignment_code
(
self
.
rhs
,
code
)
def
generate_function_definitions
(
self
,
env
,
code
):
self
.
rhs
.
generate_function_definitions
(
env
,
code
)
...
...
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