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

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

Issue 2863073003: Access NativeData only through ClosedWorld (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) 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
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 jsAst.Name _rtiFieldJsName; 482 jsAst.Name _rtiFieldJsName;
483 jsAst.Name get rtiFieldJsName => 483 jsAst.Name get rtiFieldJsName =>
484 _rtiFieldJsName ??= new StringBackedName(rtiName); 484 _rtiFieldJsName ??= new StringBackedName(rtiName);
485 485
486 // Name of property in a class description for the native dispatch metadata. 486 // Name of property in a class description for the native dispatch metadata.
487 final String nativeSpecProperty = '%'; 487 final String nativeSpecProperty = '%';
488 488
489 static final RegExp IDENTIFIER = new RegExp(r'^[A-Za-z_$][A-Za-z0-9_$]*$'); 489 static final RegExp IDENTIFIER = new RegExp(r'^[A-Za-z_$][A-Za-z0-9_$]*$');
490 static final RegExp NON_IDENTIFIER_CHAR = new RegExp(r'[^A-Za-z_0-9$]'); 490 static final RegExp NON_IDENTIFIER_CHAR = new RegExp(r'[^A-Za-z_0-9$]');
491 491
492 final NativeData _nativeData;
493 final ClosedWorld _closedWorld; 492 final ClosedWorld _closedWorld;
494 final CodegenWorldBuilder _codegenWorldBuilder; 493 final CodegenWorldBuilder _codegenWorldBuilder;
495 494
496 RuntimeTypesEncoder _rtiEncoder; 495 RuntimeTypesEncoder _rtiEncoder;
497 RuntimeTypesEncoder get rtiEncoder { 496 RuntimeTypesEncoder get rtiEncoder {
498 assert(invariant(NO_LOCATION_SPANNABLE, _rtiEncoder != null, 497 assert(invariant(NO_LOCATION_SPANNABLE, _rtiEncoder != null,
499 message: "Namer.rtiEncoder has not been set.")); 498 message: "Namer.rtiEncoder has not been set."));
500 return _rtiEncoder; 499 return _rtiEncoder;
501 } 500 }
502 501
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 553
555 final Map<String, String> suggestedGlobalNames = <String, String>{}; 554 final Map<String, String> suggestedGlobalNames = <String, String>{};
556 final Map<String, String> suggestedInstanceNames = <String, String>{}; 555 final Map<String, String> suggestedInstanceNames = <String, String>{};
557 556
558 /// Used to store unique keys for library names. Keys are not used as names, 557 /// Used to store unique keys for library names. Keys are not used as names,
559 /// nor are they visible in the output. The only serve as an internal 558 /// nor are they visible in the output. The only serve as an internal
560 /// key into maps. 559 /// key into maps.
561 final Map<LibraryElement, String> _libraryKeys = 560 final Map<LibraryElement, String> _libraryKeys =
562 new HashMap<LibraryElement, String>(); 561 new HashMap<LibraryElement, String>();
563 562
564 Namer(this._nativeData, this._closedWorld, this._codegenWorldBuilder) { 563 Namer(this._closedWorld, this._codegenWorldBuilder) {
565 _literalAsyncPrefix = new StringBackedName(asyncPrefix); 564 _literalAsyncPrefix = new StringBackedName(asyncPrefix);
566 _literalGetterPrefix = new StringBackedName(getterPrefix); 565 _literalGetterPrefix = new StringBackedName(getterPrefix);
567 _literalSetterPrefix = new StringBackedName(setterPrefix); 566 _literalSetterPrefix = new StringBackedName(setterPrefix);
568 _literalLazyGetterPrefix = new StringBackedName(lazyGetterPrefix); 567 _literalLazyGetterPrefix = new StringBackedName(lazyGetterPrefix);
569 } 568 }
570 569
571 CommonElements get _commonElements => _closedWorld.commonElements; 570 CommonElements get _commonElements => _closedWorld.commonElements;
572 571
572 NativeData get _nativeData => _closedWorld.nativeData;
573
573 String get deferredTypesName => 'deferredTypes'; 574 String get deferredTypesName => 'deferredTypes';
574 String get isolateName => 'Isolate'; 575 String get isolateName => 'Isolate';
575 String get isolatePropertiesName => r'$isolateProperties'; 576 String get isolatePropertiesName => r'$isolateProperties';
576 jsAst.Name get noSuchMethodName => invocationName(Selectors.noSuchMethod_); 577 jsAst.Name get noSuchMethodName => invocationName(Selectors.noSuchMethod_);
577 578
578 /** 579 /**
579 * Some closures must contain their name. The name is stored in 580 * Some closures must contain their name. The name is stored in
580 * [STATIC_CLOSURE_NAME_NAME]. 581 * [STATIC_CLOSURE_NAME_NAME].
581 */ 582 */
582 String get STATIC_CLOSURE_NAME_NAME => r'$name'; 583 String get STATIC_CLOSURE_NAME_NAME => r'$name';
(...skipping 1601 matching lines...) Expand 10 before | Expand all | Expand 10 after
2184 void addSuggestion(String original, String suggestion) { 2185 void addSuggestion(String original, String suggestion) {
2185 assert(!_suggestedNames.containsKey(original)); 2186 assert(!_suggestedNames.containsKey(original));
2186 _suggestedNames[original] = suggestion; 2187 _suggestedNames[original] = suggestion;
2187 } 2188 }
2188 2189
2189 bool hasSuggestion(String original) => _suggestedNames.containsKey(original); 2190 bool hasSuggestion(String original) => _suggestedNames.containsKey(original);
2190 bool isSuggestion(String candidate) { 2191 bool isSuggestion(String candidate) {
2191 return _suggestedNames.containsValue(candidate); 2192 return _suggestedNames.containsValue(candidate);
2192 } 2193 }
2193 } 2194 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/minify_namer.dart ('k') | pkg/compiler/lib/src/js_backend/native_data.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698