MCPcopy Index your code
hub / github.com/python/mypy / _emit_attr_bitmap_update

Method _emit_attr_bitmap_update

mypyc/codegen/emit.py:464–478  ·  view source on GitHub ↗
(
        self, value: str, obj: str, rtype: RType, cl: ClassIR, attr: str, clear: bool
    )

Source from the content-addressed store, hash-verified

462 self._emit_attr_bitmap_update("", obj, rtype, cl, attr, clear=True)
463
464 def _emit_attr_bitmap_update(
465 self, value: str, obj: str, rtype: RType, cl: ClassIR, attr: str, clear: bool
466 ) -> None:
467 if value:
468 check = self.error_value_check(rtype, value, "==")
469 self.emit_line(f"if (unlikely({check})) {{")
470 index = cl.bitmap_attrs.index(attr)
471 mask = 1 << (index & (BITMAP_BITS - 1))
472 bitmap = self.attr_bitmap_expr(obj, cl, index)
473 if clear:
474 self.emit_line(f"{bitmap} &= ~{mask};")
475 else:
476 self.emit_line(f"{bitmap} |= {mask};")
477 if value:
478 self.emit_line("}")
479
480 def emit_undefined_attr_check(
481 self,

Callers 2

emit_attr_bitmap_setMethod · 0.95

Calls 4

error_value_checkMethod · 0.95
emit_lineMethod · 0.95
attr_bitmap_exprMethod · 0.95
indexMethod · 0.80

Tested by

no test coverage detected