From 5acde63f8812ab92f2d8a3501fea1aa8af47fded Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Sat, 9 Jun 2018 18:02:43 +0200 Subject: [PATCH] compiler: Move isPointer out of Compiler object --- tgo.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tgo.go b/tgo.go index 9209981a..21e51e22 100644 --- a/tgo.go +++ b/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 {