| 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 final String currentIsolate = r'$'; | 220 final String currentIsolate = r'$'; |
| 221 final String getterPrefix = r'get$'; | 221 final String getterPrefix = r'get$'; |
| 222 final String setterPrefix = r'set$'; | 222 final String setterPrefix = r'set$'; |
| 223 final String metadataField = '@'; | 223 final String metadataField = '@'; |
| 224 final String callCatchAllName = r'call$catchAll'; | 224 final String callCatchAllName = r'call$catchAll'; |
| 225 final String reflectableField = r'$reflectable'; | 225 final String reflectableField = r'$reflectable'; |
| 226 final String defaultValuesField = r'$defaultValues'; | 226 final String defaultValuesField = r'$defaultValues'; |
| 227 final String methodsWithOptionalArgumentsField = | 227 final String methodsWithOptionalArgumentsField = |
| 228 r'$methodsWithOptionalArguments'; | 228 r'$methodsWithOptionalArguments'; |
| 229 | 229 |
| 230 final String classDescriptorProperty = r'^'; |
| 231 |
| 230 // Name of property in a class description for the native dispatch metadata. | 232 // Name of property in a class description for the native dispatch metadata. |
| 231 final String nativeSpecProperty = '%'; | 233 final String nativeSpecProperty = '%'; |
| 232 | 234 |
| 233 static final RegExp IDENTIFIER = new RegExp(r'^[A-Za-z_$][A-Za-z0-9_$]*$'); | 235 static final RegExp IDENTIFIER = new RegExp(r'^[A-Za-z_$][A-Za-z0-9_$]*$'); |
| 234 static final RegExp NON_IDENTIFIER_CHAR = new RegExp(r'[^A-Za-z_0-9$]'); | 236 static final RegExp NON_IDENTIFIER_CHAR = new RegExp(r'[^A-Za-z_0-9$]'); |
| 235 | 237 |
| 236 /** | 238 /** |
| 237 * Map from top-level or static elements to their unique identifiers provided | 239 * Map from top-level or static elements to their unique identifiers provided |
| 238 * by [getName]. | 240 * by [getName]. |
| 239 * | 241 * |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 String get STATIC_CLOSURE_NAME_NAME => r'$name'; | 285 String get STATIC_CLOSURE_NAME_NAME => r'$name'; |
| 284 String get closureInvocationSelectorName => Compiler.CALL_OPERATOR_NAME; | 286 String get closureInvocationSelectorName => Compiler.CALL_OPERATOR_NAME; |
| 285 bool get shouldMinify => false; | 287 bool get shouldMinify => false; |
| 286 | 288 |
| 287 String getNameForJsGetName(Node node, String name) { | 289 String getNameForJsGetName(Node node, String name) { |
| 288 switch (name) { | 290 switch (name) { |
| 289 case 'GETTER_PREFIX': return getterPrefix; | 291 case 'GETTER_PREFIX': return getterPrefix; |
| 290 case 'SETTER_PREFIX': return setterPrefix; | 292 case 'SETTER_PREFIX': return setterPrefix; |
| 291 case 'CALL_CATCH_ALL': return callCatchAllName; | 293 case 'CALL_CATCH_ALL': return callCatchAllName; |
| 292 case 'REFLECTABLE': return reflectableField; | 294 case 'REFLECTABLE': return reflectableField; |
| 295 case 'CLASS_DESCRIPTOR_PROPERTY': return classDescriptorProperty; |
| 293 default: | 296 default: |
| 294 compiler.reportError( | 297 compiler.reportError( |
| 295 node, MessageKind.GENERIC, | 298 node, MessageKind.GENERIC, |
| 296 {'text': 'Error: Namer has no name for "$name".'}); | 299 {'text': 'Error: Namer has no name for "$name".'}); |
| 297 return 'BROKEN'; | 300 return 'BROKEN'; |
| 298 } | 301 } |
| 299 } | 302 } |
| 300 | 303 |
| 301 String constantName(Constant constant) { | 304 String constantName(Constant constant) { |
| 302 // In the current implementation it doesn't make sense to give names to | 305 // In the current implementation it doesn't make sense to give names to |
| (...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1395 if (!first) { | 1398 if (!first) { |
| 1396 sb.write('_'); | 1399 sb.write('_'); |
| 1397 } | 1400 } |
| 1398 sb.write('_'); | 1401 sb.write('_'); |
| 1399 visit(link.head); | 1402 visit(link.head); |
| 1400 first = true; | 1403 first = true; |
| 1401 } | 1404 } |
| 1402 } | 1405 } |
| 1403 } | 1406 } |
| 1404 } | 1407 } |
| OLD | NEW |