Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Commit 19679fe

Browse files
committed
Update to latest go/types
1 parent b1ebb0c commit 19679fe

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

check.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,14 @@ func (c *compiler) typecheck(pkgpath string, fset *token.FileSet, files []*ast.F
2121
var errors string
2222
var imp = importer{compiler: c}
2323
config := &types.Config{
24-
Sizeof: c.llvmtypes.Sizeof,
25-
Alignof: c.llvmtypes.Alignof,
26-
Offsetsof: c.llvmtypes.Offsetsof,
2724
Error: func(err error) {
2825
if errors != "" {
2926
errors += "\n"
3027
}
3128
errors += err.Error()
3229
},
3330
Import: imp.Import,
31+
Sizes: c.llvmtypes,
3432
}
3533

3634
var info types.Info

typemap.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ type ExprTypeInfo struct {
2222

2323
type LLVMTypeMap struct {
2424
TypeStringer
25+
types.StdSizes
2526
target llvm.TargetData
2627
inttype llvm.Type
2728

@@ -80,7 +81,11 @@ func NewLLVMTypeMap(target llvm.TargetData) *LLVMTypeMap {
8081
inttype = llvm.Int32Type()
8182
}
8283
return &LLVMTypeMap{
83-
target: target,
84+
target: target,
85+
StdSizes: types.StdSizes{
86+
WordSize: int64(target.PointerSize()),
87+
MaxAlign: 8,
88+
},
8489
types: make(map[string]llvm.Type),
8590
inttype: inttype,
8691
}
@@ -399,7 +404,7 @@ func (tm *LLVMTypeMap) Alignof(typ types.Type) int64 {
399404
case types.Uintptr, types.UnsafePointer, types.String:
400405
return int64(tm.target.PointerSize())
401406
}
402-
return types.DefaultAlignof(typ)
407+
return tm.StdSizes.Alignof(typ)
403408
case *types.Struct:
404409
max := int64(1)
405410
for i := 0; i < typ.NumFields(); i++ {
@@ -422,10 +427,8 @@ func (tm *LLVMTypeMap) Sizeof(typ types.Type) int64 {
422427
return int64(tm.target.TypeAllocSize(tm.inttype))
423428
case types.Uintptr, types.UnsafePointer:
424429
return int64(tm.target.PointerSize())
425-
case types.String:
426-
return 2 * int64(tm.target.PointerSize())
427430
}
428-
return types.DefaultSizeof(typ)
431+
return tm.StdSizes.Sizeof(typ)
429432
case *types.Array:
430433
eltsize := tm.Sizeof(typ.Elem())
431434
eltalign := tm.Alignof(typ.Elem())

0 commit comments

Comments
 (0)