Skip to content

Commit c18f8c8

Browse files
committed
Use uintptr for ID types
1 parent 933197b commit c18f8c8

File tree

5 files changed

+21
-13
lines changed

5 files changed

+21
-13
lines changed

internal/ast/ast.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ type Node struct {
175175
Kind Kind
176176
Flags NodeFlags
177177
Loc core.TextRange
178-
id atomic.Uint64
178+
id atomic.Uintptr
179179
Parent *Node
180180
data nodeData
181181
}

internal/ast/ids.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package ast
22

33
type (
4-
NodeId uint64
5-
SymbolId uint64
4+
NodeId uintptr
5+
SymbolId uintptr
66
)

internal/ast/symbol.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type Symbol struct {
1616
ValueDeclaration *Node
1717
Members SymbolTable
1818
Exports SymbolTable
19-
id atomic.Uint64
19+
id atomic.Uintptr
2020
Parent *Symbol
2121
ExportSymbol *Symbol
2222
AssignmentDeclarationMembers core.Set[*Node] // Set of detected assignment declarations

internal/ast/utilities.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313
// Atomic ids
1414

1515
var (
16-
nextNodeId atomic.Uint64
17-
nextSymbolId atomic.Uint64
16+
nextNodeId atomic.Uintptr
17+
nextSymbolId atomic.Uintptr
1818
)
1919

2020
func GetNodeId(node *Node) NodeId {

internal/checker/checker.go

+15-7
Original file line numberDiff line numberDiff line change
@@ -15990,27 +15990,35 @@ var base64chars = []byte{
1599015990
'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '$', '%',
1599115991
}
1599215992

15993-
func (b *KeyBuilder) WriteUint64(value uint64) {
15993+
func (b *KeyBuilder) WriteUintptr(value uintptr) {
1599415994
for value != 0 {
1599515995
b.WriteByte(base64chars[value&0x3F])
1599615996
value >>= 6
1599715997
}
1599815998
}
1599915999

16000+
func (b *KeyBuilder) WriteUint(value uint) {
16001+
b.WriteUintptr(uintptr(value))
16002+
}
16003+
1600016004
func (b *KeyBuilder) WriteInt(value int) {
16001-
b.WriteUint64(uint64(int64(value)))
16005+
b.WriteUint(uint(value))
16006+
}
16007+
16008+
func (b *KeyBuilder) WriteUint32(value uint32) {
16009+
b.WriteUint(uint(value))
1600216010
}
1600316011

1600416012
func (b *KeyBuilder) WriteSymbolId(id ast.SymbolId) {
16005-
b.WriteUint64(uint64(id))
16013+
b.WriteUintptr(uintptr(id))
1600616014
}
1600716015

1600816016
func (b *KeyBuilder) WriteSymbol(s *ast.Symbol) {
1600916017
b.WriteSymbolId(ast.GetSymbolId(s))
1601016018
}
1601116019

1601216020
func (b *KeyBuilder) WriteTypeId(id TypeId) {
16013-
b.WriteUint64(uint64(id))
16021+
b.WriteUint32(uint32(id))
1601416022
}
1601516023

1601616024
func (b *KeyBuilder) WriteType(t *Type) {
@@ -16088,7 +16096,7 @@ func (b *KeyBuilder) WriteGenericTypeReferences(source *Type, target *Type, igno
1608816096
}
1608916097

1609016098
func (b *KeyBuilder) WriteNodeId(id ast.NodeId) {
16091-
b.WriteUint64(uint64(id))
16099+
b.WriteUintptr(uintptr(id))
1609216100
}
1609316101

1609416102
func (b *KeyBuilder) WriteNode(node *ast.Node) {
@@ -16187,7 +16195,7 @@ func getIndexedAccessKey(objectType *Type, indexType *Type, accessFlags AccessFl
1618716195
b.WriteByte(',')
1618816196
b.WriteType(indexType)
1618916197
b.WriteByte(',')
16190-
b.WriteUint64(uint64(accessFlags))
16198+
b.WriteUint32(uint32(accessFlags))
1619116199
b.WriteAlias(alias)
1619216200
return b.String()
1619316201
}
@@ -16234,7 +16242,7 @@ func getRelationKey(source *Type, target *Type, intersectionState IntersectionSt
1623416242
}
1623516243
if intersectionState != IntersectionStateNone {
1623616244
b.WriteByte(':')
16237-
b.WriteUint64(uint64(intersectionState))
16245+
b.WriteUint32(uint32(intersectionState))
1623816246
}
1623916247
if constrained {
1624016248
// We mark keys with type references that reference constrained type parameters such that we know

0 commit comments

Comments
 (0)