builtin: real/imag/complex; c/math/cmplx; patch: math/cmplx

This commit is contained in:
xushiwei
2024-06-20 10:00:47 +08:00
parent 1566a834e1
commit de6535b722
9 changed files with 274 additions and 24 deletions

View File

@@ -214,6 +214,14 @@ func (p Program) Field(typ Type, i int) Type {
switch t := typ.raw.Type.(type) {
case *types.Tuple:
fld = t.At(i)
case *types.Basic:
switch t.Kind() {
case types.Complex128:
return p.Float64()
case types.Complex64:
return p.Float32()
}
panic("Field: basic type doesn't have fields")
default:
fld = t.Underlying().(*types.Struct).Field(i)
}
@@ -330,7 +338,9 @@ func (p Program) toType(raw types.Type) Type {
case types.Float64:
return &aType{p.ctx.DoubleType(), typ, vkFloat}
case types.Complex64:
return &aType{p.tyComplex64(), typ, vkComplex}
case types.Complex128:
return &aType{p.tyComplex128(), typ, vkComplex}
case types.String:
return &aType{p.rtString(), typ, vkString}
case types.UnsafePointer: