Skip to content

Commit ea8da90

Browse files
scheglovCommit Queue
authored andcommitted
Elements. Standardize to Uint30/Uint32 in binary I/O.
Unify method names to use `Uint` (not `UInt`) for 30- and 32-bit helpers across analyzer binaries. This aligns with Dart’s `dart:typed_data` naming (e.g., `Uint8List`) and removes mixed spelling that caused confusion. Behavior and wire format are unchanged; this is a pure API rename with call-site updates. Key renames (old → new): - `readUInt30` → `readUint30` - `readOptionalUInt30` → `readOptionalUint30` - `readUInt30List` → `readUint30List` - `readUInt32` → `readUint32` - `readUInt32List` → `readUint32List` - `writeUInt30` → `writeUint30` - `writeOptionalUInt30` → `writeOptionalUint30` - `writeUInt32` → `writeUint32` Internal helpers were updated similarly (e.g., `_readUInt32` → `_readUint32`, `_writeUInt30` → `_writeUint30`), and all uses in `binary_reader.dart`, `binary_writer.dart`, string tables, unlinked data, fine-manifest code, and summary2 readers/writers were adjusted. Rationale: - Consistent API surface that matches Dart conventions. - Clearer intent for unsigned-width encodings. - Zero impact on serialization format or runtime behavior. Change-Id: I0d76239da8809b0187e8db975ec35cb46d08aab0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/449144 Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 74f753f commit ea8da90

15 files changed

+218
-218
lines changed

pkg/analyzer/lib/src/binary/binary_reader.dart

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class SummaryDataReader {
7979
required K Function() readKey,
8080
required V Function() readValue,
8181
}) {
82-
var length = readUInt30();
82+
var length = readUint30();
8383
if (length == 0) {
8484
return const {};
8585
}
@@ -119,16 +119,16 @@ class SummaryDataReader {
119119
}
120120
}
121121

122-
int? readOptionalUInt30() {
122+
int? readOptionalUint30() {
123123
if (readBool()) {
124-
return readUInt30();
124+
return readUint30();
125125
} else {
126126
return null;
127127
}
128128
}
129129

130130
String readStringReference() {
131-
var index = readUInt30();
131+
var index = readUint30();
132132
return stringOfIndex(index);
133133
}
134134

@@ -146,7 +146,7 @@ class SummaryDataReader {
146146
}
147147

148148
Set<String> readStringUtf8Set() {
149-
var length = readUInt30();
149+
var length = readUint30();
150150
var result = <String>{};
151151
for (var i = 0; i < length; i++) {
152152
var item = readStringUtf8();
@@ -156,7 +156,7 @@ class SummaryDataReader {
156156
}
157157

158158
List<T> readTypedList<T>(T Function() read) {
159-
var length = readUInt30();
159+
var length = readUint30();
160160
if (length == 0) {
161161
return const <Never>[];
162162
}
@@ -166,7 +166,7 @@ class SummaryDataReader {
166166
}
167167

168168
List<T> readTypedListCast<T>(Object? Function() read) {
169-
var length = readUInt30();
169+
var length = readUint30();
170170
if (length == 0) {
171171
return const <Never>[];
172172
}
@@ -175,7 +175,7 @@ class SummaryDataReader {
175175
}, growable: false);
176176
}
177177

178-
int readUInt30() {
178+
int readUint30() {
179179
var byte = readByte();
180180
if (byte & 0x80 == 0) {
181181
// 0xxxxxxx
@@ -192,33 +192,33 @@ class SummaryDataReader {
192192
}
193193
}
194194

195-
Uint32List readUInt30List() {
196-
var length = readUInt30();
195+
Uint32List readUint30List() {
196+
var length = readUint30();
197197
var result = Uint32List(length);
198198
for (var i = 0; i < length; ++i) {
199-
result[i] = readUInt30();
199+
result[i] = readUint30();
200200
}
201201
return result;
202202
}
203203

204-
int readUInt32() {
204+
int readUint32() {
205205
return (readByte() << 24) |
206206
(readByte() << 16) |
207207
(readByte() << 8) |
208208
readByte();
209209
}
210210

211-
Uint32List readUInt32List() {
212-
var length = readUInt32();
211+
Uint32List readUint32List() {
212+
var length = readUint32();
213213
var result = Uint32List(length);
214214
for (var i = 0; i < length; ++i) {
215-
result[i] = readUInt32();
215+
result[i] = readUint32();
216216
}
217217
return result;
218218
}
219219

220220
Uint8List readUint8List() {
221-
var length = readUInt30();
221+
var length = readUint30();
222222
var result = Uint8List.sublistView(bytes, offset, offset + length);
223223
offset += length;
224224
return result;

pkg/analyzer/lib/src/binary/binary_writer.dart

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class BufferedSink {
126126
}
127127

128128
void writeList<T>(List<T> items, void Function(T x) writeItem) {
129-
writeUInt30(items.length);
129+
writeUint30(items.length);
130130
for (var i = 0; i < items.length; i++) {
131131
writeItem(items[i]);
132132
}
@@ -137,7 +137,7 @@ class BufferedSink {
137137
required void Function(K key) writeKey,
138138
required void Function(V value) writeValue,
139139
}) {
140-
writeUInt30(map.length);
140+
writeUint30(map.length);
141141
for (var entry in map.entries) {
142142
writeKey(entry.key);
143143
writeValue(entry.value);
@@ -171,10 +171,10 @@ class BufferedSink {
171171
}
172172
}
173173

174-
void writeOptionalUInt30(int? value) {
174+
void writeOptionalUint30(int? value) {
175175
if (value != null) {
176176
writeBool(true);
177-
writeUInt30(value);
177+
writeUint30(value);
178178
} else {
179179
writeBool(false);
180180
}
@@ -187,14 +187,14 @@ class BufferedSink {
187187
}
188188

189189
void writeStringUtf8Iterable(Iterable<String> items) {
190-
writeUInt30(items.length);
190+
writeUint30(items.length);
191191
for (var item in items) {
192192
writeStringUtf8(item);
193193
}
194194
}
195195

196196
@pragma("vm:prefer-inline")
197-
void writeUInt30(int value) {
197+
void writeUint30(int value) {
198198
assert(value >= 0 && value >> 30 == 0);
199199
if (value < 0x80) {
200200
_addByte(value);
@@ -212,13 +212,13 @@ class BufferedSink {
212212

213213
void writeUint30List(List<int> values) {
214214
var length = values.length;
215-
writeUInt30(length);
215+
writeUint30(length);
216216
for (var i = 0; i < length; i++) {
217-
writeUInt30(values[i]);
217+
writeUint30(values[i]);
218218
}
219219
}
220220

221-
void writeUInt32(int value) {
221+
void writeUint32(int value) {
222222
_addByte4(
223223
(value >> 24) & 0xFF,
224224
(value >> 16) & 0xFF,
@@ -228,7 +228,7 @@ class BufferedSink {
228228
}
229229

230230
void writeUint8List(Uint8List bytes) {
231-
writeUInt30(bytes.length);
231+
writeUint30(bytes.length);
232232
writeBytes(bytes);
233233
}
234234

pkg/analyzer/lib/src/binary/string_table.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class StringIndexer {
3636
var resultOffset = sink.offset;
3737

3838
var lengthOfBytes = sink.offset - bytesOffset;
39-
sink.writeUInt30(lengthOfBytes);
39+
sink.writeUint30(lengthOfBytes);
4040
sink.writeUint30List(lengths);
4141

4242
return resultOffset;
@@ -96,12 +96,12 @@ class StringTable {
9696
StringTable({required Uint8List bytes, required int startOffset})
9797
: _bytes = bytes,
9898
_byteOffset = startOffset {
99-
var offset = startOffset - _readUInt30();
100-
var length = _readUInt30();
99+
var offset = startOffset - _readUint30();
100+
var length = _readUint30();
101101

102102
_offsets = Uint32List(length + 1);
103103
for (var i = 0; i < length; i++) {
104-
var stringLength = _readUInt30();
104+
var stringLength = _readUint30();
105105
_offsets[i] = offset;
106106
offset += stringLength;
107107
}
@@ -139,7 +139,7 @@ class StringTable {
139139
return String.fromCharCodes(_bytes, start, end);
140140
}
141141

142-
int _readUInt30() {
142+
int _readUint30() {
143143
var byte = _readByte();
144144
if (byte & 0x80 == 0) {
145145
// 0xxxxxxx

pkg/analyzer/lib/src/dart/analysis/unlinked_data.dart

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,16 @@ class UnlinkedCombinator {
7777

7878
factory UnlinkedCombinator.read(SummaryDataReader reader) {
7979
return UnlinkedCombinator(
80-
keywordOffset: reader.readUInt30(),
81-
endOffset: reader.readUInt30(),
80+
keywordOffset: reader.readUint30(),
81+
endOffset: reader.readUint30(),
8282
isShow: reader.readBool(),
8383
names: reader.readStringUtf8List(),
8484
);
8585
}
8686

8787
void write(BufferedSink sink) {
88-
sink.writeUInt30(keywordOffset);
89-
sink.writeUInt30(endOffset);
88+
sink.writeUint30(keywordOffset);
89+
sink.writeUint30(endOffset);
9090
sink.writeBool(isShow);
9191
sink.writeStringUtf8Iterable(names);
9292
}
@@ -163,7 +163,7 @@ class UnlinkedLibraryExportDirective extends UnlinkedNamespaceDirective {
163163
configurations: reader.readTypedList(
164164
() => UnlinkedNamespaceDirectiveConfiguration.read(reader),
165165
),
166-
exportKeywordOffset: reader.readUInt30(),
166+
exportKeywordOffset: reader.readUint30(),
167167
uri: reader.readOptionalStringUtf8(),
168168
);
169169
}
@@ -175,7 +175,7 @@ class UnlinkedLibraryExportDirective extends UnlinkedNamespaceDirective {
175175
) {
176176
x.write(sink);
177177
});
178-
sink.writeUInt30(exportKeywordOffset);
178+
sink.writeUint30(exportKeywordOffset);
179179
sink.writeOptionalStringUtf8(uri);
180180
}
181181
}
@@ -203,7 +203,7 @@ class UnlinkedLibraryImportDirective extends UnlinkedNamespaceDirective {
203203
configurations: reader.readTypedList(
204204
() => UnlinkedNamespaceDirectiveConfiguration.read(reader),
205205
),
206-
importKeywordOffset: reader.readUInt30() - 1,
206+
importKeywordOffset: reader.readUint30() - 1,
207207
isDocImport: reader.readBool(),
208208
isSyntheticDartCore: reader.readBool(),
209209
prefix: reader.readOptionalObject(
@@ -220,7 +220,7 @@ class UnlinkedLibraryImportDirective extends UnlinkedNamespaceDirective {
220220
) {
221221
x.write(sink);
222222
});
223-
sink.writeUInt30(1 + importKeywordOffset);
223+
sink.writeUint30(1 + importKeywordOffset);
224224
sink.writeBool(isDocImport);
225225
sink.writeBool(isSyntheticDartCore);
226226
sink.writeOptionalObject<UnlinkedLibraryImportPrefix>(
@@ -246,19 +246,19 @@ class UnlinkedLibraryImportPrefix {
246246

247247
factory UnlinkedLibraryImportPrefix.read(SummaryDataReader reader) {
248248
return UnlinkedLibraryImportPrefix(
249-
deferredOffset: reader.readOptionalUInt30(),
250-
asOffset: reader.readUInt30(),
251-
nameOffset: reader.readUInt30(),
249+
deferredOffset: reader.readOptionalUint30(),
250+
asOffset: reader.readUint30(),
251+
nameOffset: reader.readUint30(),
252252
name: reader.readOptionalObject(
253253
() => UnlinkedLibraryImportPrefixName.read(reader),
254254
),
255255
);
256256
}
257257

258258
void write(BufferedSink sink) {
259-
sink.writeOptionalUInt30(deferredOffset);
260-
sink.writeUInt30(asOffset);
261-
sink.writeUInt30(nameOffset);
259+
sink.writeOptionalUint30(deferredOffset);
260+
sink.writeUint30(asOffset);
261+
sink.writeUint30(nameOffset);
262262
sink.writeOptionalObject(name, (name) {
263263
name.write(sink);
264264
});
@@ -277,13 +277,13 @@ class UnlinkedLibraryImportPrefixName {
277277
factory UnlinkedLibraryImportPrefixName.read(SummaryDataReader reader) {
278278
return UnlinkedLibraryImportPrefixName(
279279
name: reader.readStringUtf8(),
280-
nameOffset: reader.readUInt30(),
280+
nameOffset: reader.readUint30(),
281281
);
282282
}
283283

284284
void write(BufferedSink sink) {
285285
sink.writeStringUtf8(name);
286-
sink.writeUInt30(nameOffset);
286+
sink.writeUint30(nameOffset);
287287
}
288288
}
289289

@@ -355,7 +355,7 @@ class UnlinkedPartDirective extends UnlinkedConfigurableUriDirective {
355355
configurations: reader.readTypedList(
356356
() => UnlinkedNamespaceDirectiveConfiguration.read(reader),
357357
),
358-
partKeywordOffset: reader.readUInt30(),
358+
partKeywordOffset: reader.readUint30(),
359359
uri: reader.readOptionalStringUtf8(),
360360
);
361361
}
@@ -366,7 +366,7 @@ class UnlinkedPartDirective extends UnlinkedConfigurableUriDirective {
366366
) {
367367
x.write(sink);
368368
});
369-
sink.writeUInt30(partKeywordOffset);
369+
sink.writeUint30(partKeywordOffset);
370370
sink.writeOptionalStringUtf8(uri);
371371
}
372372
}
@@ -446,14 +446,14 @@ class UnlinkedSourceRange {
446446

447447
factory UnlinkedSourceRange.read(SummaryDataReader reader) {
448448
return UnlinkedSourceRange(
449-
offset: reader.readUInt30(),
450-
length: reader.readUInt30(),
449+
offset: reader.readUint30(),
450+
length: reader.readUint30(),
451451
);
452452
}
453453

454454
void write(BufferedSink sink) {
455-
sink.writeUInt30(offset);
456-
sink.writeUInt30(length);
455+
sink.writeUint30(offset);
456+
sink.writeUint30(length);
457457
}
458458
}
459459

@@ -531,7 +531,7 @@ class UnlinkedUnit {
531531
libraryDirective: reader.readOptionalObject(
532532
() => UnlinkedLibraryDirective.read(reader),
533533
),
534-
lineStarts: reader.readUInt30List(),
534+
lineStarts: reader.readUint30List(),
535535
parts: reader.readTypedList(() => UnlinkedPartDirective.read(reader)),
536536
partOfNameDirective: reader.readOptionalObject(
537537
() => UnlinkedPartOfNameDirective.read(reader),

pkg/analyzer/lib/src/fine/lookup_name.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ extension type LookupName(String _it) {
119119

120120
extension BufferedSinkExtension on BufferedSink {
121121
void writeBaseNameIterable(Iterable<BaseName> names) {
122-
writeUInt30(names.length);
122+
writeUint30(names.length);
123123
for (var baseName in names) {
124124
baseName.write(this);
125125
}
@@ -154,7 +154,7 @@ extension StringExtension on String {
154154

155155
extension SummaryDataReaderExtension on SummaryDataReader {
156156
Set<BaseName> readBaseNameSet() {
157-
var length = readUInt30();
157+
var length = readUint30();
158158
var result = <BaseName>{};
159159
for (var i = 0; i < length; i++) {
160160
var baseName = BaseName.read(this);
@@ -168,7 +168,7 @@ extension SummaryDataReaderExtension on SummaryDataReader {
168168
}
169169

170170
Set<LookupName> readLookupNameSet() {
171-
var length = readUInt30();
171+
var length = readUint30();
172172
var result = <LookupName>{};
173173
for (var i = 0; i < length; i++) {
174174
var lookupName = LookupName.read(this);

pkg/analyzer/lib/src/fine/manifest_ast.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ class ManifestNode {
118118
return ManifestNode._(
119119
isValid: reader.readBool(),
120120
tokenBuffer: reader.readStringUtf8(),
121-
tokenLengthList: reader.readUInt30List(),
121+
tokenLengthList: reader.readUint30List(),
122122
elements: ManifestElement.readList(reader),
123-
elementIndexList: reader.readUInt30List(),
123+
elementIndexList: reader.readUint30List(),
124124
);
125125
}
126126

0 commit comments

Comments
 (0)