| 2411 | |
| 2412 | class OptimizeLoadFastTestCase(DirectCfgOptimizerTests): |
| 2413 | def make_bb(self, insts): |
| 2414 | last_loc = insts[-1][2] |
| 2415 | maxconst = 0 |
| 2416 | for op, arg, _ in insts: |
| 2417 | if op == "LOAD_CONST": |
| 2418 | maxconst = max(maxconst, arg) |
| 2419 | consts = [None for _ in range(maxconst + 1)] |
| 2420 | return insts + [ |
| 2421 | ("LOAD_CONST", 0, last_loc + 1), |
| 2422 | ("RETURN_VALUE", None, last_loc + 2), |
| 2423 | ], consts |
| 2424 | |
| 2425 | def check(self, insts, expected_insts, consts=None): |
| 2426 | insts_bb, insts_consts = self.make_bb(insts) |