From c18f8c8003bb9b43bb09582e7c25ee3aa67574b3 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 3 Apr 2025 16:18:22 -0700 Subject: [PATCH] Use uintptr for ID types --- internal/ast/ast.go | 2 +- internal/ast/ids.go | 4 ++-- internal/ast/symbol.go | 2 +- internal/ast/utilities.go | 4 ++-- internal/checker/checker.go | 22 +++++++++++++++------- 5 files changed, 21 insertions(+), 13 deletions(-) diff --git a/internal/ast/ast.go b/internal/ast/ast.go index d81338d7d3..1845932a3b 100644 --- a/internal/ast/ast.go +++ b/internal/ast/ast.go @@ -175,7 +175,7 @@ type Node struct { Kind Kind Flags NodeFlags Loc core.TextRange - id atomic.Uint64 + id atomic.Uintptr Parent *Node data nodeData } diff --git a/internal/ast/ids.go b/internal/ast/ids.go index 63e415deba..4cf7abab30 100644 --- a/internal/ast/ids.go +++ b/internal/ast/ids.go @@ -1,6 +1,6 @@ package ast type ( - NodeId uint64 - SymbolId uint64 + NodeId uintptr + SymbolId uintptr ) diff --git a/internal/ast/symbol.go b/internal/ast/symbol.go index 92e9412cd9..4842ff6369 100644 --- a/internal/ast/symbol.go +++ b/internal/ast/symbol.go @@ -16,7 +16,7 @@ type Symbol struct { ValueDeclaration *Node Members SymbolTable Exports SymbolTable - id atomic.Uint64 + id atomic.Uintptr Parent *Symbol ExportSymbol *Symbol AssignmentDeclarationMembers core.Set[*Node] // Set of detected assignment declarations diff --git a/internal/ast/utilities.go b/internal/ast/utilities.go index e182656bdf..789b4c9b4c 100644 --- a/internal/ast/utilities.go +++ b/internal/ast/utilities.go @@ -13,8 +13,8 @@ import ( // Atomic ids var ( - nextNodeId atomic.Uint64 - nextSymbolId atomic.Uint64 + nextNodeId atomic.Uintptr + nextSymbolId atomic.Uintptr ) func GetNodeId(node *Node) NodeId { diff --git a/internal/checker/checker.go b/internal/checker/checker.go index 77b962c9b1..9d224cfb21 100644 --- a/internal/checker/checker.go +++ b/internal/checker/checker.go @@ -15990,19 +15990,27 @@ var base64chars = []byte{ 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '$', '%', } -func (b *KeyBuilder) WriteUint64(value uint64) { +func (b *KeyBuilder) WriteUintptr(value uintptr) { for value != 0 { b.WriteByte(base64chars[value&0x3F]) value >>= 6 } } +func (b *KeyBuilder) WriteUint(value uint) { + b.WriteUintptr(uintptr(value)) +} + func (b *KeyBuilder) WriteInt(value int) { - b.WriteUint64(uint64(int64(value))) + b.WriteUint(uint(value)) +} + +func (b *KeyBuilder) WriteUint32(value uint32) { + b.WriteUint(uint(value)) } func (b *KeyBuilder) WriteSymbolId(id ast.SymbolId) { - b.WriteUint64(uint64(id)) + b.WriteUintptr(uintptr(id)) } func (b *KeyBuilder) WriteSymbol(s *ast.Symbol) { @@ -16010,7 +16018,7 @@ func (b *KeyBuilder) WriteSymbol(s *ast.Symbol) { } func (b *KeyBuilder) WriteTypeId(id TypeId) { - b.WriteUint64(uint64(id)) + b.WriteUint32(uint32(id)) } func (b *KeyBuilder) WriteType(t *Type) { @@ -16088,7 +16096,7 @@ func (b *KeyBuilder) WriteGenericTypeReferences(source *Type, target *Type, igno } func (b *KeyBuilder) WriteNodeId(id ast.NodeId) { - b.WriteUint64(uint64(id)) + b.WriteUintptr(uintptr(id)) } func (b *KeyBuilder) WriteNode(node *ast.Node) { @@ -16187,7 +16195,7 @@ func getIndexedAccessKey(objectType *Type, indexType *Type, accessFlags AccessFl b.WriteByte(',') b.WriteType(indexType) b.WriteByte(',') - b.WriteUint64(uint64(accessFlags)) + b.WriteUint32(uint32(accessFlags)) b.WriteAlias(alias) return b.String() } @@ -16234,7 +16242,7 @@ func getRelationKey(source *Type, target *Type, intersectionState IntersectionSt } if intersectionState != IntersectionStateNone { b.WriteByte(':') - b.WriteUint64(uint64(intersectionState)) + b.WriteUint32(uint32(intersectionState)) } if constrained { // We mark keys with type references that reference constrained type parameters such that we know