Skip to content

Commit a54dce0

Browse files
committed
sys: allow custom size for PtrType
This is required to support ptr64 type.
1 parent 08c91ab commit a54dce0

File tree

7 files changed

+8702
-8699
lines changed

7 files changed

+8702
-8699
lines changed

pkg/compiler/types.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,13 @@ var typePtr = &typeDesc{
7979
Args: []namedArg{{"direction", typeArgDir}, {"type", typeArgType}},
8080
Gen: func(comp *compiler, t *ast.Type, args []*ast.Type, base sys.IntTypeCommon) sys.Type {
8181
base.ArgDir = sys.DirIn // pointers are always in
82-
base.TypeSize = comp.ptrSize
82+
size := comp.ptrSize
8383
if t.Ident == "ptr64" {
84-
base.TypeSize = 8
84+
size = 8
8585
}
8686
return &sys.PtrType{
8787
TypeCommon: base.TypeCommon,
88+
TypeSize: size,
8889
Type: comp.genType(args[1], "", genDir(args[0]), false),
8990
}
9091
},
@@ -375,6 +376,7 @@ var typeBuffer = &typeDesc{
375376
Gen: func(comp *compiler, t *ast.Type, args []*ast.Type, base sys.IntTypeCommon) sys.Type {
376377
return &sys.PtrType{
377378
TypeCommon: base.TypeCommon,
379+
TypeSize: comp.ptrSize,
378380
Type: &sys.BufferType{
379381
TypeCommon: genCommon("", "", genDir(args[0]), false),
380382
Kind: sys.BufferBlobRand,

sys/decl.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,12 @@ func (t *ArrayType) Align() uint64 {
331331

332332
type PtrType struct {
333333
TypeCommon
334-
Type Type
334+
TypeSize uint64
335+
Type Type
335336
}
336337

337338
func (t *PtrType) Size() uint64 {
338-
return ptrSize
339+
return t.TypeSize
339340
}
340341

341342
func (t *PtrType) Align() uint64 {

sys/sys_386.go

Lines changed: 1739 additions & 1739 deletions
Large diffs are not rendered by default.

sys/sys_amd64.go

Lines changed: 1739 additions & 1739 deletions
Large diffs are not rendered by default.

sys/sys_arm.go

Lines changed: 1739 additions & 1739 deletions
Large diffs are not rendered by default.

sys/sys_arm64.go

Lines changed: 1739 additions & 1739 deletions
Large diffs are not rendered by default.

sys/sys_ppc64le.go

Lines changed: 1739 additions & 1739 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)