FlowControl.pxd 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. from __future__ import absolute_import
  2. cimport cython
  3. from .Visitor cimport CythonTransform, TreeVisitor
  4. cdef class ControlBlock:
  5. cdef public set children
  6. cdef public set parents
  7. cdef public set positions
  8. cdef public list stats
  9. cdef public dict gen
  10. cdef public set bounded
  11. # Big integer bitsets
  12. cdef public object i_input
  13. cdef public object i_output
  14. cdef public object i_gen
  15. cdef public object i_kill
  16. cdef public object i_state
  17. cpdef bint empty(self)
  18. cpdef detach(self)
  19. cpdef add_child(self, block)
  20. cdef class ExitBlock(ControlBlock):
  21. cpdef bint empty(self)
  22. cdef class NameAssignment:
  23. cdef public bint is_arg
  24. cdef public bint is_deletion
  25. cdef public object lhs
  26. cdef public object rhs
  27. cdef public object entry
  28. cdef public object pos
  29. cdef public set refs
  30. cdef public object bit
  31. cdef public object inferred_type
  32. cdef class AssignmentList:
  33. cdef public object bit
  34. cdef public object mask
  35. cdef public list stats
  36. cdef class AssignmentCollector(TreeVisitor):
  37. cdef list assignments
  38. @cython.final
  39. cdef class ControlFlow:
  40. cdef public set blocks
  41. cdef public set entries
  42. cdef public list loops
  43. cdef public list exceptions
  44. cdef public ControlBlock entry_point
  45. cdef public ExitBlock exit_point
  46. cdef public ControlBlock block
  47. cdef public dict assmts
  48. cpdef newblock(self, ControlBlock parent=*)
  49. cpdef nextblock(self, ControlBlock parent=*)
  50. cpdef bint is_tracked(self, entry)
  51. cpdef bint is_statically_assigned(self, entry)
  52. cpdef mark_position(self, node)
  53. cpdef mark_assignment(self, lhs, rhs, entry)
  54. cpdef mark_argument(self, lhs, rhs, entry)
  55. cpdef mark_deletion(self, node, entry)
  56. cpdef mark_reference(self, node, entry)
  57. @cython.locals(block=ControlBlock, parent=ControlBlock, unreachable=set)
  58. cpdef normalize(self)
  59. @cython.locals(bit=object, assmts=AssignmentList,
  60. block=ControlBlock)
  61. cpdef initialize(self)
  62. @cython.locals(assmts=AssignmentList, assmt=NameAssignment)
  63. cpdef set map_one(self, istate, entry)
  64. @cython.locals(block=ControlBlock, parent=ControlBlock)
  65. cdef reaching_definitions(self)
  66. cdef class Uninitialized:
  67. pass
  68. cdef class Unknown:
  69. pass
  70. cdef class MessageCollection:
  71. cdef set messages
  72. @cython.locals(dirty=bint, block=ControlBlock, parent=ControlBlock,
  73. assmt=NameAssignment)
  74. cdef check_definitions(ControlFlow flow, dict compiler_directives)
  75. @cython.final
  76. cdef class ControlFlowAnalysis(CythonTransform):
  77. cdef object gv_ctx
  78. cdef object constant_folder
  79. cdef set reductions
  80. cdef list env_stack
  81. cdef list stack
  82. cdef object env
  83. cdef ControlFlow flow
  84. cdef bint in_inplace_assignment
  85. cpdef mark_assignment(self, lhs, rhs=*)
  86. cpdef mark_position(self, node)