MCPcopy Create free account
hub / github.com/decomp/decomp / instCall

Method instCall

cmd/ll2go/instruction.go:507–537  ·  view source on GitHub ↗

instCall converts the given LLVM IR call instruction to a corresponding Go statement.

(inst *ir.InstCall)

Source from the content-addressed store, hash-verified

505// instCall converts the given LLVM IR call instruction to a corresponding Go
506// statement.
507func (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.

Callers 1

instMethod · 0.95

Calls 4

globalIdentMethod · 0.95
localIdentMethod · 0.95
valueMethod · 0.95
assignMethod · 0.95

Tested by

no test coverage detected