| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 dart2js.js_emitter.startup_emitter.model_emitter; | 5 part of dart2js.js_emitter.startup_emitter.model_emitter; |
| 6 | 6 |
| 7 /// The name of the property that stores the tear-off getter on a static | 7 /// The name of the property that stores the tear-off getter on a static |
| 8 /// function. | 8 /// function. |
| 9 /// | 9 /// |
| 10 /// This property is only used when isolates are used. | 10 /// This property is only used when isolates are used. |
| (...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 } | 826 } |
| 827 return new js.Block(assignments); | 827 return new js.Block(assignments); |
| 828 } | 828 } |
| 829 | 829 |
| 830 /// Encodes the optional default values so that the runtime Function.apply | 830 /// Encodes the optional default values so that the runtime Function.apply |
| 831 /// can use them. | 831 /// can use them. |
| 832 js.Expression _encodeOptionalParameterDefaultValues(DartMethod method) { | 832 js.Expression _encodeOptionalParameterDefaultValues(DartMethod method) { |
| 833 // TODO(herhut): Replace [js.LiteralNull] with [js.ArrayHole]. | 833 // TODO(herhut): Replace [js.LiteralNull] with [js.ArrayHole]. |
| 834 if (method.optionalParameterDefaultValues is List) { | 834 if (method.optionalParameterDefaultValues is List) { |
| 835 List<ConstantValue> defaultValues = method.optionalParameterDefaultValues; | 835 List<ConstantValue> defaultValues = method.optionalParameterDefaultValues; |
| 836 if (defaultValues.isEmpty) { |
| 837 return new js.LiteralNull(); |
| 838 } |
| 836 Iterable<js.Expression> elements = | 839 Iterable<js.Expression> elements = |
| 837 defaultValues.map(generateConstantReference); | 840 defaultValues.map(generateConstantReference); |
| 838 return js.js('function() { return #; }', | 841 return js.js('function() { return #; }', |
| 839 new js.ArrayInitializer(elements.toList())); | 842 new js.ArrayInitializer(elements.toList())); |
| 840 } else { | 843 } else { |
| 841 Map<String, ConstantValue> defaultValues = | 844 Map<String, ConstantValue> defaultValues = |
| 842 method.optionalParameterDefaultValues; | 845 method.optionalParameterDefaultValues; |
| 843 List<js.Property> properties = <js.Property>[]; | 846 List<js.Property> properties = <js.Property>[]; |
| 844 List<String> names = defaultValues.keys.toList(growable: false); | 847 List<String> names = defaultValues.keys.toList(growable: false); |
| 845 // Sort the names the same way we sort them for the named-argument calling | 848 // Sort the names the same way we sort them for the named-argument calling |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1311 } | 1314 } |
| 1312 statements.add(js.js.statement("setOrUpdateInterceptorsByTag(#);", | 1315 statements.add(js.js.statement("setOrUpdateInterceptorsByTag(#);", |
| 1313 js.objectLiteral(interceptorsByTag))); | 1316 js.objectLiteral(interceptorsByTag))); |
| 1314 statements.add( | 1317 statements.add( |
| 1315 js.js.statement("setOrUpdateLeafTags(#);", js.objectLiteral(leafTags))); | 1318 js.js.statement("setOrUpdateLeafTags(#);", js.objectLiteral(leafTags))); |
| 1316 statements.add(subclassAssignment); | 1319 statements.add(subclassAssignment); |
| 1317 | 1320 |
| 1318 return new js.Block(statements); | 1321 return new js.Block(statements); |
| 1319 } | 1322 } |
| 1320 } | 1323 } |
| OLD | NEW |