Этот коммит содержится в:
Ayke van Laethem 2018-08-25 03:06:11 +02:00
родитель c9e6a52d05
коммит de6c20f1bd
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: E97FF5335DFDFDED

Просмотреть файл

@ -448,7 +448,7 @@ func (c *Compiler) getLLVMType(goType types.Type) (llvm.Type, error) {
return llvm.ArrayType(elemType, int(typ.Len())), nil return llvm.ArrayType(elemType, int(typ.Len())), nil
case *types.Basic: case *types.Basic:
switch typ.Kind() { switch typ.Kind() {
case types.Bool: case types.Bool, types.UntypedBool:
return llvm.Int1Type(), nil return llvm.Int1Type(), nil
case types.Int8, types.Uint8: case types.Int8, types.Uint8:
return llvm.Int8Type(), nil return llvm.Int8Type(), nil
@ -1902,14 +1902,13 @@ func (c *Compiler) parseBinOp(frame *Frame, binop *ssa.BinOp) (llvm.Value, error
} }
func (c *Compiler) parseConst(expr *ssa.Const) (llvm.Value, error) { func (c *Compiler) parseConst(expr *ssa.Const) (llvm.Value, error) {
typ := expr.Type().Underlying() switch typ := expr.Type().Underlying().(type) {
switch typ := typ.(type) {
case *types.Basic: case *types.Basic:
llvmType, err := c.getLLVMType(typ) llvmType, err := c.getLLVMType(typ)
if err != nil { if err != nil {
return llvm.Value{}, err return llvm.Value{}, err
} }
if typ.Kind() == types.Bool { if typ.Info()&types.IsBoolean != 0 {
b := constant.BoolVal(expr.Value) b := constant.BoolVal(expr.Value)
n := uint64(0) n := uint64(0)
if b { if b {
@ -1939,7 +1938,7 @@ func (c *Compiler) parseConst(expr *ssa.Const) (llvm.Value, error) {
n, _ := constant.Int64Val(expr.Value) n, _ := constant.Int64Val(expr.Value)
return llvm.ConstInt(llvmType, uint64(n), true), nil return llvm.ConstInt(llvmType, uint64(n), true), nil
} else { } else {
return llvm.Value{}, errors.New("todo: unknown constant: " + typ.String()) return llvm.Value{}, errors.New("todo: unknown constant: " + expr.String())
} }
case *types.Interface: case *types.Interface:
if expr.Value != nil { if expr.Value != nil {