Skip to content

Commit

Permalink
irgen: Simplify callExpr.
Browse files Browse the repository at this point in the history
  • Loading branch information
mewmew committed Jun 18, 2016
1 parent 66427bc commit 698b24e
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions irgen/lower.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,20 +595,18 @@ func (m *Module) binaryExpr(f *Function, n *ast.BinaryExpr) value.Value {

// callExpr lowers the given identifier to LLVM IR, emitting code to f.
func (m *Module) callExpr(f *Function, callExpr *ast.CallExpr) value.Value {
// val := m.valueFromIdent(f, callExpr.Name.Decl.Name())
// typ := val.Type().(*irtypes.Func)
typ := toIrType(callExpr.Name.Decl.Type()).(*irtypes.Func)
result := f.Sig().Result()
var args []value.Value
for _, arg := range callExpr.Args {
expr := m.expr(f, arg)
args = append(args, expr)
// TODO: Add cast
args = append(args, expr)
}
inst, err := instruction.NewCall(typ.Result(), callExpr.Name.String(), args)
callInst, err := instruction.NewCall(result, callExpr.Name.String(), args)
if err != nil {
panic(fmt.Sprintf("unable to create call instruction; %v", err))
}
return f.emitInst(inst)
return f.emitInst(callInst)
}

// ident lowers the given identifier to LLVM IR, emitting code to f.
Expand Down

0 comments on commit 698b24e

Please sign in to comment.