| 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; | 7 import 'dart:collection' show HashSet; |
| 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 return js.call('dart.notNull(#)', _visit(node.expression)); | 172 return js.call('dart.notNull(#)', _visit(node.expression)); |
| 173 } else { | 173 } else { |
| 174 // A no-op in JavaScript. | 174 // A no-op in JavaScript. |
| 175 return _visit(node.expression); | 175 return _visit(node.expression); |
| 176 } | 176 } |
| 177 } | 177 } |
| 178 | 178 |
| 179 return _emitCast(node.expression, to); | 179 return _emitCast(node.expression, to); |
| 180 } | 180 } |
| 181 | 181 |
| 182 // TODO(vsm): This should go away in the future. I'm passing in the type |
| 183 // as a String for now to avoid breaking any existing code. In most cases, |
| 184 // we currently throw for function types. |
| 185 @override |
| 186 visitClosureWrapBase(ClosureWrapBase node) { |
| 187 var expression = _visit(node.expression); |
| 188 var typeString = js.escapedString(node.convertedType.toString()); |
| 189 return js.call('dart.closureWrap(#, #)', [expression, typeString]); |
| 190 } |
| 191 |
| 182 @override | 192 @override |
| 183 visitAsExpression(AsExpression node) => | 193 visitAsExpression(AsExpression node) => |
| 184 _emitCast(node.expression, node.type.type); | 194 _emitCast(node.expression, node.type.type); |
| 185 | 195 |
| 186 _emitCast(Expression node, DartType type) => | 196 _emitCast(Expression node, DartType type) => |
| 187 js.call('dart.as(#)', [[_visit(node), _emitTypeName(type)]]); | 197 js.call('dart.as(#)', [[_visit(node), _emitTypeName(type)]]); |
| 188 | 198 |
| 189 @override | 199 @override |
| 190 visitIsExpression(IsExpression node) { | 200 visitIsExpression(IsExpression node) { |
| 191 // Generate `is` as `dart.is` or `typeof` depending on the RHS type. | 201 // Generate `is` as `dart.is` or `typeof` depending on the RHS type. |
| (...skipping 1903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2095 | 2105 |
| 2096 // TODO(jmesserly): in many cases marking the end will be unncessary. | 2106 // TODO(jmesserly): in many cases marking the end will be unncessary. |
| 2097 printer.mark(_location(node.end)); | 2107 printer.mark(_location(node.end)); |
| 2098 } | 2108 } |
| 2099 | 2109 |
| 2100 String _getIdentifier(AstNode node) { | 2110 String _getIdentifier(AstNode node) { |
| 2101 if (node is SimpleIdentifier) return node.name; | 2111 if (node is SimpleIdentifier) return node.name; |
| 2102 return null; | 2112 return null; |
| 2103 } | 2113 } |
| 2104 } | 2114 } |
| OLD | NEW |