| 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, SplayTreeSet; | 7 import 'dart:collection' show HashSet, HashMap, SplayTreeSet; |
| 8 | 8 |
| 9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; | 9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; |
| 10 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator; | 10 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator; |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 return 'Symbol'; | 246 return 'Symbol'; |
| 247 } | 247 } |
| 248 | 248 |
| 249 bool isPublic(String name) => !name.startsWith('_'); | 249 bool isPublic(String name) => !name.startsWith('_'); |
| 250 | 250 |
| 251 @override | 251 @override |
| 252 visitAsExpression(AsExpression node) { | 252 visitAsExpression(AsExpression node) { |
| 253 var from = getStaticType(node.expression); | 253 var from = getStaticType(node.expression); |
| 254 var to = node.type.type; | 254 var to = node.type.type; |
| 255 | 255 |
| 256 // Skip the cast if it's not needed. |
| 257 if (rules.isSubTypeOf(from, to)) return _visit(node.expression); |
| 258 |
| 256 // All Dart number types map to a JS double. | 259 // All Dart number types map to a JS double. |
| 257 if (rules.isNumType(from) && | 260 if (rules.isNumType(from) && |
| 258 (rules.isIntType(to) || rules.isDoubleType(to))) { | 261 (rules.isIntType(to) || rules.isDoubleType(to))) { |
| 259 // TODO(jmesserly): a lot of these checks are meaningless, as people use | 262 // TODO(jmesserly): a lot of these checks are meaningless, as people use |
| 260 // `num` to mean "any kind of number" rather than "could be null". | 263 // `num` to mean "any kind of number" rather than "could be null". |
| 261 // The core libraries especially suffer from this problem, with many of | 264 // The core libraries especially suffer from this problem, with many of |
| 262 // the `num` methods returning `num`. | 265 // the `num` methods returning `num`. |
| 263 if (!rules.isNonNullableType(from) && rules.isNonNullableType(to)) { | 266 if (!rules.isNonNullableType(from) && rules.isNonNullableType(to)) { |
| 264 // Converting from a nullable number to a non-nullable number | 267 // Converting from a nullable number to a non-nullable number |
| 265 // only requires a null check. | 268 // only requires a null check. |
| (...skipping 2713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2979 | 2982 |
| 2980 /// A special kind of element created by the compiler, signifying a temporary | 2983 /// A special kind of element created by the compiler, signifying a temporary |
| 2981 /// variable. These objects use instance equality, and should be shared | 2984 /// variable. These objects use instance equality, and should be shared |
| 2982 /// everywhere in the tree where they are treated as the same variable. | 2985 /// everywhere in the tree where they are treated as the same variable. |
| 2983 class TemporaryVariableElement extends LocalVariableElementImpl { | 2986 class TemporaryVariableElement extends LocalVariableElementImpl { |
| 2984 TemporaryVariableElement.forNode(Identifier name) : super.forNode(name); | 2987 TemporaryVariableElement.forNode(Identifier name) : super.forNode(name); |
| 2985 | 2988 |
| 2986 int get hashCode => identityHashCode(this); | 2989 int get hashCode => identityHashCode(this); |
| 2987 bool operator ==(Object other) => identical(this, other); | 2990 bool operator ==(Object other) => identical(this, other); |
| 2988 } | 2991 } |
| OLD | NEW |