| 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 part of js_backend; | 5 part of js_backend; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Assigns JavaScript identifiers to Dart variables, class-names and members. | 8 * Assigns JavaScript identifiers to Dart variables, class-names and members. |
| 9 */ | 9 */ |
| 10 class Namer implements ClosureNamer { | 10 class Namer implements ClosureNamer { |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 String get noSuchMethodName => publicInstanceMethodNameByArity( | 299 String get noSuchMethodName => publicInstanceMethodNameByArity( |
| 300 Compiler.NO_SUCH_METHOD, Compiler.NO_SUCH_METHOD_ARG_COUNT); | 300 Compiler.NO_SUCH_METHOD, Compiler.NO_SUCH_METHOD_ARG_COUNT); |
| 301 /** | 301 /** |
| 302 * Some closures must contain their name. The name is stored in | 302 * Some closures must contain their name. The name is stored in |
| 303 * [STATIC_CLOSURE_NAME_NAME]. | 303 * [STATIC_CLOSURE_NAME_NAME]. |
| 304 */ | 304 */ |
| 305 String get STATIC_CLOSURE_NAME_NAME => r'$name'; | 305 String get STATIC_CLOSURE_NAME_NAME => r'$name'; |
| 306 String get closureInvocationSelectorName => Compiler.CALL_OPERATOR_NAME; | 306 String get closureInvocationSelectorName => Compiler.CALL_OPERATOR_NAME; |
| 307 bool get shouldMinify => false; | 307 bool get shouldMinify => false; |
| 308 | 308 |
| 309 String getNameForJsGetName(Node node, String name) { | 309 /// Returns the string that is to be used as the result of a call to |
| 310 /// [JS_GET_NAME] at [node] with argument [name]. |
| 311 String getNameForJsGetName(Node node, JsGetName name) { |
| 310 switch (name) { | 312 switch (name) { |
| 311 case 'GETTER_PREFIX': return getterPrefix; | 313 case JsGetName.GETTER_PREFIX: return getterPrefix; |
| 312 case 'SETTER_PREFIX': return setterPrefix; | 314 case JsGetName.SETTER_PREFIX: return setterPrefix; |
| 313 case 'CALL_PREFIX': return callPrefix; | 315 case JsGetName.CALL_PREFIX: return callPrefix; |
| 314 case 'CALL_CATCH_ALL': return callCatchAllName; | 316 case JsGetName.CALL_CATCH_ALL: return callCatchAllName; |
| 315 case 'REFLECTABLE': return reflectableField; | 317 case JsGetName.REFLECTABLE: return reflectableField; |
| 316 case 'CLASS_DESCRIPTOR_PROPERTY': return classDescriptorProperty; | 318 case JsGetName.CLASS_DESCRIPTOR_PROPERTY: |
| 317 case 'REQUIRED_PARAMETER_PROPERTY': return requiredParameterField; | 319 return classDescriptorProperty; |
| 318 case 'DEFAULT_VALUES_PROPERTY': return defaultValuesField; | 320 case JsGetName.REQUIRED_PARAMETER_PROPERTY: |
| 319 case 'CALL_NAME_PROPERTY': return callNameField; | 321 return requiredParameterField; |
| 322 case JsGetName.DEFAULT_VALUES_PROPERTY: return defaultValuesField; |
| 323 case JsGetName.CALL_NAME_PROPERTY: return callNameField; |
| 320 default: | 324 default: |
| 321 compiler.reportError( | 325 compiler.reportError( |
| 322 node, MessageKind.GENERIC, | 326 node, MessageKind.GENERIC, |
| 323 {'text': 'Error: Namer has no name for "$name".'}); | 327 {'text': 'Error: Namer has no name for "$name".'}); |
| 324 return 'BROKEN'; | 328 return 'BROKEN'; |
| 325 } | 329 } |
| 326 } | 330 } |
| 327 | 331 |
| 328 String constantName(ConstantValue constant) { | 332 String constantName(ConstantValue constant) { |
| 329 // In the current implementation it doesn't make sense to give names to | 333 // In the current implementation it doesn't make sense to give names to |
| 330 // function constants since the function-implementation itself serves as | 334 // function constants since the function-implementation itself serves as |
| 331 // constant and can be accessed directly. | 335 // constant and can be accessed directly. |
| 332 assert(!constant.isFunction); | 336 assert(!constant.isFunction); |
| 333 String result = constantNames[constant]; | 337 String result = constantNames[constant]; |
| (...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1428 if (!first) { | 1432 if (!first) { |
| 1429 sb.write('_'); | 1433 sb.write('_'); |
| 1430 } | 1434 } |
| 1431 sb.write('_'); | 1435 sb.write('_'); |
| 1432 visit(parameter); | 1436 visit(parameter); |
| 1433 first = true; | 1437 first = true; |
| 1434 } | 1438 } |
| 1435 } | 1439 } |
| 1436 } | 1440 } |
| 1437 } | 1441 } |
| OLD | NEW |