Commit c6ecb09c authored by Stefan Behnel's avatar Stefan Behnel

compile Code.py

parent 9271133a
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: 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.iteritems() 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.itervalues() ] 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.itervalues(): 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.itervalues() ] 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:
......
...@@ -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([
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment