compiler: Move isPointer out of Compiler object

Этот коммит содержится в:
Ayke van Laethem 2018-06-09 18:02:43 +02:00
родитель 56056934e3
коммит 5acde63f88
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: E97FF5335DFDFDED

7
tgo.go
Просмотреть файл

@ -398,7 +398,8 @@ func (c *Compiler) getInterfaceType(typ types.Type) llvm.Value {
return llvm.ConstInt(llvm.Int32Type(), c.itfTypeNumbers[typ], false)
}
func (c *Compiler) isPointer(typ types.Type) bool {
// Is this a pointer type of some sort? Can be unsafe.Pointer or any *T pointer.
func isPointer(typ types.Type) bool {
if _, ok := typ.(*types.Pointer); ok {
return true
} else if typ, ok := typ.(*types.Basic); ok && typ.Kind() == types.UnsafePointer {
@ -1442,8 +1443,8 @@ func (c *Compiler) parseConvert(frame *Frame, typeTo types.Type, x ssa.Value) (l
switch typeTo := typeTo.(type) {
case *types.Basic:
isPtrFrom := c.isPointer(x.Type())
isPtrTo := c.isPointer(typeTo)
isPtrFrom := isPointer(x.Type())
isPtrTo := isPointer(typeTo)
if isPtrFrom && !isPtrTo {
return c.builder.CreatePtrToInt(value, llvmTypeTo, ""), nil
} else if !isPtrFrom && isPtrTo {