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
cd6fb6ad
Commit
cd6fb6ad
authored
Aug 03, 2008
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved cached builtin init to Code.py for consistency
parent
d65fd747
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
26 deletions
+32
-26
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+28
-6
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+4
-20
No files found.
Cython/Compiler/Code.py
View file @
cd6fb6ad
...
...
@@ -168,8 +168,13 @@ class GlobalState(object):
self
.
utildefwriter
=
rootwriter
.
new_writer
()
self
.
decls_writer
=
rootwriter
.
new_writer
()
self
.
pystring_table
=
rootwriter
.
new_writer
()
self
.
init_cached_builtins_writer
=
rootwriter
.
new_writer
()
self
.
initwriter
=
rootwriter
.
new_writer
()
if
Options
.
cache_builtins
:
self
.
init_cached_builtins_writer
.
enter_cfunc_scope
()
self
.
init_cached_builtins_writer
.
putln
(
"static int __Pyx_InitCachedBuiltins(void) {"
)
self
.
initwriter
.
enter_cfunc_scope
()
self
.
initwriter
.
putln
(
""
).
putln
(
"static int __Pyx_InitGlobals(void) {"
)
...
...
@@ -197,19 +202,28 @@ class GlobalState(object):
Naming
.
stringtab_cname
,
self
.
initwriter
.
error_goto
(
self
.
module_pos
)))
if
Options
.
cache_builtins
:
(
self
.
init_cached_builtins_writer
.
putln
(
"return 0;"
)
.
put_label
(
self
.
init_cached_builtins_writer
.
error_label
)
.
putln
(
"return -1;"
)
.
putln
(
"}"
)
.
exit_cfunc_scope
()
)
(
self
.
initwriter
.
putln
(
"return 0;"
)
.
put_label
(
self
.
initwriter
.
error_label
)
.
putln
(
"return -1;"
)
.
putln
(
"}"
)
.
exit_cfunc_scope
()
)
self
.
initwriter
.
exit_cfunc_scope
()
def
insert_
py_string_tabl
e_into
(
self
,
code
):
def
insert_
initcod
e_into
(
self
,
code
):
if
self
.
pystring_table_needed
:
code
.
insert
(
self
.
pystring_table
)
def
insert_initglobals_into
(
self
,
code
):
if
Options
.
cache_builtins
:
code
.
insert
(
self
.
init_cached_builtins_writer
)
code
.
insert
(
self
.
initwriter
)
def
put_pyobject_decl
(
self
,
entry
):
...
...
@@ -268,8 +282,16 @@ class GlobalState(object):
self
.
put_pyobject_decl
(
entry
)
def
add_cached_builtin_decl
(
self
,
entry
):
if
self
.
should_declare
(
entry
.
cname
,
entry
):
self
.
put_pyobject_decl
(
entry
)
if
Options
.
cache_builtins
:
if
self
.
should_declare
(
entry
.
cname
,
entry
):
self
.
put_pyobject_decl
(
entry
)
self
.
init_cached_builtins_writer
.
putln
(
'%s = __Pyx_GetName(%s, %s); if (!%s) %s'
%
(
entry
.
cname
,
Naming
.
builtins_cname
,
entry
.
interned_cname
,
entry
.
cname
,
self
.
init_cached_builtins_writer
.
error_goto
(
entry
.
pos
)))
#
# File name state
...
...
Cython/Compiler/ModuleNode.py
View file @
cd6fb6ad
...
...
@@ -256,7 +256,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
self
.
generate_cached_builtins_decls
(
env
,
code
)
self
.
body
.
generate_function_definitions
(
env
,
code
,
options
.
transforms
)
code
.
mark_pos
(
None
)
self
.
generate_py_string_table
(
env
,
code
)
self
.
generate_typeobj_definitions
(
env
,
code
)
self
.
generate_method_table
(
env
,
code
)
self
.
generate_filename_init_prototype
(
code
)
...
...
@@ -1456,9 +1455,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
putln
(
"};"
)
def
generate_py_string_table
(
self
,
env
,
code
):
code
.
globalstate
.
insert_py_string_table_into
(
code
)
def
generate_filename_init_prototype
(
self
,
code
):
code
.
putln
(
""
);
code
.
putln
(
"static void %s(void); /*proto*/"
%
Naming
.
fileinit_cname
)
...
...
@@ -1527,7 +1523,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
def
generate_module_init_func
(
self
,
imported_modules
,
env
,
code
):
# Insert code stream of __Pyx_InitGlobals
code
.
globalstate
.
insert_init
globals
_into
(
code
)
code
.
globalstate
.
insert_init
code
_into
(
code
)
code
.
enter_cfunc_scope
()
code
.
putln
(
""
)
...
...
@@ -1556,8 +1552,9 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
if
Options
.
cache_builtins
:
code
.
putln
(
"/*--- Builtin init code ---*/"
)
self
.
generate_builtin_init_code
(
env
,
code
)
code
.
putln
(
code
.
error_goto_if_neg
(
"__Pyx_InitCachedBuiltins()"
,
self
.
pos
))
code
.
putln
(
"%s = 0;"
%
Naming
.
skip_dispatch_cname
);
code
.
putln
(
"/*--- Global init code ---*/"
)
...
...
@@ -1714,19 +1711,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
Naming
.
preimport_cname
,
code
.
error_goto
(
self
.
pos
)));
def
generate_builtin_init_code
(
self
,
env
,
code
):
# Lookup and cache builtin objects.
if
Options
.
cache_builtins
:
for
entry
in
env
.
cached_builtins
:
#assert entry.interned_cname is not None
code
.
putln
(
'%s = __Pyx_GetName(%s, %s); if (!%s) %s'
%
(
entry
.
cname
,
Naming
.
builtins_cname
,
entry
.
interned_cname
,
entry
.
cname
,
code
.
error_goto
(
entry
.
pos
)))
def
generate_global_init_code
(
self
,
env
,
code
):
# Generate code to initialise global PyObject *
# variables to None.
...
...
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