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