summaryrefslogtreecommitdiff
path: root/Cython/Compiler/Code.pxd
blob: acad0c1cf44cc6bfebf14da5d1bbfee7985c94c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124

from __future__ import absolute_import

cimport cython
from ..StringIOTree cimport StringIOTree


cdef class UtilityCodeBase(object):
    cpdef format_code(self, code_string, replace_empty_lines=*)


cdef class UtilityCode(UtilityCodeBase):
    cdef public object name
    cdef public object proto
    cdef public object impl
    cdef public object init
    cdef public object cleanup
    cdef public object proto_block
    cdef public object requires
    cdef public dict _cache
    cdef public list specialize_list
    cdef public object file

    cpdef none_or_sub(self, s, context)


cdef class FunctionState:
    cdef public set names_taken
    cdef public object owner
    cdef public object scope

    cdef public object error_label
    cdef public size_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 list yield_labels

    cdef public object return_from_error_cleanup_label # not used in __init__ ?

    cdef public object exc_vars
    cdef public object current_except
    cdef public bint in_try_finally
    cdef public bint can_trace
    cdef public bint gil_owned

    cdef public list temps_allocated
    cdef public dict temps_free
    cdef public dict temps_used_type
    cdef public set zombie_temps
    cdef public size_t temp_counter
    cdef public list collect_temps_stack

    cdef public object closure_temps
    cdef public bint should_declare_error_indicator
    cdef public bint uses_error_indicator

    @cython.locals(n=size_t)
    cpdef new_label(self, name=*)
    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 start_collecting_temps(self)
    cpdef stop_collecting_temps(self)

    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 public list py_versions

    @cython.locals(intern=bint, is_str=bint, is_unicode=bint)
    cpdef get_py_string_const(self, encoding, identifier=*, is_str=*, py3str_cstring=*)

## 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):

cdef class CCodeWriter(object):
    cdef readonly StringIOTree buffer
    cdef readonly list pyclass_stack
    cdef readonly object globalstate
    cdef readonly object funcstate
    cdef object code_config
    cdef object last_pos
    cdef object last_marked_pos
    cdef Py_ssize_t level
    cdef public Py_ssize_t call_level  # debug-only, see Nodes.py
    cdef bint bol

    cpdef write(self, s)
    cpdef put(self, code)
    cpdef put_safe(self, code)
    cpdef putln(self, code=*, bint safe=*)
    @cython.final
    cdef increase_indent(self)
    @cython.final
    cdef decrease_indent(self)


cdef class PyrexCodeWriter:
    cdef public object f
    cdef public Py_ssize_t level