func (d *DIBuilder) descriptorBasic(t *types.Basic, name string) llvm.Value { switch t.Kind() { case types.String: return d.typeDebugDescriptor(types.NewStruct([]*types.Var{ types.NewVar(0, nil, "ptr", types.NewPointer(types.Typ[types.Uint8])), types.NewVar(0, nil, "len", types.Typ[types.Int]), }, nil), name) case types.UnsafePointer: return d.builder.CreateBasicType(llvm.DIBasicType{ Name: name, SizeInBits: uint64(d.sizes.Sizeof(t) * 8), AlignInBits: uint64(d.sizes.Alignof(t) * 8), Encoding: llvm.DW_ATE_unsigned, }) default: bt := llvm.DIBasicType{ Name: t.String(), SizeInBits: uint64(d.sizes.Sizeof(t) * 8), AlignInBits: uint64(d.sizes.Alignof(t) * 8), } switch bi := t.Info(); { case bi&types.IsBoolean != 0: bt.Encoding = llvm.DW_ATE_boolean case bi&types.IsUnsigned != 0: bt.Encoding = llvm.DW_ATE_unsigned case bi&types.IsInteger != 0: bt.Encoding = llvm.DW_ATE_signed case bi&types.IsFloat != 0: bt.Encoding = llvm.DW_ATE_float case bi&types.IsComplex != 0: bt.Encoding = llvm.DW_ATE_imaginary_float case bi&types.IsUnsigned != 0: bt.Encoding = llvm.DW_ATE_unsigned default: panic(fmt.Sprintf("unhandled: %#v", t)) } return d.builder.CreateBasicType(bt) } }
func isUnsigned(t *types.Basic) bool { return t.Info()&types.IsUnsigned != 0 }
func isString(t *types.Basic) bool { return t.Info()&types.IsString != 0 }
func isNumeric(t *types.Basic) bool { return t.Info()&types.IsNumeric != 0 }
func isInteger(t *types.Basic) bool { return t.Info()&types.IsInteger != 0 }
func isFloat(t *types.Basic) bool { return t.Info()&types.IsFloat != 0 }
func isComplex(t *types.Basic) bool { return t.Info()&types.IsComplex != 0 }
func isBoolean(t *types.Basic) bool { return t.Info()&types.IsBoolean != 0 }