| OLD | NEW |
| 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 /** | 5 /** |
| 6 * Assigns JavaScript identifiers to Dart variables, class-names and members. | 6 * Assigns JavaScript identifiers to Dart variables, class-names and members. |
| 7 */ | 7 */ |
| 8 class Namer { | 8 class Namer { |
| 9 final Compiler compiler; | 9 final Compiler compiler; |
| 10 | 10 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 */ | 94 */ |
| 95 String getName(Element element) { | 95 String getName(Element element) { |
| 96 if (element.isInstanceMember()) { | 96 if (element.isInstanceMember()) { |
| 97 SourceString name; | 97 SourceString name; |
| 98 if (element.kind == ElementKind.GENERATIVE_CONSTRUCTOR_BODY) { | 98 if (element.kind == ElementKind.GENERATIVE_CONSTRUCTOR_BODY) { |
| 99 ConstructorBodyElement bodyElement = element; | 99 ConstructorBodyElement bodyElement = element; |
| 100 SourceString name = bodyElement.constructor.name; | 100 SourceString name = bodyElement.constructor.name; |
| 101 return instanceMethodName(name, bodyElement.parameterCount(compiler)); | 101 return instanceMethodName(name, bodyElement.parameterCount(compiler)); |
| 102 } else if (element.kind == ElementKind.FUNCTION) { | 102 } else if (element.kind == ElementKind.FUNCTION) { |
| 103 FunctionElement functionElement = element; | 103 FunctionElement functionElement = element; |
| 104 int parameterCount = functionElement.parameterCount(compiler); | |
| 105 int optionalParameterCount = | |
| 106 functionElement.optionalParameterCount(compiler); | |
| 107 return instanceMethodName( | 104 return instanceMethodName( |
| 108 element.name, parameterCount + optionalParameterCount); | 105 element.name, functionElement.parameterCount(compiler)); |
| 109 } else if (element.kind == ElementKind.GETTER) { | 106 } else if (element.kind == ElementKind.GETTER) { |
| 110 return getterName(element.name); | 107 return getterName(element.name); |
| 111 } else if (element.kind == ElementKind.SETTER) { | 108 } else if (element.kind == ElementKind.SETTER) { |
| 112 return setterName(element.name); | 109 return setterName(element.name); |
| 113 } else { | 110 } else { |
| 114 return instanceFieldName(element.name); | 111 return instanceFieldName(element.name); |
| 115 } | 112 } |
| 116 } else { | 113 } else { |
| 117 // Dealing with a top-level or static element. | 114 // Dealing with a top-level or static element. |
| 118 String cached = globals[element]; | 115 String cached = globals[element]; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 } | 166 } |
| 170 | 167 |
| 171 String isolateBailoutAccess(Element element) { | 168 String isolateBailoutAccess(Element element) { |
| 172 return '${isolateAccess(element)}\$bailout'; | 169 return '${isolateAccess(element)}\$bailout'; |
| 173 } | 170 } |
| 174 | 171 |
| 175 String operatorIs(ClassElement element) { | 172 String operatorIs(ClassElement element) { |
| 176 return 'is\$${getName(element)}'; | 173 return 'is\$${getName(element)}'; |
| 177 } | 174 } |
| 178 } | 175 } |
| OLD | NEW |