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

Side by Side Diff: pkg/compiler/lib/src/js_backend/namer.dart

Issue 2688413003: Extract BackendUsage, MirrorsData, and CheckedModeHelpers from Backend. (Closed)
Patch Set: Cleanup Created 3 years, 10 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 library js_backend.namer; 5 library js_backend.namer;
6 6
7 import 'dart:collection' show HashMap; 7 import 'dart:collection' show HashMap;
8 8
9 import 'package:js_runtime/shared/embedded_names.dart' show JsGetName; 9 import 'package:js_runtime/shared/embedded_names.dart' show JsGetName;
10 10
11 import '../closure.dart'; 11 import '../closure.dart';
12 import '../common.dart'; 12 import '../common.dart';
13 import '../common/names.dart' show Identifiers, Selectors; 13 import '../common/names.dart' show Identifiers, Selectors;
14 import '../constants/values.dart'; 14 import '../constants/values.dart';
15 import '../core_types.dart' show CommonElements; 15 import '../core_types.dart' show CommonElements;
16 import '../elements/resolution_types.dart';
17 import '../diagnostics/invariant.dart' show DEBUG_MODE; 16 import '../diagnostics/invariant.dart' show DEBUG_MODE;
18 import '../elements/elements.dart'; 17 import '../elements/elements.dart';
19 import '../elements/entities.dart'; 18 import '../elements/entities.dart';
19 import '../elements/resolution_types.dart';
20 import '../elements/types.dart';
20 import '../js/js.dart' as jsAst; 21 import '../js/js.dart' as jsAst;
21 import '../js/js.dart' show js; 22 import '../js/js.dart' show js;
22 import '../tree/tree.dart'; 23 import '../tree/tree.dart';
23 import '../universe/call_structure.dart' show CallStructure; 24 import '../universe/call_structure.dart' show CallStructure;
24 import '../universe/selector.dart' show Selector, SelectorKind; 25 import '../universe/selector.dart' show Selector, SelectorKind;
25 import '../universe/world_builder.dart' show CodegenWorldBuilder; 26 import '../universe/world_builder.dart' show CodegenWorldBuilder;
26 import 'package:front_end/src/fasta/scanner/characters.dart'; 27 import 'package:front_end/src/fasta/scanner/characters.dart';
27 import '../util/util.dart'; 28 import '../util/util.dart';
28 import '../world.dart' show ClosedWorld; 29 import '../world.dart' show ClosedWorld;
29 import 'backend.dart'; 30 import 'backend.dart';
(...skipping 1550 matching lines...) Expand 10 before | Expand all | Expand 10 after
1580 new HashMap<ResolutionFunctionType, jsAst.Name>(); 1581 new HashMap<ResolutionFunctionType, jsAst.Name>();
1581 final FunctionTypeNamer functionTypeNamer; 1582 final FunctionTypeNamer functionTypeNamer;
1582 1583
1583 jsAst.Name getFunctionTypeName(ResolutionFunctionType functionType) { 1584 jsAst.Name getFunctionTypeName(ResolutionFunctionType functionType) {
1584 return functionTypeNameMap.putIfAbsent(functionType, () { 1585 return functionTypeNameMap.putIfAbsent(functionType, () {
1585 String proposedName = functionTypeNamer.computeName(functionType); 1586 String proposedName = functionTypeNamer.computeName(functionType);
1586 return getFreshName(instanceScope, proposedName); 1587 return getFreshName(instanceScope, proposedName);
1587 }); 1588 });
1588 } 1589 }
1589 1590
1590 jsAst.Name operatorIsType(ResolutionDartType type) { 1591 jsAst.Name operatorIsType(DartType type) {
1591 if (type.isFunctionType) { 1592 if (type.isFunctionType) {
1592 // TODO(erikcorry): Reduce from $isx to ix when we are minifying. 1593 // TODO(erikcorry): Reduce from $isx to ix when we are minifying.
1593 return new CompoundName([ 1594 return new CompoundName([
1594 new StringBackedName(operatorIsPrefix), 1595 new StringBackedName(operatorIsPrefix),
1595 _literalUnderscore, 1596 _literalUnderscore,
1596 getFunctionTypeName(type) 1597 getFunctionTypeName(type)
1597 ]); 1598 ]);
1598 } 1599 }
1599 return operatorIs(type.element); 1600 InterfaceType interfaceType = type;
1601 return operatorIs(interfaceType.element);
1600 } 1602 }
1601 1603
1602 jsAst.Name operatorIs(ClassElement element) { 1604 jsAst.Name operatorIs(ClassElement element) {
1603 // TODO(erikcorry): Reduce from $isx to ix when we are minifying. 1605 // TODO(erikcorry): Reduce from $isx to ix when we are minifying.
1604 return new CompoundName( 1606 return new CompoundName(
1605 [new StringBackedName(operatorIsPrefix), runtimeTypeName(element)]); 1607 [new StringBackedName(operatorIsPrefix), runtimeTypeName(element)]);
1606 } 1608 }
1607 1609
1608 /// Returns a name that does not clash with reserved JS keywords. 1610 /// Returns a name that does not clash with reserved JS keywords.
1609 String _sanitizeForKeywords(String name) { 1611 String _sanitizeForKeywords(String name) {
1610 if (jsReserved.contains(name)) { 1612 if (jsReserved.contains(name)) {
1611 name = '\$$name'; 1613 name = '\$$name';
1612 } 1614 }
1613 assert(!jsReserved.contains(name)); 1615 assert(!jsReserved.contains(name));
1614 return name; 1616 return name;
1615 } 1617 }
1616 1618
1617 jsAst.Name substitutionName(Element element) { 1619 jsAst.Name substitutionName(ClassElement element) {
1618 return new CompoundName( 1620 return new CompoundName(
1619 [new StringBackedName(operatorAsPrefix), runtimeTypeName(element)]); 1621 [new StringBackedName(operatorAsPrefix), runtimeTypeName(element)]);
1620 } 1622 }
1621 1623
1622 /// Translates a [String] into the corresponding [Name] data structure as 1624 /// Translates a [String] into the corresponding [Name] data structure as
1623 /// used by the namer. 1625 /// used by the namer.
1624 /// 1626 ///
1625 /// If [name] is a setter or getter name, the corresponding [GetterName] or 1627 /// If [name] is a setter or getter name, the corresponding [GetterName] or
1626 /// [SetterName] data structure is used. 1628 /// [SetterName] data structure is used.
1627 jsAst.Name asName(String name) { 1629 jsAst.Name asName(String name) {
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
2191 void addSuggestion(String original, String suggestion) { 2193 void addSuggestion(String original, String suggestion) {
2192 assert(!_suggestedNames.containsKey(original)); 2194 assert(!_suggestedNames.containsKey(original));
2193 _suggestedNames[original] = suggestion; 2195 _suggestedNames[original] = suggestion;
2194 } 2196 }
2195 2197
2196 bool hasSuggestion(String original) => _suggestedNames.containsKey(original); 2198 bool hasSuggestion(String original) => _suggestedNames.containsKey(original);
2197 bool isSuggestion(String candidate) { 2199 bool isSuggestion(String candidate) {
2198 return _suggestedNames.containsValue(candidate); 2200 return _suggestedNames.containsValue(candidate);
2199 } 2201 }
2200 } 2202 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/mirrors_data.dart ('k') | pkg/compiler/lib/src/js_backend/type_variable_handler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698