def replace_box(self, oldbox, newbox): # here, only for replacing a box with a const if isinstance(oldbox, FrontendOp) and isinstance(newbox, Const): assert newbox.same_constant(constant_from_op(oldbox)) oldbox.set_replaced_with_const()
def maybe_replace_with_const(box): if not isinstance(box, Const) and box.is_replaced_with_const(): return constant_from_op(box) else: return box