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

Side by Side Diff: lib/compiler/implementation/dart_backend/usage.dart

Issue 10836128: A visitor that builds a map from node to "Usage". (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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
(Empty)
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
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.
4
5 class UsageKind {
6 final String id;
7 const UsageKind(String this.id);
8
9 static final UsageKind CONSTRUCTOR_NAME =
10 const UsageKind('constructor_name');
11 static final UsageKind TYPE =
12 const UsageKind('type');
13 static final UsageKind METHOD =
14 const UsageKind('method');
15 // Common-case resolved element. This should go away.
16 static final UsageKind ELEMENT =
17 const UsageKind('element');
18 // Do not emit.
19 static final UsageKind NULL =
20 const UsageKind('null');
21 }
22
23 class Usage {
24 final UsageKind kind;
25 Usage(this.kind);
26 abstract String rename(ConflictingRenamer renamer);
27 }
28
29 class ConstructorNameUsage extends Usage {
30 final FunctionElement constructor;
31 ConstructorNameUsage(this.constructor) : super(UsageKind.CONSTRUCTOR_NAME);
32 String rename(ConflictingRenamer renamer) =>
33 renamer.renameConstructorName(constructor);
34 }
35 class TypeUsage extends Usage {
36 final Type type;
37 TypeUsage(this.type) : super(UsageKind.TYPE);
38 String rename(ConflictingRenamer renamer) =>
39 renamer.renameElement(type.element);
40 }
41 class MethodUsage extends Usage {
42 final Element method;
43 MethodUsage(this.method) : super(UsageKind.METHOD);
44 String rename(ConflictingRenamer renamer) => renamer.renameElement(method);
45 }
46 class NullUsage extends Usage {
47 NullUsage() : super(UsageKind.NULL);
48 String rename(ConflictingRenamer renamer) => '';
49 }
50 class ElementUsage extends Usage {
51 final Element element;
52 ElementUsage(this.element) : super(UsageKind.ELEMENT);
53 String rename(ConflictingRenamer renamer) => renamer.renameElement(element);
54 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698