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
c6ecb09c
Commit
c6ecb09c
authored
Dec 09, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
compile Code.py
parent
9271133a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
91 additions
and
12 deletions
+91
-12
Cython/Compiler/Code.pxd
Cython/Compiler/Code.pxd
+72
-0
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+18
-12
setup.py
setup.py
+1
-0
No files found.
Cython/Compiler/Code.pxd
0 → 100644
View file @
c6ecb09c
cdef
class
UtilityCode
:
cdef
public
object
proto
cdef
public
object
impl
cdef
public
object
init
cdef
public
object
cleanup
cdef
public
object
requires
cdef
public
dict
_cache
cdef
public
list
specialize_list
cdef
public
object
proto_block
cpdef
put_code
(
self
,
dict
output
)
cdef
class
FunctionState
:
cdef
public
set
names_taken
cdef
public
object
owner
cdef
public
object
error_label
cdef
public
Py_ssize_t
label_counter
cdef
public
set
labels_used
cdef
public
object
return_label
cdef
public
object
continue_label
cdef
public
object
break_label
cdef
public
object
return_from_error_cleanup_label
# not used in __init__ ?
cdef
public
bint
in_try_finally
cdef
public
object
exc_vars
cdef
public
list
temps_allocated
cdef
public
dict
temps_free
cdef
public
dict
temps_used_type
cdef
public
Py_ssize_t
temp_counter
cpdef
tuple
get_loop_labels
(
self
)
cpdef
set_loop_labels
(
self
,
labels
)
cpdef
tuple
get_all_labels
(
self
)
cpdef
set_all_labels
(
self
,
labels
)
cpdef
list
temps_in_use
(
self
)
cdef
class
IntConst
:
cdef
public
object
cname
cdef
public
object
value
cdef
public
bint
is_long
cdef
class
PyObjectConst
:
cdef
public
object
cname
cdef
public
object
type
cdef
class
StringConst
:
cdef
public
object
cname
cdef
public
object
text
cdef
public
object
escaped_value
cdef
public
dict
py_strings
## cdef class PyStringConst:
## cdef public object cname
## cdef public object encoding
## cdef public bint is_str
## cdef public bint is_unicode
## cdef public bint intern
#class GlobalState(object):
#def funccontext_property(name):
#class CCodeWriter(object):
cdef
class
PyrexCodeWriter
:
cdef
public
object
f
cdef
public
Py_ssize_t
level
Cython/Compiler/Code.py
View file @
c6ecb09c
# cython: language_level = 3
#
#
# Pyrex - Code output module
# Pyrex - Code output module
#
#
import
cython
cython
.
declare
(
re
=
object
,
Naming
=
object
,
Options
=
object
,
StringEncoding
=
object
,
Utils
=
object
,
SourceDescriptor
=
object
,
StringIOTree
=
object
,
DebugFlags
=
object
,
none_or_sub
=
object
)
import
re
import
re
import
Naming
import
Naming
import
Options
import
Options
...
@@ -9,13 +15,13 @@ import StringEncoding
...
@@ -9,13 +15,13 @@ import StringEncoding
from
Cython
import
Utils
from
Cython
import
Utils
from
Scanning
import
SourceDescriptor
from
Scanning
import
SourceDescriptor
from
Cython.StringIOTree
import
StringIOTree
from
Cython.StringIOTree
import
StringIOTree
try
:
set
except
NameError
:
from
sets
import
Set
as
set
import
DebugFlags
import
DebugFlags
from
Cython.Utils
import
none_or_sub
from
Cython.Utils
import
none_or_sub
try
:
basestring
except
NameError
:
basestring
=
str
class
UtilityCode
(
object
):
class
UtilityCode
(
object
):
# Stores utility code to add during code generation.
# Stores utility code to add during code generation.
...
@@ -92,13 +98,13 @@ class FunctionState(object):
...
@@ -92,13 +98,13 @@ class FunctionState(object):
# exc_vars (string * 3) exception variables for reraise, or None
# exc_vars (string * 3) exception variables for reraise, or None
# Not used for now, perhaps later
# Not used for now, perhaps later
def
__init__
(
self
,
owner
,
names_taken
=
set
()):
def
__init__
(
self
,
owner
,
names_taken
=
cython
.
set
()):
self
.
names_taken
=
names_taken
self
.
names_taken
=
names_taken
self
.
owner
=
owner
self
.
owner
=
owner
self
.
error_label
=
None
self
.
error_label
=
None
self
.
label_counter
=
0
self
.
label_counter
=
0
self
.
labels_used
=
{}
self
.
labels_used
=
cython
.
set
()
self
.
return_label
=
self
.
new_label
()
self
.
return_label
=
self
.
new_label
()
self
.
new_error_label
()
self
.
new_error_label
()
self
.
continue_label
=
None
self
.
continue_label
=
None
...
@@ -168,7 +174,7 @@ class FunctionState(object):
...
@@ -168,7 +174,7 @@ class FunctionState(object):
return
old_labels
return
old_labels
def
use_label
(
self
,
lbl
):
def
use_label
(
self
,
lbl
):
self
.
labels_used
[
lbl
]
=
1
self
.
labels_used
.
add
(
lbl
)
def
label_used
(
self
,
lbl
):
def
label_used
(
self
,
lbl
):
return
lbl
in
self
.
labels_used
return
lbl
in
self
.
labels_used
...
@@ -260,7 +266,7 @@ class FunctionState(object):
...
@@ -260,7 +266,7 @@ class FunctionState(object):
error case.
error case.
"""
"""
return
[(
cname
,
type
)
return
[(
cname
,
type
)
for
(
type
,
manage_ref
),
freelist
in
self
.
temps_free
.
ite
rite
ms
()
for
(
type
,
manage_ref
),
freelist
in
self
.
temps_free
.
items
()
if
manage_ref
if
manage_ref
for
cname
in
freelist
]
for
cname
in
freelist
]
...
@@ -436,7 +442,7 @@ class GlobalState(object):
...
@@ -436,7 +442,7 @@ class GlobalState(object):
self.filename_table = {}
self.filename_table = {}
self.filename_list = []
self.filename_list = []
self.input_file_contents = {}
self.input_file_contents = {}
self.utility_codes = set()
self.utility_codes =
cython.
set()
self.declared_cnames = {}
self.declared_cnames = {}
self.in_utility_code_generation = False
self.in_utility_code_generation = False
self.emit_linenums = emit_linenums
self.emit_linenums = emit_linenums
...
@@ -683,7 +689,7 @@ class GlobalState(object):
...
@@ -683,7 +689,7 @@ class GlobalState(object):
def generate_string_constants(self):
def generate_string_constants(self):
c_consts = [ (len(c.cname), c.cname, c)
c_consts = [ (len(c.cname), c.cname, c)
for c in self.string_const_index.
iter
values() ]
for c in self.string_const_index.values() ]
c_consts.sort()
c_consts.sort()
py_strings = []
py_strings = []
...
@@ -692,7 +698,7 @@ class GlobalState(object):
...
@@ -692,7 +698,7 @@ class GlobalState(object):
decls_writer.putln('static char %s[] = "
%
s
";' % (
decls_writer.putln('static char %s[] = "
%
s
";' % (
cname, StringEncoding.split_string_literal(c.escaped_value)))
cname, StringEncoding.split_string_literal(c.escaped_value)))
if c.py_strings is not None:
if c.py_strings is not None:
for py_string in c.py_strings.
iter
values():
for py_string in c.py_strings.values():
py_strings.append((c.cname, len(py_string.cname), py_string))
py_strings.append((c.cname, len(py_string.cname), py_string))
if py_strings:
if py_strings:
...
@@ -735,7 +741,7 @@ class GlobalState(object):
...
@@ -735,7 +741,7 @@ class GlobalState(object):
def generate_int_constants(self):
def generate_int_constants(self):
consts = [ (len(c.value), c.value, c.is_long, c)
consts = [ (len(c.value), c.value, c.is_long, c)
for c in self.int_const_index.
iter
values() ]
for c in self.int_const_index.values() ]
consts.sort()
consts.sort()
decls_writer = self.parts['decls']
decls_writer = self.parts['decls']
for _, value, longness, c in consts:
for _, value, longness, c in consts:
...
...
setup.py
View file @
c6ecb09c
...
@@ -92,6 +92,7 @@ def compile_cython_modules(profile=False, compile_more=False, cython_with_refnan
...
@@ -92,6 +92,7 @@ def compile_cython_modules(profile=False, compile_more=False, cython_with_refnan
"Cython.Compiler.Scanning"
,
"Cython.Compiler.Scanning"
,
"Cython.Compiler.Parsing"
,
"Cython.Compiler.Parsing"
,
"Cython.Compiler.Visitor"
,
"Cython.Compiler.Visitor"
,
"Cython.Compiler.Code"
,
"Cython.Runtime.refnanny"
]
"Cython.Runtime.refnanny"
]
if
compile_more
:
if
compile_more
:
compiled_modules
.
extend
([
compiled_modules
.
extend
([
...
...
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