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
218d5959
Commit
218d5959
authored
Aug 01, 2008
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduced code.globalstate and renamed code.func to code.funcstate
global is a reserved word...
parent
d28ddc7e
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
99 additions
and
89 deletions
+99
-89
Cython/Compiler/Buffer.py
Cython/Compiler/Buffer.py
+6
-6
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+78
-68
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+3
-3
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+3
-3
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+9
-9
No files found.
Cython/Compiler/Buffer.py
View file @
218d5959
...
@@ -209,7 +209,7 @@ def put_assign_to_buffer(lhs_cname, rhs_cname, buffer_aux, buffer_type,
...
@@ -209,7 +209,7 @@ def put_assign_to_buffer(lhs_cname, rhs_cname, buffer_aux, buffer_type,
lhs_cname
,
bufstruct
))
lhs_cname
,
bufstruct
))
code
.
end_block
()
code
.
end_block
()
# Acquire
# Acquire
retcode_cname
=
code
.
func
.
allocate_temp
(
PyrexTypes
.
c_int_type
)
retcode_cname
=
code
.
func
state
.
allocate_temp
(
PyrexTypes
.
c_int_type
)
code
.
putln
(
"%s = %s;"
%
(
retcode_cname
,
getbuffer
%
rhs_cname
))
code
.
putln
(
"%s = %s;"
%
(
retcode_cname
,
getbuffer
%
rhs_cname
))
code
.
putln
(
'if (%s) '
%
(
code
.
unlikely
(
"%s < 0"
%
retcode_cname
)))
code
.
putln
(
'if (%s) '
%
(
code
.
unlikely
(
"%s < 0"
%
retcode_cname
)))
# If acquisition failed, attempt to reacquire the old buffer
# If acquisition failed, attempt to reacquire the old buffer
...
@@ -217,7 +217,7 @@ def put_assign_to_buffer(lhs_cname, rhs_cname, buffer_aux, buffer_type,
...
@@ -217,7 +217,7 @@ def put_assign_to_buffer(lhs_cname, rhs_cname, buffer_aux, buffer_type,
# will cause the reacquisition exception to be reported, one
# will cause the reacquisition exception to be reported, one
# can consider working around this later.
# can consider working around this later.
code
.
begin_block
()
code
.
begin_block
()
type
,
value
,
tb
=
[
code
.
func
.
allocate_temp
(
PyrexTypes
.
py_object_type
)
type
,
value
,
tb
=
[
code
.
func
state
.
allocate_temp
(
PyrexTypes
.
py_object_type
)
for
i
in
range
(
3
)]
for
i
in
range
(
3
)]
code
.
putln
(
'PyErr_Fetch(&%s, &%s, &%s);'
%
(
type
,
value
,
tb
))
code
.
putln
(
'PyErr_Fetch(&%s, &%s, &%s);'
%
(
type
,
value
,
tb
))
code
.
put
(
'if (%s) '
%
code
.
unlikely
(
"%s == -1"
%
(
getbuffer
%
lhs_cname
)))
code
.
put
(
'if (%s) '
%
code
.
unlikely
(
"%s == -1"
%
(
getbuffer
%
lhs_cname
)))
...
@@ -227,13 +227,13 @@ def put_assign_to_buffer(lhs_cname, rhs_cname, buffer_aux, buffer_type,
...
@@ -227,13 +227,13 @@ def put_assign_to_buffer(lhs_cname, rhs_cname, buffer_aux, buffer_type,
code
.
putln
(
'} else {'
)
code
.
putln
(
'} else {'
)
code
.
putln
(
'PyErr_Restore(%s, %s, %s);'
%
(
type
,
value
,
tb
))
code
.
putln
(
'PyErr_Restore(%s, %s, %s);'
%
(
type
,
value
,
tb
))
for
t
in
(
type
,
value
,
tb
):
for
t
in
(
type
,
value
,
tb
):
code
.
func
.
release_temp
(
t
)
code
.
func
state
.
release_temp
(
t
)
code
.
end_block
()
code
.
end_block
()
# Unpack indices
# Unpack indices
code
.
end_block
()
code
.
end_block
()
put_unpack_buffer_aux_into_scope
(
buffer_aux
,
buffer_type
.
mode
,
code
)
put_unpack_buffer_aux_into_scope
(
buffer_aux
,
buffer_type
.
mode
,
code
)
code
.
putln
(
code
.
error_goto_if_neg
(
retcode_cname
,
pos
))
code
.
putln
(
code
.
error_goto_if_neg
(
retcode_cname
,
pos
))
code
.
func
.
release_temp
(
retcode_cname
)
code
.
func
state
.
release_temp
(
retcode_cname
)
else
:
else
:
# Our entry had no previous value, so set to None when acquisition fails.
# Our entry had no previous value, so set to None when acquisition fails.
# In this case, auxiliary vars should be set up right in initialization to a zero-buffer,
# In this case, auxiliary vars should be set up right in initialization to a zero-buffer,
...
@@ -261,7 +261,7 @@ def put_access(entry, index_signeds, index_cnames, pos, code):
...
@@ -261,7 +261,7 @@ def put_access(entry, index_signeds, index_cnames, pos, code):
# Check bounds and fix negative indices
# Check bounds and fix negative indices
boundscheck
=
True
boundscheck
=
True
nonegs
=
True
nonegs
=
True
tmp_cname
=
code
.
func
.
allocate_temp
(
PyrexTypes
.
c_int_type
)
tmp_cname
=
code
.
func
state
.
allocate_temp
(
PyrexTypes
.
c_int_type
)
if
boundscheck
:
if
boundscheck
:
code
.
putln
(
"%s = -1;"
%
tmp_cname
)
code
.
putln
(
"%s = -1;"
%
tmp_cname
)
for
idx
,
(
signed
,
cname
,
shape
)
in
enumerate
(
zip
(
index_signeds
,
index_cnames
,
for
idx
,
(
signed
,
cname
,
shape
)
in
enumerate
(
zip
(
index_signeds
,
index_cnames
,
...
@@ -288,7 +288,7 @@ def put_access(entry, index_signeds, index_cnames, pos, code):
...
@@ -288,7 +288,7 @@ def put_access(entry, index_signeds, index_cnames, pos, code):
code
.
putln
(
'__Pyx_BufferIndexError(%s);'
%
tmp_cname
)
code
.
putln
(
'__Pyx_BufferIndexError(%s);'
%
tmp_cname
)
code
.
putln
(
code
.
error_goto
(
pos
))
code
.
putln
(
code
.
error_goto
(
pos
))
code
.
end_block
()
code
.
end_block
()
code
.
func
.
release_temp
(
tmp_cname
)
code
.
func
state
.
release_temp
(
tmp_cname
)
# Create buffer lookup and return it
# Create buffer lookup and return it
params
=
[]
params
=
[]
...
...
Cython/Compiler/Code.py
View file @
218d5959
This diff is collapsed.
Click to expand it.
Cython/Compiler/ExprNodes.py
View file @
218d5959
...
@@ -1065,7 +1065,7 @@ class NameNode(AtomicExprNode):
...
@@ -1065,7 +1065,7 @@ class NameNode(AtomicExprNode):
rhs
.
generate_post_assignment_code
(
code
)
rhs
.
generate_post_assignment_code
(
code
)
def
generate_acquire_buffer
(
self
,
rhs
,
code
):
def
generate_acquire_buffer
(
self
,
rhs
,
code
):
rhstmp
=
code
.
func
.
allocate_temp
(
self
.
entry
.
type
)
rhstmp
=
code
.
func
state
.
allocate_temp
(
self
.
entry
.
type
)
buffer_aux
=
self
.
entry
.
buffer_aux
buffer_aux
=
self
.
entry
.
buffer_aux
bufstruct
=
buffer_aux
.
buffer_info_var
.
cname
bufstruct
=
buffer_aux
.
buffer_info_var
.
cname
code
.
putln
(
'%s = %s;'
%
(
rhstmp
,
rhs
.
result_as
(
self
.
ctype
())))
code
.
putln
(
'%s = %s;'
%
(
rhstmp
,
rhs
.
result_as
(
self
.
ctype
())))
...
@@ -1075,7 +1075,7 @@ class NameNode(AtomicExprNode):
...
@@ -1075,7 +1075,7 @@ class NameNode(AtomicExprNode):
is_initialized
=
not
self
.
skip_assignment_decref
,
is_initialized
=
not
self
.
skip_assignment_decref
,
pos
=
self
.
pos
,
code
=
code
)
pos
=
self
.
pos
,
code
=
code
)
code
.
putln
(
"%s = 0;"
%
rhstmp
)
code
.
putln
(
"%s = 0;"
%
rhstmp
)
code
.
func
.
release_temp
(
rhstmp
)
code
.
func
state
.
release_temp
(
rhstmp
)
def
generate_deletion_code
(
self
,
code
):
def
generate_deletion_code
(
self
,
code
):
if
self
.
entry
is
None
:
if
self
.
entry
is
None
:
...
@@ -1520,7 +1520,7 @@ class IndexNode(ExprNode):
...
@@ -1520,7 +1520,7 @@ class IndexNode(ExprNode):
def
buffer_access_code
(
self
,
code
):
def
buffer_access_code
(
self
,
code
):
# Assign indices to temps
# Assign indices to temps
index_temps
=
[
code
.
func
.
allocate_temp
(
i
.
type
)
for
i
in
self
.
indices
]
index_temps
=
[
code
.
func
state
.
allocate_temp
(
i
.
type
)
for
i
in
self
.
indices
]
for
temp
,
index
in
zip
(
index_temps
,
self
.
indices
):
for
temp
,
index
in
zip
(
index_temps
,
self
.
indices
):
code
.
putln
(
"%s = %s;"
%
(
temp
,
index
.
result_code
))
code
.
putln
(
"%s = %s;"
%
(
temp
,
index
.
result_code
))
# Generate buffer access code using these temps
# Generate buffer access code using these temps
...
...
Cython/Compiler/ModuleNode.py
View file @
218d5959
...
@@ -529,8 +529,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -529,8 +529,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
def
generate_filename_table
(
self
,
code
):
def
generate_filename_table
(
self
,
code
):
code
.
putln
(
""
)
code
.
putln
(
""
)
code
.
putln
(
"static const char *%s[] = {"
%
Naming
.
filenames_cname
)
code
.
putln
(
"static const char *%s[] = {"
%
Naming
.
filenames_cname
)
if
code
.
filename_list
:
if
code
.
globalstate
.
filename_list
:
for
source_desc
in
code
.
filename_list
:
for
source_desc
in
code
.
globalstate
.
filename_list
:
filename
=
os
.
path
.
basename
(
source_desc
.
get_filenametable_entry
())
filename
=
os
.
path
.
basename
(
source_desc
.
get_filenametable_entry
())
escaped_filename
=
filename
.
replace
(
"
\
\
"
,
"
\
\
\
\
"
).
replace
(
'"'
,
r'\"'
)
escaped_filename
=
filename
.
replace
(
"
\
\
"
,
"
\
\
\
\
"
).
replace
(
'"'
,
r'\"'
)
code
.
putln
(
'"%s",'
%
code
.
putln
(
'"%s",'
%
...
@@ -1610,7 +1610,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -1610,7 +1610,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
putln
(
'}'
)
code
.
putln
(
'}'
)
tempdecl_code
.
put_var_declarations
(
env
.
temp_entries
)
tempdecl_code
.
put_var_declarations
(
env
.
temp_entries
)
tempdecl_code
.
put_temp_declarations
(
code
.
func
)
tempdecl_code
.
put_temp_declarations
(
code
.
func
state
)
code
.
exit_cfunc_scope
()
code
.
exit_cfunc_scope
()
...
...
Cython/Compiler/Nodes.py
View file @
218d5959
...
@@ -969,7 +969,7 @@ class FuncDefNode(StatNode, BlockNode):
...
@@ -969,7 +969,7 @@ class FuncDefNode(StatNode, BlockNode):
code
.
putln
(
"}"
)
code
.
putln
(
"}"
)
# ----- Go back and insert temp variable declarations
# ----- Go back and insert temp variable declarations
tempvardecl_code
.
put_var_declarations
(
lenv
.
temp_entries
)
tempvardecl_code
.
put_var_declarations
(
lenv
.
temp_entries
)
tempvardecl_code
.
put_temp_declarations
(
code
.
func
)
tempvardecl_code
.
put_temp_declarations
(
code
.
func
state
)
# ----- Python version
# ----- Python version
code
.
exit_cfunc_scope
()
code
.
exit_cfunc_scope
()
if
self
.
py_func
:
if
self
.
py_func
:
...
@@ -2634,7 +2634,7 @@ class ContinueStatNode(StatNode):
...
@@ -2634,7 +2634,7 @@ class ContinueStatNode(StatNode):
pass
pass
def
generate_execution_code
(
self
,
code
):
def
generate_execution_code
(
self
,
code
):
if
code
.
in_try_finally
:
if
code
.
funcstate
.
in_try_finally
:
error
(
self
.
pos
,
"continue statement inside try of try...finally"
)
error
(
self
.
pos
,
"continue statement inside try of try...finally"
)
elif
not
code
.
continue_label
:
elif
not
code
.
continue_label
:
error
(
self
.
pos
,
"continue statement not inside loop"
)
error
(
self
.
pos
,
"continue statement not inside loop"
)
...
@@ -2797,7 +2797,7 @@ class ReraiseStatNode(StatNode):
...
@@ -2797,7 +2797,7 @@ class ReraiseStatNode(StatNode):
gil_message
=
"Raising exception"
gil_message
=
"Raising exception"
def
generate_execution_code
(
self
,
code
):
def
generate_execution_code
(
self
,
code
):
vars
=
code
.
exc_vars
vars
=
code
.
funcstate
.
exc_vars
if
vars
:
if
vars
:
code
.
putln
(
"__Pyx_Raise(%s, %s, %s);"
%
tuple
(
vars
))
code
.
putln
(
"__Pyx_Raise(%s, %s, %s);"
%
tuple
(
vars
))
code
.
putln
(
code
.
error_goto
(
self
.
pos
))
code
.
putln
(
code
.
error_goto
(
self
.
pos
))
...
@@ -3478,10 +3478,10 @@ class ExceptClauseNode(Node):
...
@@ -3478,10 +3478,10 @@ class ExceptClauseNode(Node):
self
.
excinfo_tuple
.
generate_evaluation_code
(
code
)
self
.
excinfo_tuple
.
generate_evaluation_code
(
code
)
self
.
excinfo_target
.
generate_assignment_code
(
self
.
excinfo_tuple
,
code
)
self
.
excinfo_target
.
generate_assignment_code
(
self
.
excinfo_tuple
,
code
)
old_exc_vars
=
code
.
exc_vars
old_exc_vars
=
code
.
funcstate
.
exc_vars
code
.
exc_vars
=
self
.
exc_vars
code
.
funcstate
.
exc_vars
=
self
.
exc_vars
self
.
body
.
generate_execution_code
(
code
)
self
.
body
.
generate_execution_code
(
code
)
code
.
exc_vars
=
old_exc_vars
code
.
funcstate
.
exc_vars
=
old_exc_vars
for
var
in
self
.
exc_vars
:
for
var
in
self
.
exc_vars
:
code
.
putln
(
"Py_DECREF(%s); %s = 0;"
%
(
var
,
var
))
code
.
putln
(
"Py_DECREF(%s); %s = 0;"
%
(
var
,
var
))
code
.
put_goto
(
end_label
)
code
.
put_goto
(
end_label
)
...
@@ -3556,11 +3556,11 @@ class TryFinallyStatNode(StatNode):
...
@@ -3556,11 +3556,11 @@ class TryFinallyStatNode(StatNode):
code
.
putln
(
code
.
putln
(
"/*try:*/ {"
)
"/*try:*/ {"
)
if
self
.
disallow_continue_in_try_finally
:
if
self
.
disallow_continue_in_try_finally
:
was_in_try_finally
=
code
.
in_try_finally
was_in_try_finally
=
code
.
funcstate
.
in_try_finally
code
.
in_try_finally
=
1
code
.
funcstate
.
in_try_finally
=
1
self
.
body
.
generate_execution_code
(
code
)
self
.
body
.
generate_execution_code
(
code
)
if
self
.
disallow_continue_in_try_finally
:
if
self
.
disallow_continue_in_try_finally
:
code
.
in_try_finally
=
was_in_try_finally
code
.
funcstate
.
in_try_finally
=
was_in_try_finally
code
.
putln
(
code
.
putln
(
"}"
)
"}"
)
code
.
putln
(
code
.
putln
(
...
...
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