result: checkExpr funcPtr => closure
This commit is contained in:
15
ssa/expr.go
15
ssa/expr.go
@@ -1137,6 +1137,21 @@ func (b Builder) Call(fn Expr, args ...Expr) (ret Expr) {
|
||||
return
|
||||
}
|
||||
|
||||
// The Extract instruction yields component Index of Tuple.
|
||||
//
|
||||
// This is used to access the results of instructions with multiple
|
||||
// return values, such as Call, TypeAssert, Next, UnOp(ARROW) and
|
||||
// IndexExpr(Map).
|
||||
//
|
||||
// Example printed form:
|
||||
//
|
||||
// t1 = extract t0 #1
|
||||
func (b Builder) Extract(x Expr, index int) (ret Expr) {
|
||||
ret.Type = b.Prog.toType(x.Type.raw.Type.(*types.Tuple).At(index).Type())
|
||||
ret.impl = b.impl.CreateExtractValue(x.impl, index, "")
|
||||
return
|
||||
}
|
||||
|
||||
// A Builtin represents a specific use of a built-in function, e.g. len.
|
||||
//
|
||||
// Builtins are immutable values. Builtins do not have addresses.
|
||||
|
||||
@@ -101,7 +101,9 @@ func (b Builder) Return(results ...Expr) {
|
||||
case 0:
|
||||
b.impl.CreateRetVoid()
|
||||
case 1:
|
||||
b.impl.CreateRet(results[0].impl)
|
||||
raw := b.Func.raw.Type.(*types.Signature).Results().At(0).Type()
|
||||
ret := checkExpr(results[0], raw, b)
|
||||
b.impl.CreateRet(ret.impl)
|
||||
default:
|
||||
tret := b.Func.raw.Type.(*types.Signature).Results()
|
||||
b.impl.CreateAggregateRet(llvmParams(0, results, tret, b))
|
||||
|
||||
Reference in New Issue
Block a user