Chromium Code Reviews| Index: sdk/lib/_internal/compiler/implementation/mirror_renamer/renamer.dart |
| diff --git a/sdk/lib/_internal/compiler/implementation/mirror_renamer/renamer.dart b/sdk/lib/_internal/compiler/implementation/mirror_renamer/renamer.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a9328ac7ece32894666366b18d39210e185ba8f8 |
| --- /dev/null |
| +++ b/sdk/lib/_internal/compiler/implementation/mirror_renamer/renamer.dart |
| @@ -0,0 +1,30 @@ |
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +part of mirror_renamer; |
| + |
| +class MirrorRenamer { |
| + static const String MIRROR_HELPER_CLASS = 'MirrorHelper'; |
| + static const String MIRROR_HELPER_GET_NAME_FUNCTION = 'getName'; |
| + static const String MIRROR_HELPER_LIBRARY_NAME = 'mirror_helper.dart'; |
| + static const String MIRROR_HELPER_LIBRARY_PREFIX = 'm'; |
| + |
| + static void handleStaticSend(Map<Node, String> renames, Element element, |
| + Send node, Compiler compiler) { |
| + if (element == compiler.mirrorSystemGetNameFunction) { |
| + renames[node.selector] = MIRROR_HELPER_GET_NAME_FUNCTION; |
| + renames[node.receiver] = |
| + '$MIRROR_HELPER_LIBRARY_PREFIX.$MIRROR_HELPER_CLASS'; |
|
ahe
2013/08/06 15:53:36
This could be a constant as well.
zarah
2013/08/08 12:17:10
Done.
|
| + } |
| + } |
| + |
| + static void addMirrorHelperImport(Map<LibraryElement, String> imports) { |
| + Uri mirrorHelperUri = new Uri(path: MIRROR_HELPER_LIBRARY_NAME); |
| + //TODO(zarah) When actual mirror helper library is created |
| + // change to load that. |
| + LibraryElement mirrorHelperLib = new LibraryElementX( |
| + new Script(mirrorHelperUri, null)); |
|
ahe
2013/08/06 15:53:36
I'm really not comfortable that you instantiate Li
zarah
2013/08/08 12:17:10
Done.
|
| + imports.putIfAbsent(mirrorHelperLib, () => MIRROR_HELPER_LIBRARY_PREFIX); |
| + } |
| +} |