Merge pull request #955 from visualfc/conv
ssa: fix cvtType check types.Alias
This commit is contained in:
@@ -19,6 +19,7 @@ package ssa
|
|||||||
import (
|
import (
|
||||||
"go/token"
|
"go/token"
|
||||||
"go/types"
|
"go/types"
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
"github.com/goplus/llgo/compiler/ssa/abi"
|
"github.com/goplus/llgo/compiler/ssa/abi"
|
||||||
"github.com/goplus/llvm"
|
"github.com/goplus/llvm"
|
||||||
@@ -253,7 +254,7 @@ func (b Builder) abiNamedInterfaceOf(t *types.Named) func() Expr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b Builder) sizeof(t types.Type) int64 {
|
func (b Builder) sizeof(t types.Type) int64 {
|
||||||
sizes := (*goProgram)(b.Prog)
|
sizes := (*goProgram)(unsafe.Pointer(b.Prog))
|
||||||
return sizes.Sizeof(t)
|
return sizes.Sizeof(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,7 +344,7 @@ func (b Builder) abiChanOf(t *types.Chan) func() Expr {
|
|||||||
func (b Builder) abiMapOf(t *types.Map) func() Expr {
|
func (b Builder) abiMapOf(t *types.Map) func() Expr {
|
||||||
key := b.abiTypeOf(t.Key())
|
key := b.abiTypeOf(t.Key())
|
||||||
elem := b.abiTypeOf(t.Elem())
|
elem := b.abiTypeOf(t.Elem())
|
||||||
sizes := (*goProgram)(b.Prog)
|
sizes := (*goProgram)(unsafe.Pointer(b.Prog))
|
||||||
bucket := b.abiTypeOf(abi.MapBucketType(t, sizes))
|
bucket := b.abiTypeOf(abi.MapBucketType(t, sizes))
|
||||||
flags := abi.MapTypeFlags(t, sizes)
|
flags := abi.MapTypeFlags(t, sizes)
|
||||||
return func() Expr {
|
return func() Expr {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package ssa
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"go/types"
|
"go/types"
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
"github.com/goplus/llgo/compiler/ssa/abi"
|
"github.com/goplus/llgo/compiler/ssa/abi"
|
||||||
"github.com/goplus/llvm"
|
"github.com/goplus/llvm"
|
||||||
@@ -96,7 +97,7 @@ func (p *goProgram) Alignof(T types.Type) int64 {
|
|||||||
// Offsetsof must implement the offset guarantees required by the spec.
|
// Offsetsof must implement the offset guarantees required by the spec.
|
||||||
// A negative entry in the result indicates that the struct is too large.
|
// A negative entry in the result indicates that the struct is too large.
|
||||||
func (p *goProgram) Offsetsof(fields []*types.Var) (ret []int64) {
|
func (p *goProgram) Offsetsof(fields []*types.Var) (ret []int64) {
|
||||||
prog := Program(p)
|
prog := Program(unsafe.Pointer(p))
|
||||||
ptrSize := int64(prog.PointerSize())
|
ptrSize := int64(prog.PointerSize())
|
||||||
extra := int64(0)
|
extra := int64(0)
|
||||||
ret = p.sizes.Offsetsof(fields)
|
ret = p.sizes.Offsetsof(fields)
|
||||||
@@ -111,7 +112,7 @@ func (p *goProgram) Offsetsof(fields []*types.Var) (ret []int64) {
|
|||||||
// Sizeof must implement the size guarantees required by the spec.
|
// Sizeof must implement the size guarantees required by the spec.
|
||||||
// A negative result indicates that T is too large.
|
// A negative result indicates that T is too large.
|
||||||
func (p *goProgram) Sizeof(T types.Type) int64 {
|
func (p *goProgram) Sizeof(T types.Type) int64 {
|
||||||
prog := Program(p)
|
prog := Program(unsafe.Pointer(p))
|
||||||
ptrSize := int64(prog.PointerSize())
|
ptrSize := int64(prog.PointerSize())
|
||||||
baseSize := prog.sizes.Sizeof(T) + p.extraSize(T, ptrSize)
|
baseSize := prog.sizes.Sizeof(T) + p.extraSize(T, ptrSize)
|
||||||
switch T.Underlying().(type) {
|
switch T.Underlying().(type) {
|
||||||
@@ -171,7 +172,7 @@ func (t Type) RawType() types.Type {
|
|||||||
// TypeSizes returns the sizes of the types.
|
// TypeSizes returns the sizes of the types.
|
||||||
func (p Program) TypeSizes(sizes types.Sizes) types.Sizes {
|
func (p Program) TypeSizes(sizes types.Sizes) types.Sizes {
|
||||||
p.sizes = sizes
|
p.sizes = sizes
|
||||||
return (*goProgram)(p)
|
return (*goProgram)(unsafe.Pointer(p))
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(xsw):
|
// TODO(xsw):
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ func (p goTypes) cvtType(typ types.Type) (raw types.Type, cvt bool) {
|
|||||||
case *types.TypeParam:
|
case *types.TypeParam:
|
||||||
return typ.Underlying(), false
|
return typ.Underlying(), false
|
||||||
case *types.Alias:
|
case *types.Alias:
|
||||||
return types.Unalias(t), true
|
return p.cvtType(types.Unalias(t))
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("cvtType: unexpected type - %T", typ))
|
panic(fmt.Sprintf("cvtType: unexpected type - %T", typ))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user