Merge pull request #225 from visualfc/typed

ssa: fix type toNamed
This commit is contained in:
xushiwei
2024-05-24 10:55:15 +08:00
committed by GitHub
2 changed files with 5 additions and 4 deletions

View File

@@ -183,12 +183,12 @@ func (b Builder) Const(v constant.Value, typ Type) Expr {
return prog.Null(typ)
}
raw := typ.raw.Type
switch t := raw.(type) {
switch t := raw.Underlying().(type) {
case *types.Basic:
kind := t.Kind()
switch {
case kind == types.Bool:
return prog.BoolVal(constant.BoolVal(v))
return Expr{prog.BoolVal(constant.BoolVal(v)).impl, typ}
case kind >= types.Int && kind <= types.Int64:
if v, exact := constant.Int64Val(v); exact {
return prog.IntVal(uint64(v), typ)
@@ -202,7 +202,7 @@ func (b Builder) Const(v constant.Value, typ Type) Expr {
return prog.FloatVal(v, typ)
}
case kind == types.String:
return b.Str(constant.StringVal(v))
return Expr{b.Str(constant.StringVal(v)).impl, typ}
}
}
panic(fmt.Sprintf("unsupported Const: %v, %v", v, raw))

View File

@@ -396,7 +396,8 @@ func (p Program) toNamed(raw *types.Named) Type {
name := NameOf(raw)
return &aType{p.toLLVMNamedStruct(name, t), rawType{raw}, vkStruct}
default:
return p.rawType(t)
typ := p.rawType(t)
return &aType{typ.ll, rawType{raw}, typ.kind}
}
}