instCall converts the given LLVM IR call instruction to a corresponding Go statement.
(inst *ir.InstCall)
| 505 | // instCall converts the given LLVM IR call instruction to a corresponding Go |
| 506 | // statement. |
| 507 | func (d *decompiler) instCall(inst *ir.InstCall) ast.Stmt { |
| 508 | var callee ast.Expr |
| 509 | switch c := inst.Callee.(type) { |
| 510 | case *ir.Function: |
| 511 | // global function identifier. |
| 512 | callee = d.globalIdent(c.Name) |
| 513 | case *irtypes.Param: |
| 514 | // local function identifier. |
| 515 | callee = d.localIdent(c.Name) |
| 516 | case *constant.ExprBitCast: |
| 517 | callee = d.value(c) |
| 518 | case *ir.InstBitCast: |
| 519 | callee = d.value(c) |
| 520 | case *ir.InstLoad: |
| 521 | callee = d.value(c) |
| 522 | default: |
| 523 | panic(fmt.Sprintf("support for callee type %T not yet implemented", c)) |
| 524 | } |
| 525 | var args []ast.Expr |
| 526 | for _, a := range inst.Args { |
| 527 | args = append(args, d.value(a)) |
| 528 | } |
| 529 | expr := &ast.CallExpr{ |
| 530 | Fun: callee, |
| 531 | Args: args, |
| 532 | } |
| 533 | if irtypes.Equal(inst.Sig.Ret, irtypes.Void) { |
| 534 | return &ast.ExprStmt{X: expr} |
| 535 | } |
| 536 | return d.assign(inst.Name, expr) |
| 537 | } |
| 538 | |
| 539 | // binaryOp converts the given LLVM IR binary operation to a corresponding Go |
| 540 | // expression. |
no test coverage detected