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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
d2e24522
Commit
d2e24522
authored
Dec 10, 2010
by
Vitja Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move generate parsing,checking and misc code to generate_preamble()
parent
b1d43e46
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
26 deletions
+33
-26
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+33
-26
No files found.
Cython/Compiler/Nodes.py
View file @
d2e24522
...
...
@@ -1357,6 +1357,8 @@ class FuncDefNode(StatNode, BlockNode):
# fatal error before hand, it's not really worth tracing
code
.
put_trace_call
(
self
.
entry
.
name
,
self
.
pos
)
# ----- Fetch arguments
if
not
self
.
is_generator
:
self
.
generate_preamble
(
env
,
code
)
if
self
.
is_generator
:
resume_code
=
code
.
insertion_point
()
first_run_label
=
code
.
new_label
(
'first_run'
)
...
...
@@ -1364,30 +1366,6 @@ class FuncDefNode(StatNode, BlockNode):
code
.
put_label
(
first_run_label
)
code
.
putln
(
'%s'
%
(
code
.
error_goto_if_null
(
Naming
.
sent_value_cname
,
self
.
pos
)))
if
not
self
.
is_generator
:
self
.
generate_argument_parsing_code
(
env
,
code
)
# If an argument is assigned to in the body, we must
# incref it to properly keep track of refcounts.
for
entry
in
lenv
.
arg_entries
:
if
entry
.
type
.
is_pyobject
:
if
entry
.
assignments
and
not
entry
.
in_closure
:
code
.
put_var_incref
(
entry
)
# ----- Initialise local variables
for
entry
in
lenv
.
var_entries
:
if
entry
.
type
.
is_pyobject
and
entry
.
init_to_none
and
entry
.
used
:
code
.
put_init_var_to_py_none
(
entry
)
# ----- Initialise local buffer auxiliary variables
for
entry
in
lenv
.
var_entries
+
lenv
.
arg_entries
:
if
entry
.
type
.
is_buffer
and
entry
.
buffer_aux
.
buffer_info_var
.
used
:
code
.
putln
(
"%s.buf = NULL;"
%
entry
.
buffer_aux
.
buffer_info_var
.
cname
)
# ----- Check and convert arguments
self
.
generate_argument_type_tests
(
code
)
# ----- Acquire buffer arguments
for
entry
in
lenv
.
arg_entries
:
if
entry
.
type
.
is_buffer
:
Buffer
.
put_acquire_arg_buffer
(
entry
,
code
,
self
.
pos
)
# -------------------------
# ----- Function body -----
# -------------------------
...
...
@@ -1545,6 +1523,35 @@ class FuncDefNode(StatNode, BlockNode):
self
.
temp_allocator
.
put_gotref
(
gotref_code
)
self
.
generator
.
generate_function_body
(
self
.
local_scope
,
code
)
def
generate_preamble
(
self
,
env
,
code
):
"""Parse arguments and prepare scope"""
import
Buffer
lenv
=
self
.
local_scope
self
.
generate_argument_parsing_code
(
env
,
code
)
# If an argument is assigned to in the body, we must
# incref it to properly keep track of refcounts.
for
entry
in
lenv
.
arg_entries
:
if
entry
.
type
.
is_pyobject
:
if
entry
.
assignments
and
not
entry
.
in_closure
:
code
.
put_var_incref
(
entry
)
# ----- Initialise local variables
for
entry
in
lenv
.
var_entries
:
if
entry
.
type
.
is_pyobject
and
entry
.
init_to_none
and
entry
.
used
:
code
.
put_init_var_to_py_none
(
entry
)
# ----- Initialise local buffer auxiliary variables
for
entry
in
lenv
.
var_entries
+
lenv
.
arg_entries
:
if
entry
.
type
.
is_buffer
and
entry
.
buffer_aux
.
buffer_info_var
.
used
:
code
.
putln
(
"%s.buf = NULL;"
%
entry
.
buffer_aux
.
buffer_info_var
.
cname
)
# ----- Check and convert arguments
self
.
generate_argument_type_tests
(
code
)
# ----- Acquire buffer arguments
for
entry
in
lenv
.
arg_entries
:
if
entry
.
type
.
is_buffer
:
Buffer
.
put_acquire_arg_buffer
(
entry
,
code
,
self
.
pos
)
def
declare_argument
(
self
,
env
,
arg
):
if
arg
.
type
.
is_void
:
error
(
arg
.
pos
,
"Invalid use of 'void'"
)
...
...
@@ -1935,7 +1942,7 @@ class GeneratorWrapperNode(object):
Naming
.
self_cname
))
code
.
put_incref
(
outer_scope_cname
,
cenv
.
scope_class
.
type
)
self
.
def_node
.
generate_
argument_parsing_cod
e
(
env
,
code
)
self
.
def_node
.
generate_
preambl
e
(
env
,
code
)
generator_cname
=
'%s->%s'
%
(
Naming
.
cur_scope_cname
,
Naming
.
obj_base_cname
)
...
...
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