def _optimize_NEWSTR(self, op, mode): length_box = self.get_constant_box(op.getarg(0)) if length_box and length_box.getint() <= MAX_CONST_LEN: # if the original 'op' did not have a ConstInt as argument, # build a new one with the ConstInt argument if not isinstance(op.getarg(0), ConstInt): op = ResOperation(mode.NEWSTR, [length_box], op.result) vvalue = self.make_vstring_plain(op.result, op, mode) vvalue.setup(length_box.getint()) else: self.getvalue(op.result).ensure_nonnull() self.emit_operation(op) self.pure(mode.STRLEN, [op.result], op.getarg(0))
def optimize_VIRTUAL_REF(self, op): op = ResOperation(rop.SAME_AS, [op.getarg(0)], op.result) self.emit_operation(op)