| 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 final String callCatchAllName = r'call$catchAll'; | 226 final String callCatchAllName = r'call$catchAll'; |
| 227 final String reflectableField = r'$reflectable'; | 227 final String reflectableField = r'$reflectable'; |
| 228 final String reflectionInfoField = r'$reflectionInfo'; | 228 final String reflectionInfoField = r'$reflectionInfo'; |
| 229 final String reflectionNameField = r'$reflectionName'; | 229 final String reflectionNameField = r'$reflectionName'; |
| 230 final String metadataIndexField = r'$metadataIndex'; | 230 final String metadataIndexField = r'$metadataIndex'; |
| 231 final String defaultValuesField = r'$defaultValues'; | 231 final String defaultValuesField = r'$defaultValues'; |
| 232 final String methodsWithOptionalArgumentsField = | 232 final String methodsWithOptionalArgumentsField = |
| 233 r'$methodsWithOptionalArguments'; | 233 r'$methodsWithOptionalArguments'; |
| 234 | 234 |
| 235 final String classDescriptorProperty = r'^'; | 235 final String classDescriptorProperty = r'^'; |
| 236 final String requiredParameterField = r'$requiredArgCount'; |
| 236 | 237 |
| 237 // Name of property in a class description for the native dispatch metadata. | 238 // Name of property in a class description for the native dispatch metadata. |
| 238 final String nativeSpecProperty = '%'; | 239 final String nativeSpecProperty = '%'; |
| 239 | 240 |
| 240 static final RegExp IDENTIFIER = new RegExp(r'^[A-Za-z_$][A-Za-z0-9_$]*$'); | 241 static final RegExp IDENTIFIER = new RegExp(r'^[A-Za-z_$][A-Za-z0-9_$]*$'); |
| 241 static final RegExp NON_IDENTIFIER_CHAR = new RegExp(r'[^A-Za-z_0-9$]'); | 242 static final RegExp NON_IDENTIFIER_CHAR = new RegExp(r'[^A-Za-z_0-9$]'); |
| 242 | 243 |
| 243 /** | 244 /** |
| 244 * Map from top-level or static elements to their unique identifiers provided | 245 * Map from top-level or static elements to their unique identifiers provided |
| 245 * by [getName]. | 246 * by [getName]. |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 bool get shouldMinify => false; | 301 bool get shouldMinify => false; |
| 301 | 302 |
| 302 String getNameForJsGetName(Node node, String name) { | 303 String getNameForJsGetName(Node node, String name) { |
| 303 switch (name) { | 304 switch (name) { |
| 304 case 'GETTER_PREFIX': return getterPrefix; | 305 case 'GETTER_PREFIX': return getterPrefix; |
| 305 case 'SETTER_PREFIX': return setterPrefix; | 306 case 'SETTER_PREFIX': return setterPrefix; |
| 306 case 'CALL_PREFIX': return callPrefix; | 307 case 'CALL_PREFIX': return callPrefix; |
| 307 case 'CALL_CATCH_ALL': return callCatchAllName; | 308 case 'CALL_CATCH_ALL': return callCatchAllName; |
| 308 case 'REFLECTABLE': return reflectableField; | 309 case 'REFLECTABLE': return reflectableField; |
| 309 case 'CLASS_DESCRIPTOR_PROPERTY': return classDescriptorProperty; | 310 case 'CLASS_DESCRIPTOR_PROPERTY': return classDescriptorProperty; |
| 311 case 'REQUIRED_PARAMETER_PROPERTY': return requiredParameterField; |
| 312 case 'DEFAULT_VALUES_PROPERTY': return defaultValuesField; |
| 310 default: | 313 default: |
| 311 compiler.reportError( | 314 compiler.reportError( |
| 312 node, MessageKind.GENERIC, | 315 node, MessageKind.GENERIC, |
| 313 {'text': 'Error: Namer has no name for "$name".'}); | 316 {'text': 'Error: Namer has no name for "$name".'}); |
| 314 return 'BROKEN'; | 317 return 'BROKEN'; |
| 315 } | 318 } |
| 316 } | 319 } |
| 317 | 320 |
| 318 String constantName(ConstantValue constant) { | 321 String constantName(ConstantValue constant) { |
| 319 // In the current implementation it doesn't make sense to give names to | 322 // In the current implementation it doesn't make sense to give names to |
| (...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1418 if (!first) { | 1421 if (!first) { |
| 1419 sb.write('_'); | 1422 sb.write('_'); |
| 1420 } | 1423 } |
| 1421 sb.write('_'); | 1424 sb.write('_'); |
| 1422 visit(parameter); | 1425 visit(parameter); |
| 1423 first = true; | 1426 first = true; |
| 1424 } | 1427 } |
| 1425 } | 1428 } |
| 1426 } | 1429 } |
| 1427 } | 1430 } |
| OLD | NEW |