Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd508afb

Browse files
authored
Make NodeId and SymbolId into uint64s, fix up KeyBuilder (microsoft#243)
1 parentec11a7f commitd508afb

File tree

6 files changed

+32
-16
lines changed

6 files changed

+32
-16
lines changed

‎internal/ast/ast.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ type Node struct {
175175
KindKind
176176
FlagsNodeFlags
177177
Loc core.TextRange
178-
id atomic.Uint32
178+
id atomic.Uint64
179179
Parent*Node
180180
datanodeData
181181
}

‎internal/ast/ids.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package ast
22

33
type (
4-
NodeIduint32
5-
SymbolIduint32
4+
NodeIduint64
5+
SymbolIduint64
66
)

‎internal/ast/symbol.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type Symbol struct {
1616
ValueDeclaration*Node
1717
MembersSymbolTable
1818
ExportsSymbolTable
19-
id atomic.Uint32
19+
id atomic.Uint64
2020
Parent*Symbol
2121
ExportSymbol*Symbol
2222
AssignmentDeclarationMembers core.Set[*Node]// Set of detected assignment declarations

‎internal/ast/utilities.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313
// Atomic ids
1414

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

2020
funcGetNodeId(node*Node)NodeId {

‎internal/checker/checker.go

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15765,19 +15765,31 @@ var base64chars = []byte{
1576515765
'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '$', '%',
1576615766
}
1576715767

15768-
func (b *KeyBuilder)WriteInt(valueint) {
15768+
func (b *KeyBuilder)WriteUint64(valueuint64) {
1576915769
for value != 0 {
1577015770
b.WriteByte(base64chars[value&0x3F])
1577115771
value >>= 6
1577215772
}
1577315773
}
1577415774

15775+
func (b *KeyBuilder) WriteInt(value int) {
15776+
b.WriteUint64(uint64(int64(value)))
15777+
}
15778+
15779+
func (b *KeyBuilder) WriteSymbolId(id ast.SymbolId) {
15780+
b.WriteUint64(uint64(id))
15781+
}
15782+
1577515783
func (b *KeyBuilder) WriteSymbol(s *ast.Symbol) {
15776-
b.WriteInt(int(ast.GetSymbolId(s)))
15784+
b.WriteSymbolId(ast.GetSymbolId(s))
15785+
}
15786+
15787+
func (b *KeyBuilder) WriteTypeId(id TypeId) {
15788+
b.WriteUint64(uint64(id))
1577715789
}
1577815790

1577915791
func (b *KeyBuilder) WriteType(t *Type) {
15780-
b.WriteInt(int(t.id))
15792+
b.WriteTypeId(t.id)
1578115793
}
1578215794

1578315795
func (b *KeyBuilder) WriteTypes(types []*Type) {
@@ -15792,7 +15804,7 @@ func (b *KeyBuilder) WriteTypes(types []*Type) {
1579215804
if tail {
1579315805
b.WriteByte(',')
1579415806
}
15795-
b.WriteInt(int(startId))
15807+
b.WriteTypeId(startId)
1579615808
if count > 1 {
1579715809
b.WriteByte(':')
1579815810
b.WriteInt(count)
@@ -15850,9 +15862,13 @@ func (b *KeyBuilder) WriteGenericTypeReferences(source *Type, target *Type, igno
1585015862
return constrained
1585115863
}
1585215864

15865+
func (b *KeyBuilder) WriteNodeId(id ast.NodeId) {
15866+
b.WriteUint64(uint64(id))
15867+
}
15868+
1585315869
func (b *KeyBuilder) WriteNode(node *ast.Node) {
1585415870
if node != nil {
15855-
b.WriteInt(int(ast.GetNodeId(node)))
15871+
b.WriteNodeId(ast.GetNodeId(node))
1585615872
}
1585715873
}
1585815874

@@ -15917,7 +15933,7 @@ func getTupleKey(elementInfos []TupleElementInfo, readonly bool) string {
1591715933
b.WriteByte('*')
1591815934
}
1591915935
if e.labeledDeclaration != nil {
15920-
b.WriteInt(int(ast.GetNodeId(e.labeledDeclaration)))
15936+
b.WriteNode(e.labeledDeclaration)
1592115937
}
1592215938
}
1592315939
if readonly {
@@ -15946,7 +15962,7 @@ func getIndexedAccessKey(objectType *Type, indexType *Type, accessFlags AccessFl
1594615962
b.WriteByte(',')
1594715963
b.WriteType(indexType)
1594815964
b.WriteByte(',')
15949-
b.WriteInt(int(accessFlags))
15965+
b.WriteUint64(uint64(accessFlags))
1595015966
b.WriteAlias(alias)
1595115967
return b.String()
1595215968
}
@@ -15993,7 +16009,7 @@ func getRelationKey(source *Type, target *Type, intersectionState IntersectionSt
1599316009
}
1599416010
if intersectionState != IntersectionStateNone {
1599516011
b.WriteByte(':')
15996-
b.WriteInt(int(intersectionState))
16012+
b.WriteUint64(uint64(intersectionState))
1599716013
}
1599816014
if constrained {
1599916015
// We mark keys with type references that reference constrained type parameters such that we know

‎internal/checker/flow.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,7 +1622,7 @@ func (c *Checker) writeFlowCacheKey(b *KeyBuilder, node *ast.Node, declaredType
16221622
}
16231623
ifflowContainer!=nil {
16241624
b.WriteByte('@')
1625-
b.WriteInt(int(ast.GetNodeId(flowContainer)))
1625+
b.WriteNode(flowContainer)
16261626
}
16271627
returntrue
16281628
caseast.KindNonNullExpression,ast.KindParenthesizedExpression:
@@ -1656,7 +1656,7 @@ func (c *Checker) writeFlowCacheKey(b *KeyBuilder, node *ast.Node, declaredType
16561656
}
16571657
caseast.KindObjectBindingPattern,ast.KindArrayBindingPattern,ast.KindFunctionDeclaration,
16581658
ast.KindFunctionExpression,ast.KindArrowFunction,ast.KindMethodDeclaration:
1659-
b.WriteInt(int(ast.GetNodeId(node)))
1659+
b.WriteNode(node)
16601660
b.WriteByte('#')
16611661
b.WriteType(declaredType)
16621662
returntrue

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp