Generate tables containing descriptions of Python literals to construct. We will store the constructed literals in a single array that contains literals of all types. This way we can refer to an arbitrary literal by its index.
(self)
| 798 | ] |
| 799 | |
| 800 | def generate_literal_tables(self) -> None: |
| 801 | """Generate tables containing descriptions of Python literals to construct. |
| 802 | |
| 803 | We will store the constructed literals in a single array that contains |
| 804 | literals of all types. This way we can refer to an arbitrary literal by |
| 805 | its index. |
| 806 | """ |
| 807 | literals = self.context.literals |
| 808 | # During module initialization we store all the constructed objects here |
| 809 | self.declare_global("PyObject *[%d]" % literals.num_literals(), "CPyStatics") |
| 810 | # Descriptions of str literals |
| 811 | init_str = c_string_array_initializer(literals.encoded_str_values()) |
| 812 | self.declare_global("const char * const []", "CPyLit_Str", initializer=init_str) |
| 813 | # Descriptions of bytes literals |
| 814 | init_bytes = c_string_array_initializer(literals.encoded_bytes_values()) |
| 815 | self.declare_global("const char * const []", "CPyLit_Bytes", initializer=init_bytes) |
| 816 | # Descriptions of int literals |
| 817 | init_int = c_string_array_initializer(literals.encoded_int_values()) |
| 818 | self.declare_global("const char * const []", "CPyLit_Int", initializer=init_int) |
| 819 | # Descriptions of float literals |
| 820 | init_floats = c_array_initializer(literals.encoded_float_values()) |
| 821 | self.declare_global("const double []", "CPyLit_Float", initializer=init_floats) |
| 822 | # Descriptions of complex literals |
| 823 | init_complex = c_array_initializer(literals.encoded_complex_values()) |
| 824 | self.declare_global("const double []", "CPyLit_Complex", initializer=init_complex) |
| 825 | # Descriptions of tuple literals |
| 826 | init_tuple = c_array_initializer(literals.encoded_tuple_values()) |
| 827 | self.declare_global("const int []", "CPyLit_Tuple", initializer=init_tuple) |
| 828 | # Descriptions of frozenset literals |
| 829 | init_frozenset = c_array_initializer(literals.encoded_frozenset_values()) |
| 830 | self.declare_global("const int []", "CPyLit_FrozenSet", initializer=init_frozenset) |
| 831 | |
| 832 | def generate_export_table(self, decl_emitter: Emitter, code_emitter: Emitter) -> None: |
| 833 | """Generate the declaration and definition of the group's export struct. |
no test coverage detected