Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: pkg/compiler/lib/src/ssa/kernel_impact.dart

Issue 2861733002: Handle const Symbol(...) in kernel_impact (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'package:kernel/ast.dart' as ir; 5 import 'package:kernel/ast.dart' as ir;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../common/names.dart'; 8 import '../common/names.dart';
9 import '../compiler.dart'; 9 import '../compiler.dart';
10 import '../constants/expressions.dart'; 10 import '../constants/expressions.dart';
11 import '../constants/values.dart';
11 import '../common_elements.dart'; 12 import '../common_elements.dart';
12 import '../elements/types.dart'; 13 import '../elements/types.dart';
13 import '../elements/elements.dart' show AstElement, ResolvedAst; 14 import '../elements/elements.dart' show AstElement, ResolvedAst;
14 import '../elements/entities.dart'; 15 import '../elements/entities.dart';
15 import '../js_backend/backend.dart' show JavaScriptBackend; 16 import '../js_backend/backend.dart' show JavaScriptBackend;
16 import '../kernel/element_adapter.dart'; 17 import '../kernel/element_adapter.dart';
17 import '../kernel/kernel.dart'; 18 import '../kernel/kernel.dart';
18 import '../resolution/registry.dart' show ResolutionWorldImpactBuilder; 19 import '../resolution/registry.dart' show ResolutionWorldImpactBuilder;
19 import '../universe/call_structure.dart'; 20 import '../universe/call_structure.dart';
20 import '../universe/feature.dart'; 21 import '../universe/feature.dart';
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 target.enclosingClass, node.arguments.types); 274 target.enclosingClass, node.arguments.types);
274 CallStructure callStructure = 275 CallStructure callStructure =
275 elementAdapter.getCallStructure(node.arguments); 276 elementAdapter.getCallStructure(node.arguments);
276 impactBuilder.registerStaticUse(isConst 277 impactBuilder.registerStaticUse(isConst
277 ? new StaticUse.constConstructorInvoke(constructor, callStructure, type) 278 ? new StaticUse.constConstructorInvoke(constructor, callStructure, type)
278 : new StaticUse.typedConstructorInvoke( 279 : new StaticUse.typedConstructorInvoke(
279 constructor, callStructure, type)); 280 constructor, callStructure, type));
280 if (type.typeArguments.any((DartType type) => !type.isDynamic)) { 281 if (type.typeArguments.any((DartType type) => !type.isDynamic)) {
281 impactBuilder.registerFeature(Feature.TYPE_VARIABLE_BOUNDS_CHECK); 282 impactBuilder.registerFeature(Feature.TYPE_VARIABLE_BOUNDS_CHECK);
282 } 283 }
284 if (isConst && commonElements.isSymbolConstructor(constructor)) {
285 ConstantValue value =
286 elementAdapter.getConstantValue(node.arguments.positional.first);
287 if (!value.isString) {
288 throw new SpannableAssertionFailure(
289 CURRENT_ELEMENT_SPANNABLE,
290 "Unexpected constant value in const Symbol(...) call: "
291 "${value.toStructuredText()}");
292 }
293 StringConstantValue stringValue = value;
294 impactBuilder
295 .registerConstSymbolName(stringValue.primitiveValue.slowToString());
296 }
283 } 297 }
284 298
285 @override 299 @override
286 void visitSuperInitializer(ir.SuperInitializer node) { 300 void visitSuperInitializer(ir.SuperInitializer node) {
287 ConstructorEntity target = elementAdapter.getConstructor(node.target); 301 ConstructorEntity target = elementAdapter.getConstructor(node.target);
288 _visitArguments(node.arguments); 302 _visitArguments(node.arguments);
289 impactBuilder.registerStaticUse(new StaticUse.superConstructorInvoke( 303 impactBuilder.registerStaticUse(new StaticUse.superConstructorInvoke(
290 target, elementAdapter.getCallStructure(node.arguments))); 304 target, elementAdapter.getCallStructure(node.arguments)));
291 } 305 }
292 306
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 ConstructorEntity target = elementAdapter.getConstructor(node.target); 593 ConstructorEntity target = elementAdapter.getConstructor(node.target);
580 impactBuilder.registerStaticUse(new StaticUse.superConstructorInvoke( 594 impactBuilder.registerStaticUse(new StaticUse.superConstructorInvoke(
581 target, elementAdapter.getCallStructure(node.arguments))); 595 target, elementAdapter.getCallStructure(node.arguments)));
582 } 596 }
583 597
584 // TODO(johnniwinther): Make this throw and visit child nodes explicitly 598 // TODO(johnniwinther): Make this throw and visit child nodes explicitly
585 // instead to ensure that we don't visit unwanted parts of the ir. 599 // instead to ensure that we don't visit unwanted parts of the ir.
586 @override 600 @override
587 void defaultNode(ir.Node node) => node.visitChildren(this); 601 void defaultNode(ir.Node node) => node.visitChildren(this);
588 } 602 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart ('k') | tests/compiler/dart2js/kernel/closed_world2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698