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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
294 String get noSuchMethodName => publicInstanceMethodNameByArity( | 294 String get noSuchMethodName => publicInstanceMethodNameByArity( |
295 Compiler.NO_SUCH_METHOD, Compiler.NO_SUCH_METHOD_ARG_COUNT); | 295 Compiler.NO_SUCH_METHOD, Compiler.NO_SUCH_METHOD_ARG_COUNT); |
296 /** | 296 /** |
297 * Some closures must contain their name. The name is stored in | 297 * Some closures must contain their name. The name is stored in |
298 * [STATIC_CLOSURE_NAME_NAME]. | 298 * [STATIC_CLOSURE_NAME_NAME]. |
299 */ | 299 */ |
300 String get STATIC_CLOSURE_NAME_NAME => r'$name'; | 300 String get STATIC_CLOSURE_NAME_NAME => r'$name'; |
301 String get closureInvocationSelectorName => Compiler.CALL_OPERATOR_NAME; | 301 String get closureInvocationSelectorName => Compiler.CALL_OPERATOR_NAME; |
302 bool get shouldMinify => false; | 302 bool get shouldMinify => false; |
303 | 303 |
304 String getNameForJsGetName(Node node, String name) { | 304 /// Returns the string that is to be used as the result of a call to |
305 /// [JS_GET_NAME] at [node] with argument [name]. | |
306 String getNameForJsGetName(Node node, JsGetName name) { | |
305 switch (name) { | 307 switch (name) { |
306 case 'GETTER_PREFIX': return getterPrefix; | 308 case JsGetName.GETTER_PREFIX: return getterPrefix; |
307 case 'SETTER_PREFIX': return setterPrefix; | 309 case JsGetName.SETTER_PREFIX: return setterPrefix; |
308 case 'CALL_PREFIX': return callPrefix; | 310 case JsGetName.CALL_PREFIX: return callPrefix; |
309 case 'CALL_CATCH_ALL': return callCatchAllName; | 311 case JsGetName.CALL_CATCH_ALL: return callCatchAllName; |
310 case 'REFLECTABLE': return reflectableField; | 312 case JsGetName.REFLECTABLE: return reflectableField; |
311 case 'CLASS_DESCRIPTOR_PROPERTY': return classDescriptorProperty; | 313 case JsGetName.CLASS_DESCRIPTOR_PROPERTY: |
312 case 'REQUIRED_PARAMETER_PROPERTY': return requiredParameterField; | 314 return classDescriptorProperty; |
313 case 'DEFAULT_VALUES_PROPERTY': return defaultValuesField; | 315 case JsGetName.REQUIRED_PARAMETER_PROPERTY: |
314 case 'CALL_NAME_PROPERTY': return callNameField; | 316 return requiredParameterField; |
317 case JsGetName.DEFAULT_VALUES_PROPERTY: return defaultValuesField; | |
318 case JsGetName.CALL_NAME_PROPERTY: return callNameField; | |
315 default: | 319 default: |
316 compiler.reportError( | 320 assert(invariant(node, "Missing JsGetName value in namer!")); |
floitsch
2015/02/18 13:00:44
Keep the 'compiler.reportError'.
herhut
2015/02/19 10:27:28
Done.
| |
317 node, MessageKind.GENERIC, | 321 return null; |
318 {'text': 'Error: Namer has no name for "$name".'}); | |
319 return 'BROKEN'; | |
320 } | 322 } |
321 } | 323 } |
322 | 324 |
323 String constantName(ConstantValue constant) { | 325 String constantName(ConstantValue constant) { |
324 // In the current implementation it doesn't make sense to give names to | 326 // In the current implementation it doesn't make sense to give names to |
325 // function constants since the function-implementation itself serves as | 327 // function constants since the function-implementation itself serves as |
326 // constant and can be accessed directly. | 328 // constant and can be accessed directly. |
327 assert(!constant.isFunction); | 329 assert(!constant.isFunction); |
328 String result = constantNames[constant]; | 330 String result = constantNames[constant]; |
329 if (result == null) { | 331 if (result == null) { |
(...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1423 if (!first) { | 1425 if (!first) { |
1424 sb.write('_'); | 1426 sb.write('_'); |
1425 } | 1427 } |
1426 sb.write('_'); | 1428 sb.write('_'); |
1427 visit(parameter); | 1429 visit(parameter); |
1428 first = true; | 1430 first = true; |
1429 } | 1431 } |
1430 } | 1432 } |
1431 } | 1433 } |
1432 } | 1434 } |
OLD | NEW |