Chromium Code Reviews| Index: pkg/compiler/lib/src/js_backend/namer.dart |
| diff --git a/pkg/compiler/lib/src/js_backend/namer.dart b/pkg/compiler/lib/src/js_backend/namer.dart |
| index 1dac9f9a201d67e57c54ecbaebf3e1bfe13c31de..f1b5935c0993a07d9e1ef698632aff544fce7c6b 100644 |
| --- a/pkg/compiler/lib/src/js_backend/namer.dart |
| +++ b/pkg/compiler/lib/src/js_backend/namer.dart |
| @@ -585,11 +585,16 @@ class Namer { |
| return '$name\$${suffix.join(r'$')}'; |
| } |
| + /// Name for a constructor body. |
| + jsAst.Name constructorBodyName(FunctionElement ctor) { |
| + return _disambiguateInternalMember(ctor, |
| + () => _proposeNameForConstructorBody(ctor)); |
| + } |
| + |
| /// Annotated name for [method] encoding arity and named parameters. |
| jsAst.Name instanceMethodName(FunctionElement method) { |
| if (method.isGenerativeConstructorBody) { |
| - return _disambiguateInternalMember(method, |
| - () => _proposeNameForConstructorBody(method)); |
| + return constructorBodyName(method); |
| } |
| return invocationName(new Selector.fromElement(method)); |
| } |
| @@ -917,6 +922,31 @@ class Namer { |
| return newName; |
| } |
| + /// Returns the disambiguated name for the instance member identified by |
| + /// [key]. |
| + /// |
| + /// When a name for an element is requested by key, it may not be requested |
| + /// by element at the same time, as two different names would be returned. |
|
sra1
2015/07/01 16:15:47
Can we have an assert for that?
herhut
2015/07/02 09:03:00
No, because there is no well defined relation betw
|
| + /// |
| + /// If key has not yet been registered, [proposeName] is used to generate |
| + /// a name proposal for the given key. |
| + /// |
| + /// [key] must not clash with valid instance names. This is typically |
| + /// achieved by using at least one character in [key] that is not valid in |
| + /// identifiers, for example the @ symbol. |
| + jsAst.Name _disambiguateMemberByKey(String key, |
|
sra1
2015/07/01 16:15:47
fits on one line.
herhut
2015/07/02 09:03:00
Done.
|
| + String proposeName()) { |
| + jsAst.Name newName = userInstanceMembers[key]; |
| + if (newName == null) { |
| + String name = proposeName(); |
| + newName = getFreshName(name, |
| + usedInstanceNames, suggestedInstanceNames, |
| + sanitizeForAnnotations: true); |
| + userInstanceMembers[key] = newName; |
| + } |
| + return newName; |
| + } |
| + |
| /// Forces the public instance member with [originalName] to have the given |
| /// [disambiguatedName]. |
| /// |