termSwitch converts the given LLVM IR switch terminator to a corresponding Go statement.
(term *ir.TermSwitch)
| 76 | // termSwitch converts the given LLVM IR switch terminator to a corresponding Go |
| 77 | // statement. |
| 78 | func (d *decompiler) termSwitch(term *ir.TermSwitch) ast.Stmt { |
| 79 | // Use goto-statements as a fallback for incomplete control flow recovery. |
| 80 | var cases []ast.Stmt |
| 81 | for _, c := range term.Cases { |
| 82 | gotoStmt := &ast.BranchStmt{ |
| 83 | Tok: token.GOTO, |
| 84 | Label: d.localIdent(c.Target.Name), |
| 85 | } |
| 86 | cc := &ast.CaseClause{ |
| 87 | List: []ast.Expr{d.value(c.X)}, |
| 88 | Body: []ast.Stmt{gotoStmt}, |
| 89 | } |
| 90 | cases = append(cases, cc) |
| 91 | } |
| 92 | return &ast.SwitchStmt{ |
| 93 | Tag: d.value(term.X), |
| 94 | Body: &ast.BlockStmt{ |
| 95 | List: cases, |
| 96 | }, |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | // termUnreachable converts the given LLVM IR unreachable terminator to a |
| 101 | // corresponding Go statement. |
no test coverage detected