Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart

Issue 1215713005: dart2js cps: Do not build type casts for casting to 'dynamic'. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 dart2js.ir_builder; 5 library dart2js.ir_builder;
6 6
7 import '../compile_time_constants.dart' show BackendConstantEnvironment; 7 import '../compile_time_constants.dart' show BackendConstantEnvironment;
8 import '../constants/constant_system.dart'; 8 import '../constants/constant_system.dart';
9 import '../constants/values.dart' show ConstantValue, PrimitiveConstantValue; 9 import '../constants/values.dart' show ConstantValue, PrimitiveConstantValue;
10 import '../dart_types.dart'; 10 import '../dart_types.dart';
(...skipping 2557 matching lines...) Expand 10 before | Expand all | Expand 10 after
2568 if (type.isObject || type.isDynamic) { 2568 if (type.isObject || type.isDynamic) {
2569 // `x is Object` and `x is dynamic` are always true, even if x is null. 2569 // `x is Object` and `x is dynamic` are always true, even if x is null.
2570 return buildBooleanConstant(true); 2570 return buildBooleanConstant(true);
2571 } 2571 }
2572 if (type is InterfaceType && type.element == program.nullClass) { 2572 if (type is InterfaceType && type.element == program.nullClass) {
2573 // `x is Null` is true if and only if x is null. 2573 // `x is Null` is true if and only if x is null.
2574 return _buildCheckNull(value); 2574 return _buildCheckNull(value);
2575 } 2575 }
2576 return addPrimitive(new ir.TypeTest(value, type, typeArguments)); 2576 return addPrimitive(new ir.TypeTest(value, type, typeArguments));
2577 } else { 2577 } else {
2578 if (type.isObject || type.isDynamic) {
2579 // `x as Object` and `x as dynamic` are the same as `x`.
2580 return value;
2581 }
2578 return _continueWithExpression( 2582 return _continueWithExpression(
2579 (k) => new ir.TypeCast(value, type, typeArguments, k)); 2583 (k) => new ir.TypeCast(value, type, typeArguments, k));
2580 } 2584 }
2581 } 2585 }
2582 2586
2583 /// Create an if-null expression. This is equivalent to a conditional 2587 /// Create an if-null expression. This is equivalent to a conditional
2584 /// expression whose result is either [value] if [value] is not null, or 2588 /// expression whose result is either [value] if [value] is not null, or
2585 /// `right` if [value] is null. Only when [value] is null, [buildRight] is 2589 /// `right` if [value] is null. Only when [value] is null, [buildRight] is
2586 /// evaluated to produce the `right` value. 2590 /// evaluated to produce the `right` value.
2587 ir.Primitive buildIfNull(ir.Primitive value, 2591 ir.Primitive buildIfNull(ir.Primitive value,
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
2686 } 2690 }
2687 2691
2688 class SwitchCaseInfo { 2692 class SwitchCaseInfo {
2689 final List<ir.Primitive> constants = <ir.Primitive>[]; 2693 final List<ir.Primitive> constants = <ir.Primitive>[];
2690 final SubbuildFunction buildBody; 2694 final SubbuildFunction buildBody;
2691 2695
2692 SwitchCaseInfo(this.buildBody); 2696 SwitchCaseInfo(this.buildBody);
2693 2697
2694 void addConstant(ir.Primitive constant) => constants.add(constant); 2698 void addConstant(ir.Primitive constant) => constants.add(constant);
2695 } 2699 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698