(self, func_target: &FunctionTarget<'_>, f: &mut F)
| 478 | } |
| 479 | |
| 480 | fn remap_vars_internal<F>(self, func_target: &FunctionTarget<'_>, f: &mut F) -> Self |
| 481 | where |
| 482 | F: FnMut(bool, TempIndex) -> TempIndex, |
| 483 | { |
| 484 | use BorrowNode::*; |
| 485 | use Bytecode::*; |
| 486 | use Operation::*; |
| 487 | let map = |is_src: bool, f: &mut F, v: Vec<TempIndex>| -> Vec<TempIndex> { |
| 488 | v.into_iter().map(|i| f(is_src, i)).collect() |
| 489 | }; |
| 490 | let map_abort = |f: &mut F, aa: Option<AbortAction>| { |
| 491 | aa.map(|AbortAction(l, code)| AbortAction(l, f(false, code))) |
| 492 | }; |
| 493 | let map_node = |f: &mut F, node: BorrowNode| match node { |
| 494 | LocalRoot(tmp) => LocalRoot(f(true, tmp)), |
| 495 | Reference(tmp) => Reference(f(true, tmp)), |
| 496 | _ => node, |
| 497 | }; |
| 498 | match self { |
| 499 | Load(attr, dst, cons) => Load(attr, f(false, dst), cons), |
| 500 | Assign(attr, dest, src, kind) => Assign(attr, f(false, dest), f(true, src), kind), |
| 501 | Call(attr, _, WriteBack(node, edge), srcs, aa) => Call( |
| 502 | attr, |
| 503 | vec![], |
| 504 | WriteBack(map_node(f, node), edge), |
| 505 | map(true, f, srcs), |
| 506 | map_abort(f, aa), |
| 507 | ), |
| 508 | Call(attr, dests, IsParent(node, edge), srcs, aa) => Call( |
| 509 | attr, |
| 510 | map(false, f, dests), |
| 511 | IsParent(map_node(f, node), edge), |
| 512 | map(true, f, srcs), |
| 513 | map_abort(f, aa), |
| 514 | ), |
| 515 | Call(attr, dests, op, srcs, aa) => Call( |
| 516 | attr, |
| 517 | map(false, f, dests), |
| 518 | op, |
| 519 | map(true, f, srcs), |
| 520 | map_abort(f, aa), |
| 521 | ), |
| 522 | Ret(attr, rets) => Ret(attr, map(true, f, rets)), |
| 523 | Branch(attr, if_label, else_label, cond) => { |
| 524 | Branch(attr, if_label, else_label, f(true, cond)) |
| 525 | } |
| 526 | Abort(attr, cond) => Abort(attr, f(true, cond)), |
| 527 | Prop(attr, kind, exp) => { |
| 528 | let new_exp = Bytecode::remap_exp(func_target, &mut |idx| f(true, idx), exp); |
| 529 | Prop(attr, kind, new_exp) |
| 530 | } |
| 531 | _ => self, |
| 532 | } |
| 533 | } |
| 534 | |
| 535 | fn remap_exp<F>(func_target: &FunctionTarget<'_>, f: &mut F, exp: Exp) -> Exp |
| 536 | where |
no test coverage detected