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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/mirror_renamer/renamer.dart

Issue 22791002: Add renames in output when using the mirror helper library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of mirror_renamer; 5 part of mirror_renamer;
6 6
7 class MirrorRenamer { 7 class MirrorRenamer {
8 static const String MIRROR_HELPER_CLASS = 'MirrorHelper'; 8 static const String MIRROR_HELPER_CLASS = 'MirrorHelper';
9 static const String MIRROR_HELPER_GET_NAME_FUNCTION = 'getName'; 9 static const String MIRROR_HELPER_GET_NAME_FUNCTION = 'getName';
10 static const String MIRROR_HELPER_ADD_RENAME_FUNCTION = 'addRename';
11
10 static const String MIRROR_HELPER_LIBRARY_NAME = 'mirror_helper.dart'; 12 static const String MIRROR_HELPER_LIBRARY_NAME = 'mirror_helper.dart';
11 static const String MIRROR_HELPER_LIBRARY_PREFIX = 'm'; 13 static const String MIRROR_HELPER_LIBRARY_PREFIX = 'm';
12 static const String MIRROR_HELPER_CLASS_FULLY_QUALIFIED_NAME = 14 static const String MIRROR_HELPER_CLASS_FULLY_QUALIFIED_NAME =
13 '$MIRROR_HELPER_LIBRARY_PREFIX.$MIRROR_HELPER_CLASS'; 15 '$MIRROR_HELPER_LIBRARY_PREFIX.$MIRROR_HELPER_CLASS';
14 16
17 static Map<String, String> inverseRenames;
18
15 static void handleStaticSend(Map<Node, String> renames, Element element, 19 static void handleStaticSend(Map<Node, String> renames, Element element,
16 Send node, Compiler compiler) { 20 Send node, Compiler compiler) {
17 if (element == compiler.mirrorSystemGetNameFunction) { 21 if (element == compiler.mirrorSystemGetNameFunction) {
18 renames[node.selector] = MIRROR_HELPER_GET_NAME_FUNCTION; 22 renames[node.selector] = MIRROR_HELPER_GET_NAME_FUNCTION;
19 renames[node.receiver] = MIRROR_HELPER_CLASS_FULLY_QUALIFIED_NAME; 23 renames[node.receiver] = MIRROR_HELPER_CLASS_FULLY_QUALIFIED_NAME;
20 } 24 }
21 } 25 }
22 26
23 static void addMirrorHelperImport(Map<LibraryElement, String> imports) { 27 static void addMirrorHelperImport(Map<LibraryElement, String> imports) {
24 Uri mirrorHelperUri = new Uri(path: MIRROR_HELPER_LIBRARY_NAME); 28 Uri mirrorHelperUri = new Uri(path: MIRROR_HELPER_LIBRARY_NAME);
25 // TODO(zarah): Remove this hack! LibraryElementX should not be created 29 // TODO(zarah): Remove this hack! LibraryElementX should not be created
26 // outside the library loader. When actual mirror helper library 30 // outside the library loader. When actual mirror helper library
27 // is created, change to load that. 31 // is created, change to load that.
28 LibraryElement mirrorHelperLib = new LibraryElementX( 32 LibraryElement mirrorHelperLib = new LibraryElementX(
29 new Script(mirrorHelperUri, null)); 33 new Script(mirrorHelperUri, null));
30 imports.putIfAbsent(mirrorHelperLib, () => MIRROR_HELPER_LIBRARY_PREFIX); 34 imports.putIfAbsent(mirrorHelperLib, () => MIRROR_HELPER_LIBRARY_PREFIX);
31 } 35 }
36
37 static void registerRenames(Map<Node, String> renames) {
38 inverseRenames = new Map<String, String>();
39
40 for (Node node in renames.keys) {
41 if (node is Identifier) {
42 var stringValue = node.asIdentifier().source.stringValue;
43 if (stringValue != renames[node]) {
44 inverseRenames.putIfAbsent(renames[node], () => stringValue);
45 }
46 }
47 }
48 }
32 } 49 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698