| OLD | NEW |
| 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 library dart2js.ir_nodes; | 4 library dart2js.ir_nodes; |
| 5 | 5 |
| 6 import 'dart:collection'; | 6 import 'dart:collection'; |
| 7 import 'cps_fragment.dart' show CpsFragment; | 7 import 'cps_fragment.dart' show CpsFragment; |
| 8 import 'cps_ir_nodes_sexpr.dart'; | 8 import 'cps_ir_nodes_sexpr.dart'; |
| 9 import '../constants/values.dart' as values; | 9 import '../constants/values.dart' as values; |
| 10 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType; | 10 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType; |
| (...skipping 2054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2065 } | 2065 } |
| 2066 } | 2066 } |
| 2067 | 2067 |
| 2068 /// Choose between a pair of continuations based on a condition value. | 2068 /// Choose between a pair of continuations based on a condition value. |
| 2069 /// | 2069 /// |
| 2070 /// The two continuations must not declare any parameters. | 2070 /// The two continuations must not declare any parameters. |
| 2071 class Branch extends TailExpression { | 2071 class Branch extends TailExpression { |
| 2072 final Reference<Primitive> conditionRef; | 2072 final Reference<Primitive> conditionRef; |
| 2073 final Reference<Continuation> trueContinuationRef; | 2073 final Reference<Continuation> trueContinuationRef; |
| 2074 final Reference<Continuation> falseContinuationRef; | 2074 final Reference<Continuation> falseContinuationRef; |
| 2075 final SourceInformation sourceInformation; |
| 2075 | 2076 |
| 2076 Primitive get condition => conditionRef.definition; | 2077 Primitive get condition => conditionRef.definition; |
| 2077 Continuation get trueContinuation => trueContinuationRef.definition; | 2078 Continuation get trueContinuation => trueContinuationRef.definition; |
| 2078 Continuation get falseContinuation => falseContinuationRef.definition; | 2079 Continuation get falseContinuation => falseContinuationRef.definition; |
| 2079 | 2080 |
| 2080 /// If true, only the value `true` satisfies the condition. Otherwise, any | 2081 /// If true, only the value `true` satisfies the condition. Otherwise, any |
| 2081 /// truthy value satisfies the check. | 2082 /// truthy value satisfies the check. |
| 2082 /// | 2083 /// |
| 2083 /// Non-strict checks are preferable when the condition is known to be a | 2084 /// Non-strict checks are preferable when the condition is known to be a |
| 2084 /// boolean. | 2085 /// boolean. |
| 2085 bool isStrictCheck; | 2086 bool isStrictCheck; |
| 2086 | 2087 |
| 2087 Branch(Primitive condition, Continuation trueCont, Continuation falseCont, | 2088 Branch( |
| 2089 Primitive condition, |
| 2090 Continuation trueCont, |
| 2091 Continuation falseCont, |
| 2092 this.sourceInformation, |
| 2088 {bool strict}) | 2093 {bool strict}) |
| 2089 : this.conditionRef = new Reference<Primitive>(condition), | 2094 : this.conditionRef = new Reference<Primitive>(condition), |
| 2090 trueContinuationRef = new Reference<Continuation>(trueCont), | 2095 trueContinuationRef = new Reference<Continuation>(trueCont), |
| 2091 falseContinuationRef = new Reference<Continuation>(falseCont), | 2096 falseContinuationRef = new Reference<Continuation>(falseCont), |
| 2092 isStrictCheck = strict { | 2097 isStrictCheck = strict { |
| 2093 assert(strict != null); | 2098 assert(strict != null); |
| 2094 } | 2099 } |
| 2095 | 2100 |
| 2096 Branch.strict( | 2101 Branch.strict( |
| 2097 Primitive condition, Continuation trueCont, Continuation falseCont) | 2102 Primitive condition, |
| 2098 : this(condition, trueCont, falseCont, strict: true); | 2103 Continuation trueCont, |
| 2104 Continuation falseCont, |
| 2105 SourceInformation sourceInformation) |
| 2106 : this(condition, trueCont, falseCont, sourceInformation, strict: true); |
| 2099 | 2107 |
| 2100 Branch.loose( | 2108 Branch.loose( |
| 2101 Primitive condition, Continuation trueCont, Continuation falseCont) | 2109 Primitive condition, |
| 2102 : this(condition, trueCont, falseCont, strict: false); | 2110 Continuation trueCont, |
| 2111 Continuation falseCont, |
| 2112 SourceInformation sourceInformation) |
| 2113 : this(condition, trueCont, falseCont, sourceInformation, strict: false); |
| 2103 | 2114 |
| 2104 accept(BlockVisitor visitor) => visitor.visitBranch(this); | 2115 accept(BlockVisitor visitor) => visitor.visitBranch(this); |
| 2105 | 2116 |
| 2106 void setParentPointers() { | 2117 void setParentPointers() { |
| 2107 conditionRef.parent = this; | 2118 conditionRef.parent = this; |
| 2108 trueContinuationRef.parent = this; | 2119 trueContinuationRef.parent = this; |
| 2109 falseContinuationRef.parent = this; | 2120 falseContinuationRef.parent = this; |
| 2110 } | 2121 } |
| 2111 } | 2122 } |
| 2112 | 2123 |
| (...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3127 } | 3138 } |
| 3128 | 3139 |
| 3129 visitRethrow(Rethrow node) { | 3140 visitRethrow(Rethrow node) { |
| 3130 plug(new Rethrow()); | 3141 plug(new Rethrow()); |
| 3131 } | 3142 } |
| 3132 | 3143 |
| 3133 visitBranch(Branch node) { | 3144 visitBranch(Branch node) { |
| 3134 plug(new Branch.loose( | 3145 plug(new Branch.loose( |
| 3135 _definitions.getCopy(node.conditionRef), | 3146 _definitions.getCopy(node.conditionRef), |
| 3136 _copies[node.trueContinuation], | 3147 _copies[node.trueContinuation], |
| 3137 _copies[node.falseContinuation])..isStrictCheck = node.isStrictCheck); | 3148 _copies[node.falseContinuation], |
| 3149 node.sourceInformation)..isStrictCheck = node.isStrictCheck); |
| 3138 } | 3150 } |
| 3139 | 3151 |
| 3140 visitUnreachable(Unreachable node) { | 3152 visitUnreachable(Unreachable node) { |
| 3141 plug(new Unreachable()); | 3153 plug(new Unreachable()); |
| 3142 } | 3154 } |
| 3143 } | 3155 } |
| OLD | NEW |