| 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 library dev_compiler.src.codegen.js_codegen; | 5 library dev_compiler.src.codegen.js_codegen; |
| 6 | 6 |
| 7 import 'dart:collection' show HashSet, HashMap; | 7 import 'dart:collection' show HashSet, HashMap; |
| 8 import 'dart:io' show Directory, File; | 8 import 'dart:io' show Directory, File; |
| 9 | 9 |
| 10 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; | 10 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; |
| (...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1095 _emitTypeProperties(namedTypes) | 1095 _emitTypeProperties(namedTypes) |
| 1096 ]); | 1096 ]); |
| 1097 } | 1097 } |
| 1098 } | 1098 } |
| 1099 // TODO(jmesserly): remove when we're using coercion reifier. | 1099 // TODO(jmesserly): remove when we're using coercion reifier. |
| 1100 return _unimplementedCall('Unimplemented type $type'); | 1100 return _unimplementedCall('Unimplemented type $type'); |
| 1101 } | 1101 } |
| 1102 | 1102 |
| 1103 var typeArgs = null; | 1103 var typeArgs = null; |
| 1104 if (type is ParameterizedType) { | 1104 if (type is ParameterizedType) { |
| 1105 // TODO(jmesserly): this is a workaround for an analyzer bug, see: | 1105 var args = type.typeArguments; |
| 1106 // https://github.com/dart-lang/dev_compiler/commit/a212d59ad046085a626dd8
d16881cdb8e8b9c3fa | 1106 if (args.any((a) => a != types.dynamicType)) { |
| 1107 if (type is! FunctionType || element is FunctionTypeAlias) { | 1107 name = '$name\$'; |
| 1108 var args = type.typeArguments; | 1108 typeArgs = args.map(_emitTypeName); |
| 1109 if (args.any((a) => a != types.dynamicType)) { | |
| 1110 name = '$name\$'; | |
| 1111 typeArgs = args.map(_emitTypeName); | |
| 1112 } | |
| 1113 } | 1109 } |
| 1114 } | 1110 } |
| 1115 | 1111 |
| 1116 JS.Expression result; | 1112 JS.Expression result; |
| 1117 if (_needQualifiedName(element)) { | 1113 if (_needQualifiedName(element)) { |
| 1118 result = js.call('#.#', [_libraryName(element.library), name]); | 1114 result = js.call('#.#', [_libraryName(element.library), name]); |
| 1119 } else { | 1115 } else { |
| 1120 result = new JS.Identifier(name); | 1116 result = new JS.Identifier(name); |
| 1121 } | 1117 } |
| 1122 | 1118 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1270 } | 1266 } |
| 1271 return js.call(code, [_visit(node.function), _visit(node.argumentList)]); | 1267 return js.call(code, [_visit(node.function), _visit(node.argumentList)]); |
| 1272 } | 1268 } |
| 1273 | 1269 |
| 1274 @override | 1270 @override |
| 1275 List<JS.Expression> visitArgumentList(ArgumentList node) { | 1271 List<JS.Expression> visitArgumentList(ArgumentList node) { |
| 1276 var args = <JS.Expression>[]; | 1272 var args = <JS.Expression>[]; |
| 1277 var named = <JS.Property>[]; | 1273 var named = <JS.Property>[]; |
| 1278 for (var arg in node.arguments) { | 1274 for (var arg in node.arguments) { |
| 1279 if (arg is NamedExpression) { | 1275 if (arg is NamedExpression) { |
| 1280 named.add(visitNamedExpression(arg)); | 1276 named.add(_visit(arg)); |
| 1281 } else { | 1277 } else { |
| 1282 args.add(_visit(arg)); | 1278 args.add(_visit(arg)); |
| 1283 } | 1279 } |
| 1284 } | 1280 } |
| 1285 if (named.isNotEmpty) { | 1281 if (named.isNotEmpty) { |
| 1286 args.add(new JS.ObjectInitializer(named)); | 1282 args.add(new JS.ObjectInitializer(named)); |
| 1287 } | 1283 } |
| 1288 return args; | 1284 return args; |
| 1289 } | 1285 } |
| 1290 | 1286 |
| (...skipping 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2532 } | 2528 } |
| 2533 } | 2529 } |
| 2534 | 2530 |
| 2535 // TODO(jmesserly): validate the library. See issue #135. | 2531 // TODO(jmesserly): validate the library. See issue #135. |
| 2536 bool _isJsNameAnnotation(DartObjectImpl value) => value.type.name == 'JsName'; | 2532 bool _isJsNameAnnotation(DartObjectImpl value) => value.type.name == 'JsName'; |
| 2537 | 2533 |
| 2538 // TODO(jacobr): we would like to do something like the following | 2534 // TODO(jacobr): we would like to do something like the following |
| 2539 // but we don't have summary support yet. | 2535 // but we don't have summary support yet. |
| 2540 // bool _supportJsExtensionMethod(AnnotatedNode node) => | 2536 // bool _supportJsExtensionMethod(AnnotatedNode node) => |
| 2541 // _getAnnotation(node, "SupportJsExtensionMethod") != null; | 2537 // _getAnnotation(node, "SupportJsExtensionMethod") != null; |
| OLD | NEW |