Exemplo n.º 1
0
 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()
Exemplo n.º 2
0
 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()
Exemplo n.º 3
0
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
Exemplo n.º 4
0
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