(self, line: str)
| 254 | return re.sub(continue_symbol, continue_label, text) |
| 255 | |
| 256 | def _parse_instruction(self, line: str) -> Instruction: |
| 257 | target = None |
| 258 | if match := self._re_branch.match(line): |
| 259 | target = match["target"] |
| 260 | name = match["instruction"] |
| 261 | if name in self._short_branches: |
| 262 | kind = InstructionKind.SHORT_BRANCH |
| 263 | else: |
| 264 | kind = InstructionKind.LONG_BRANCH |
| 265 | elif match := self._re_jump.match(line): |
| 266 | target = match["target"] |
| 267 | name = line[: -len(target)].strip() |
| 268 | kind = InstructionKind.JUMP |
| 269 | elif match := self._re_call.match(line): |
| 270 | target = match["target"] |
| 271 | name = line[: -len(target)].strip() |
| 272 | kind = InstructionKind.CALL |
| 273 | elif match := self._re_return.match(line): |
| 274 | name = line |
| 275 | kind = InstructionKind.RETURN |
| 276 | elif match := self._re_small_const_1.match(line): |
| 277 | target = match["value"] |
| 278 | name = match["instruction"] |
| 279 | kind = InstructionKind.SMALL_CONST_1 |
| 280 | elif match := self._re_small_const_2.match(line): |
| 281 | target = match["value"] |
| 282 | name = match["instruction"] |
| 283 | kind = InstructionKind.SMALL_CONST_2 |
| 284 | else: |
| 285 | name, *_ = line.split(" ") |
| 286 | kind = InstructionKind.OTHER |
| 287 | return Instruction(kind, name, line, target) |
| 288 | |
| 289 | def _invert_branch(self, inst: Instruction, target: str) -> Instruction | None: |
| 290 | assert inst.is_branch() |
no test coverage detected