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
ca688476
Commit
ca688476
authored
Dec 12, 2018
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '0.29.x'
parents
62b6ba0f
cfa02c27
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
16 deletions
+28
-16
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+9
-3
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+19
-13
No files found.
Cython/Compiler/Code.py
View file @
ca688476
...
...
@@ -1133,6 +1133,7 @@ class GlobalState(object):
self.num_const_index = {}
self.py_constants = []
self.cached_cmethods = {}
self.initialised_constants = set()
writer.set_global_state(self)
self.rootwriter = writer
...
...
@@ -1242,7 +1243,12 @@ class GlobalState(object):
# constant handling at code generation time
def
get_cached_constants_writer
(
self
):
def
get_cached_constants_writer
(
self
,
target
=
None
):
if
target
is
not
None
:
if
target
in
self
.
initialised_constants
:
# Return None on second/later calls to prevent duplicate creation code.
return
None
self
.
initialised_constants
.
add
(
target
)
return
self
.
parts
[
'cached_constants'
]
def
get_int_const
(
self
,
str_value
,
longness
=
False
):
...
...
@@ -1816,8 +1822,8 @@ class CCodeWriter(object):
def
intern_identifier
(
self
,
text
):
return
self
.
get_py_string_const
(
text
,
identifier
=
True
)
def
get_cached_constants_writer
(
self
):
return
self
.
globalstate
.
get_cached_constants_writer
()
def
get_cached_constants_writer
(
self
,
target
=
None
):
return
self
.
globalstate
.
get_cached_constants_writer
(
target
)
# code generation
...
...
Cython/Compiler/ExprNodes.py
View file @
ca688476
...
...
@@ -1621,15 +1621,17 @@ class UnicodeNode(ConstNode):
# decoded by the UTF-8 codec in Py3.3
self
.
result_code
=
code
.
get_py_const
(
py_object_type
,
'ustring'
)
data_cname
=
code
.
get_pyunicode_ptr_const
(
self
.
value
)
code
=
code
.
get_cached_constants_writer
()
code
.
mark_pos
(
self
.
pos
)
code
.
putln
(
const_code
=
code
.
get_cached_constants_writer
(
self
.
result_code
)
if
const_code
is
None
:
return
# already initialised
const_code
.
mark_pos
(
self
.
pos
)
const_code
.
putln
(
"%s = PyUnicode_FromUnicode(%s, (sizeof(%s) / sizeof(Py_UNICODE))-1); %s"
%
(
self
.
result_code
,
data_cname
,
data_cname
,
code
.
error_goto_if_null
(
self
.
result_code
,
self
.
pos
)))
code
.
put_error_if_neg
(
co
nst_co
de
.
put_error_if_neg
(
self
.
pos
,
"__Pyx_PyUnicode_READY(%s)"
%
self
.
result_code
)
else
:
self
.
result_code
=
code
.
get_py_string_const
(
self
.
value
)
...
...
@@ -5253,7 +5255,9 @@ class SliceNode(ExprNode):
if
self
.
is_literal
:
dedup_key
=
make_dedup_key
(
self
.
type
,
(
self
,))
self
.
result_code
=
code
.
get_py_const
(
py_object_type
,
'slice'
,
cleanup_level
=
2
,
dedup_key
=
dedup_key
)
code
=
code
.
get_cached_constants_writer
()
code
=
code
.
get_cached_constants_writer
(
self
.
result_code
)
if
code
is
None
:
return
# already initialised
code
.
mark_pos
(
self
.
pos
)
code
.
putln
(
...
...
@@ -7988,14 +7992,14 @@ class TupleNode(SequenceNode):
return
if
self
.
is_literal
or
self
.
is_partly_literal
:
dedup_key
=
None
if
self
.
is_literal
:
dedup_key
=
make_dedup_key
(
self
.
type
,
self
.
args
)
dedup_key
=
make_dedup_key
(
self
.
type
,
self
.
args
)
if
self
.
is_literal
else
None
tuple_target
=
code
.
get_py_const
(
py_object_type
,
'tuple'
,
cleanup_level
=
2
,
dedup_key
=
dedup_key
)
const_code
=
code
.
get_cached_constants_writer
()
const_code
.
mark_pos
(
self
.
pos
)
self
.
generate_sequence_packing_code
(
const_code
,
tuple_target
,
plain
=
not
self
.
is_literal
)
const_code
.
put_giveref
(
tuple_target
)
const_code
=
code
.
get_cached_constants_writer
(
tuple_target
)
if
const_code
is
not
None
:
# constant is not yet initialised
const_code
.
mark_pos
(
self
.
pos
)
self
.
generate_sequence_packing_code
(
const_code
,
tuple_target
,
plain
=
not
self
.
is_literal
)
const_code
.
put_giveref
(
tuple_target
)
if
self
.
is_literal
:
self
.
result_code
=
tuple_target
else
:
...
...
@@ -9511,7 +9515,9 @@ class CodeObjectNode(ExprNode):
if
self
.
result_code
is
None
:
self
.
result_code
=
code
.
get_py_const
(
py_object_type
,
'codeobj'
,
cleanup_level
=
2
)
code
=
code
.
get_cached_constants_writer
()
code
=
code
.
get_cached_constants_writer
(
self
.
result_code
)
if
code
is
None
:
return
# already initialised
code
.
mark_pos
(
self
.
pos
)
func
=
self
.
def_node
func_name
=
code
.
get_py_string_const
(
...
...
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