Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit c23ec46

Browse files
author
Dart CI
committed
Version 2.18.0-114.0.dev
Merge commit 'f6dd05939d273004aa5fc22e235cd72022113f22' into 'dev'
2 parents 00a9662 + f6dd059 commit c23ec46

File tree

5 files changed

+45
-42
lines changed

5 files changed

+45
-42
lines changed

DEPS

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ vars = {
114114
"fixnum_rev": "3bfc2ed1eea7e7acb79ad4f17392f92c816fc5ce",
115115
"glob_rev": "e10eb2407c58427144004458ef85c9bbf7286e56",
116116
"html_rev": "f108bce59d136c584969fd24a5006914796cf213",
117-
"http_io_rev": "2fa188caf7937e313026557713f7feffedd4978b",
117+
"http_io_rev": "405fc79233b4a3d4bb079ebf438bb2caf2f49355",
118118
"http_multi_server_rev": "34bf7f04b61cce561f47f7f275c2cc811534a05a",
119119
"http_parser_rev": "9126ee04e77fd8e4e2e6435b503ee4dd708d7ddc",
120120
"http_rev": "2c9b418f5086f999c150d18172d2eec1f963de7b",

pkg/compiler/lib/src/ir/annotations.dart

+32-33
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// @dart = 2.10
6-
75
import 'package:kernel/ast.dart' as ir;
86
import 'package:kernel/type_environment.dart' as ir;
97
import '../common/names.dart';
10-
import 'modular.dart';
8+
import 'modular_migrated.dart';
119

1210
class IrAnnotationData {
1311
final Map<ir.Class, String> _nativeClassNames = {};
@@ -25,13 +23,13 @@ class IrAnnotationData {
2523
{};
2624

2725
// Returns the text from the `@Native(<text>)` annotation of [node], if any.
28-
String getNativeClassName(ir.Class node) => _nativeClassNames[node];
26+
String? getNativeClassName(ir.Class node) => _nativeClassNames[node];
2927

3028
// Returns `true` if [node] has a native body, as in `method() native;`.
3129
bool hasNativeBody(ir.Member node) => _nativeMembers.contains(node);
3230

3331
// Returns the text from the `@JSName(<text>)` annotation of [node], if any.
34-
String getNativeMemberName(ir.Member node) => _nativeMemberNames[node];
32+
String? getNativeMemberName(ir.Member node) => _nativeMemberNames[node];
3533

3634
// Returns a list of the text from the `@Creates(<text>)` annotation of
3735
// [node].
@@ -44,18 +42,18 @@ class IrAnnotationData {
4442
_returnsAnnotations[node] ?? const [];
4543

4644
// Returns the text from the `@JS(<text>)` annotation of [node], if any.
47-
String getJsInteropLibraryName(ir.Library node) =>
45+
String? getJsInteropLibraryName(ir.Library node) =>
4846
_jsInteropLibraryNames[node];
4947

5048
// Returns the text from the `@JS(<text>)` annotation of [node], if any.
51-
String getJsInteropClassName(ir.Class node) => _jsInteropClassNames[node];
49+
String? getJsInteropClassName(ir.Class node) => _jsInteropClassNames[node];
5250

5351
// Returns `true` if [node] is annotated with `@anonymous`.
5452
bool isAnonymousJsInteropClass(ir.Class node) =>
5553
_anonymousJsInteropClasses.contains(node);
5654

5755
// Returns the text from the `@JS(<text>)` annotation of [node], if any.
58-
String getJsInteropMemberName(ir.Member node) => _jsInteropMemberNames[node];
56+
String? getJsInteropMemberName(ir.Member node) => _jsInteropMemberNames[node];
5957

6058
// Returns a list of the `@pragma('dart2js:<suffix>')` annotations on [node].
6159
List<PragmaAnnotationData> getMemberPragmaAnnotationData(ir.Member node) =>
@@ -76,7 +74,7 @@ class IrAnnotationData {
7674
});
7775
}
7876

79-
void forEachJsInteropMember(void Function(ir.Member, String) f) {
77+
void forEachJsInteropMember(void Function(ir.Member, String?) f) {
8078
_jsInteropLibraryNames.forEach((ir.Library library, _) {
8179
for (ir.Member member in library.members) {
8280
if (member.isExternal) {
@@ -87,7 +85,7 @@ class IrAnnotationData {
8785
_jsInteropClassNames.forEach((ir.Class cls, _) {
8886
for (ir.Member member in cls.members) {
8987
if (member is ir.Field) continue;
90-
String name = _jsInteropMemberNames[member];
88+
String? name = _jsInteropMemberNames[member];
9189
if (member.isExternal) {
9290
name ??= member.name.text;
9391
}
@@ -131,15 +129,15 @@ IrAnnotationData processAnnotations(ModularCore modularCore) {
131129
void processMember(ir.Member member) {
132130
ir.StaticTypeContext staticTypeContext = ir.StaticTypeContext(
133131
member, modularCore.constantEvaluator.typeEnvironment);
134-
List<PragmaAnnotationData> pragmaAnnotations;
135-
List<String> createsAnnotations;
136-
List<String> returnsAnnotations;
132+
List<PragmaAnnotationData>? pragmaAnnotations;
133+
List<String>? createsAnnotations;
134+
List<String>? returnsAnnotations;
137135
for (ir.Expression annotation in member.annotations) {
138136
if (annotation is ir.ConstantExpression) {
139137
ir.Constant constant = modularCore.constantEvaluator
140138
.evaluate(staticTypeContext, annotation);
141139

142-
String jsName = _getJsInteropName(constant);
140+
String? jsName = _getJsInteropName(constant);
143141
if (jsName != null) {
144142
data._jsInteropMemberNames[member] = jsName;
145143
}
@@ -149,28 +147,28 @@ IrAnnotationData processAnnotations(ModularCore modularCore) {
149147
data._nativeMembers.add(member);
150148
}
151149

152-
String nativeName = _getNativeMemberName(constant);
150+
String? nativeName = _getNativeMemberName(constant);
153151
if (nativeName != null) {
154152
data._nativeMemberNames[member] = nativeName;
155153
}
156154

157-
String creates = _getCreatesAnnotation(constant);
155+
String? creates = _getCreatesAnnotation(constant);
158156
if (creates != null) {
159157
if (createsAnnotations == null) {
160158
data._createsAnnotations[member] = createsAnnotations = [];
161159
}
162160
createsAnnotations.add(creates);
163161
}
164162

165-
String returns = _getReturnsAnnotation(constant);
163+
String? returns = _getReturnsAnnotation(constant);
166164
if (returns != null) {
167165
if (returnsAnnotations == null) {
168166
data._returnsAnnotations[member] = returnsAnnotations = [];
169167
}
170168
returnsAnnotations.add(returns);
171169
}
172170

173-
PragmaAnnotationData pragmaAnnotation = _getPragmaAnnotation(constant);
171+
PragmaAnnotationData? pragmaAnnotation = _getPragmaAnnotation(constant);
174172
if (pragmaAnnotation != null) {
175173
if (pragmaAnnotations == null) {
176174
data._memberPragmaAnnotations[member] = pragmaAnnotations = [];
@@ -190,7 +188,7 @@ IrAnnotationData processAnnotations(ModularCore modularCore) {
190188
ir.Constant constant = modularCore.constantEvaluator
191189
.evaluate(staticTypeContext, annotation);
192190

193-
String jsName = _getJsInteropName(constant);
191+
String? jsName = _getJsInteropName(constant);
194192
if (jsName != null) {
195193
data._jsInteropLibraryNames[library] = jsName;
196194
}
@@ -202,12 +200,12 @@ IrAnnotationData processAnnotations(ModularCore modularCore) {
202200
ir.Constant constant = modularCore.constantEvaluator
203201
.evaluate(staticTypeContext, annotation);
204202

205-
String nativeClassName = _getNativeClassName(constant);
203+
String? nativeClassName = _getNativeClassName(constant);
206204
if (nativeClassName != null) {
207205
data._nativeClassNames[cls] = nativeClassName;
208206
}
209207

210-
String jsName = _getJsInteropName(constant);
208+
String? jsName = _getJsInteropName(constant);
211209
if (jsName != null) {
212210
data._jsInteropClassNames[cls] = jsName;
213211
}
@@ -229,15 +227,15 @@ IrAnnotationData processAnnotations(ModularCore modularCore) {
229227
return data;
230228
}
231229

232-
String _getNativeClassName(ir.Constant constant) {
230+
String? _getNativeClassName(ir.Constant constant) {
233231
if (constant is ir.InstanceConstant) {
234232
// TODO(johnniwinther): Add an IrCommonElements for these queries; i.e.
235233
// `commonElements.isNativeAnnotationClass(constant.classNode)`.
236234
if (constant.classNode.name == 'Native' &&
237235
constant.classNode.enclosingLibrary.importUri == Uris.dart__js_helper) {
238236
if (constant.fieldValues.length == 1) {
239237
ir.Constant fieldValue = constant.fieldValues.values.single;
240-
String name;
238+
String? name;
241239
if (fieldValue is ir.StringConstant) {
242240
name = fieldValue.value;
243241
}
@@ -256,7 +254,7 @@ bool _isNativeMember(ir.Constant constant) {
256254
constant.classNode.enclosingLibrary.importUri == Uris.dart__internal;
257255
}
258256

259-
String _getNativeMemberName(ir.Constant constant) {
257+
String? _getNativeMemberName(ir.Constant constant) {
260258
if (constant is ir.InstanceConstant &&
261259
constant.classNode.name == 'JSName' &&
262260
constant.classNode.enclosingLibrary.importUri == Uris.dart__js_helper) {
@@ -269,7 +267,7 @@ String _getNativeMemberName(ir.Constant constant) {
269267
return null;
270268
}
271269

272-
String _getCreatesAnnotation(ir.Constant constant) {
270+
String? _getCreatesAnnotation(ir.Constant constant) {
273271
if (constant is ir.InstanceConstant &&
274272
constant.classNode.name == 'Creates' &&
275273
constant.classNode.enclosingLibrary.importUri == Uris.dart__js_helper) {
@@ -282,7 +280,7 @@ String _getCreatesAnnotation(ir.Constant constant) {
282280
return null;
283281
}
284282

285-
String _getReturnsAnnotation(ir.Constant constant) {
283+
String? _getReturnsAnnotation(ir.Constant constant) {
286284
if (constant is ir.InstanceConstant &&
287285
constant.classNode.name == 'Returns' &&
288286
constant.classNode.enclosingLibrary.importUri == Uris.dart__js_helper) {
@@ -295,7 +293,7 @@ String _getReturnsAnnotation(ir.Constant constant) {
295293
return null;
296294
}
297295

298-
String _getJsInteropName(ir.Constant constant) {
296+
String? _getJsInteropName(ir.Constant constant) {
299297
if (constant is ir.InstanceConstant &&
300298
constant.classNode.name == 'JS' &&
301299
(constant.classNode.enclosingLibrary.importUri == Uris.package_js ||
@@ -335,7 +333,7 @@ class PragmaAnnotationData {
335333
String toString() => 'PragmaAnnotationData($name)';
336334
}
337335

338-
PragmaAnnotationData _getPragmaAnnotation(ir.Constant constant) {
336+
PragmaAnnotationData? _getPragmaAnnotation(ir.Constant constant) {
339337
if (constant is! ir.InstanceConstant) return null;
340338
ir.InstanceConstant value = constant;
341339
ir.Class cls = value.classNode;
@@ -347,8 +345,8 @@ PragmaAnnotationData _getPragmaAnnotation(ir.Constant constant) {
347345
return const PragmaAnnotationData('tryInline');
348346
}
349347
} else if (uri == Uris.dart_core && cls.name == 'pragma') {
350-
ir.Constant nameValue;
351-
ir.Constant optionsValue;
348+
ir.Constant? nameValue;
349+
ir.Constant? optionsValue;
352350
value.fieldValues.forEach((ir.Reference reference, ir.Constant fieldValue) {
353351
ir.Field field = reference.asField;
354352
if (field.name.text == 'name') {
@@ -357,8 +355,9 @@ PragmaAnnotationData _getPragmaAnnotation(ir.Constant constant) {
357355
optionsValue = fieldValue;
358356
}
359357
});
360-
if (nameValue is! ir.StringConstant) return null;
361-
ir.StringConstant stringValue = nameValue;
358+
final nameValueFinal = nameValue;
359+
if (nameValueFinal is! ir.StringConstant) return null;
360+
ir.StringConstant stringValue = nameValueFinal;
362361
String name = stringValue.value;
363362
String prefix = 'dart2js:';
364363
if (!name.startsWith(prefix)) return null;
@@ -377,7 +376,7 @@ List<PragmaAnnotationData> computePragmaAnnotationDataFromIr(ir.Member member) {
377376
ir.Constant constant = constantExpression.constant;
378377
assert(constant is! ir.UnevaluatedConstant,
379378
"Unexpected unevaluated constant on $member: $metadata");
380-
PragmaAnnotationData data = _getPragmaAnnotation(constant);
379+
PragmaAnnotationData? data = _getPragmaAnnotation(constant);
381380
if (data != null) {
382381
annotations.add(data);
383382
}

pkg/compiler/lib/src/ir/modular.dart

+1-7
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,10 @@ import '../kernel/element_map.dart';
2020
import '../serialization/serialization.dart';
2121
import '../util/enumset.dart';
2222
import 'annotations.dart';
23-
import 'constants.dart';
2423
import 'impact.dart';
2524
import 'scope.dart';
2625

27-
class ModularCore {
28-
final ir.Component component;
29-
final Dart2jsConstantEvaluator constantEvaluator;
30-
31-
ModularCore(this.component, this.constantEvaluator);
32-
}
26+
export 'modular_migrated.dart';
3327

3428
class ModularMemberData {
3529
final ScopeModel scopeModel;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import 'package:compiler/src/ir/constants.dart';
2+
import 'package:kernel/ast.dart' as ir;
3+
4+
// TODO(48820): Move this back to modular.dart
5+
class ModularCore {
6+
final ir.Component component;
7+
final Dart2jsConstantEvaluator constantEvaluator;
8+
9+
ModularCore(this.component, this.constantEvaluator);
10+
}

tools/VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ CHANNEL dev
2727
MAJOR 2
2828
MINOR 18
2929
PATCH 0
30-
PRERELEASE 113
30+
PRERELEASE 114
3131
PRERELEASE_PATCH 0

0 commit comments

Comments
 (0)