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

Side by Side Diff: pkg/kernel/test/type_propagation_selfcheck.dart

Issue 2561723003: Merge kernel closure conversion into the Dart SDK (Closed)
Patch Set: Remove path constraint Created 4 years 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 | « pkg/kernel/test/type_propagation_dump.dart ('k') | pkg/kernel/test/type_unification_test.dart » ('j') | 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 kernel.type_propagation.selfcheck; 4 library kernel.type_propagation.selfcheck;
5 5
6 import 'dart:io'; 6 import 'dart:io';
7 import 'package:kernel/core_types.dart'; 7 import 'package:kernel/core_types.dart';
8 import 'package:kernel/kernel.dart'; 8 import 'package:kernel/kernel.dart';
9 import 'package:kernel/type_propagation/type_propagation.dart'; 9 import 'package:kernel/type_propagation/type_propagation.dart';
10 10
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 148
149 // List of conditions that all must hold. For each zero bit we know that 149 // List of conditions that all must hold. For each zero bit we know that
150 // type of value is not allowed to occur. 150 // type of value is not allowed to occur.
151 List<Expression> allChecks = <Expression>[]; 151 List<Expression> allChecks = <Expression>[];
152 152
153 // List of condition of which one must hold. This is used for checking the 153 // List of condition of which one must hold. This is used for checking the
154 // [ValueBit.other] bit. For each one bit, we know that type of value 154 // [ValueBit.other] bit. For each one bit, we know that type of value
155 // is allowed to occur. We use this because it is hard to check directly 155 // is allowed to occur. We use this because it is hard to check directly
156 // that a value is of the 'other' type. 156 // that a value is of the 'other' type.
157 bool disallowOtherValues = expected.valueBits & ValueBit.other == 0; 157 bool disallowOtherValues = expected.valueBits & ValueBit.other == 0;
158 List<Expression> anyChecks = disallowOtherValues 158 List<Expression> anyChecks = disallowOtherValues ? <Expression>[] : null;
159 ? <Expression>[]
160 : null;
161 159
162 void checkType(int bit, DartType type) { 160 void checkType(int bit, DartType type) {
163 if (expected.valueBits & bit == 0) { 161 if (expected.valueBits & bit == 0) {
164 allChecks 162 allChecks
165 .add(new Not(new IsExpression(new VariableGet(variable), type))); 163 .add(new Not(new IsExpression(new VariableGet(variable), type)));
166 } else if (disallowOtherValues) { 164 } else if (disallowOtherValues) {
167 anyChecks.add(new IsExpression(new VariableGet(variable), type)); 165 anyChecks.add(new IsExpression(new VariableGet(variable), type));
168 } 166 }
169 } 167 }
170 168
171 checkType(ValueBit.integer, coreTypes.intClass.rawType); 169 checkType(ValueBit.integer, coreTypes.intClass.rawType);
172 checkType(ValueBit.double_, coreTypes.doubleClass.rawType); 170 checkType(ValueBit.double_, coreTypes.doubleClass.rawType);
173 checkType(ValueBit.string, coreTypes.stringClass.rawType); 171 checkType(ValueBit.string, coreTypes.stringClass.rawType);
174 checkType(ValueBit.null_, coreTypes.nullClass.rawType); 172 checkType(ValueBit.null_, coreTypes.nullClass.rawType);
175 173
176 if (disallowOtherValues) { 174 if (disallowOtherValues) {
177 Expression any = 175 Expression any =
178 anyChecks.reduce((e1, e2) => new LogicalExpression(e1, '||', e2)); 176 anyChecks.reduce((e1, e2) => new LogicalExpression(e1, '||', e2));
179 allChecks.add(any); 177 allChecks.add(any);
180 } 178 }
181 return allChecks.isEmpty 179 return allChecks.isEmpty
182 ? new BoolLiteral(true) 180 ? new BoolLiteral(true)
183 : allChecks.reduce((e1, e2) => new LogicalExpression(e1, '&&', e2)); 181 : allChecks.reduce((e1, e2) => new LogicalExpression(e1, '&&', e2));
184 } 182 }
185 } 183 }
OLDNEW
« no previous file with comments | « pkg/kernel/test/type_propagation_dump.dart ('k') | pkg/kernel/test/type_unification_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698