Emit code to deallocate object by putting it to per-type free list. The free "list" currently can have up to one object.
(cl: ClassIR, emitter: Emitter)
| 972 | |
| 973 | |
| 974 | def emit_reuse_dealloc(cl: ClassIR, emitter: Emitter) -> None: |
| 975 | """Emit code to deallocate object by putting it to per-type free list. |
| 976 | |
| 977 | The free "list" currently can have up to one object. |
| 978 | """ |
| 979 | prefix = cl.name_prefix(emitter.names) |
| 980 | emitter.emit_line(f"if ({prefix}_free_instance == NULL) {{") |
| 981 | emitter.emit_line(f"{prefix}_free_instance = self;") |
| 982 | |
| 983 | # Clear attributes and free referenced objects. |
| 984 | |
| 985 | emit_clear_bitmaps(cl, emitter) |
| 986 | |
| 987 | for base in reversed(cl.base_mro): |
| 988 | for attr, rtype in base.attributes.items(): |
| 989 | emitter.emit_reuse_clear(f"self->{emitter.attr(attr)}", rtype) |
| 990 | |
| 991 | emitter.emit_line("return;") |
| 992 | emitter.emit_line("}") |
| 993 | |
| 994 | |
| 995 | def generate_finalize_for_class( |
no test coverage detected
searching dependent graphs…