ssa: fix named func call
This commit is contained in:
10
ssa/expr.go
10
ssa/expr.go
@@ -689,12 +689,14 @@ func (b Builder) ChangeType(t Type, x Expr) (ret Expr) {
|
||||
log.Printf("ChangeType %v, %v\n", t.RawType(), x.impl)
|
||||
}
|
||||
typ := t.raw.Type
|
||||
switch typ.(type) {
|
||||
switch t.kind {
|
||||
case vkClosure:
|
||||
ret.impl = checkExpr(x, typ.Underlying(), b).impl
|
||||
default:
|
||||
ret.impl = llvm.CreateBitCast(b.impl, x.impl, t.ll)
|
||||
ret.Type = b.Prog.rawType(typ)
|
||||
return
|
||||
ret.impl = x.impl
|
||||
}
|
||||
ret.Type = t
|
||||
return
|
||||
}
|
||||
|
||||
// The Convert instruction yields the conversion of value X to type
|
||||
|
||||
@@ -486,7 +486,11 @@ func (p Program) toNamed(raw *types.Named) Type {
|
||||
switch t := raw.Underlying().(type) {
|
||||
case *types.Struct:
|
||||
name := p.llvmNameOf(raw)
|
||||
return &aType{p.toLLVMNamedStruct(name, t), rawType{raw}, vkStruct}
|
||||
kind := vkStruct
|
||||
if isClosure(t) {
|
||||
kind = vkClosure
|
||||
}
|
||||
return &aType{p.toLLVMNamedStruct(name, t), rawType{raw}, kind}
|
||||
default:
|
||||
typ := p.rawType(t)
|
||||
return &aType{typ.ll, rawType{raw}, typ.kind}
|
||||
|
||||
Reference in New Issue
Block a user