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

Side by Side Diff: pkg/compiler/lib/src/js_backend/checked_mode_helpers.dart

Issue 2718513002: Void is not required to be `null` anymore. (Closed)
Patch Set: Fix more places in the VM. Created 3 years, 9 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
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 import '../common.dart'; 5 import '../common.dart';
6 import '../core_types.dart'; 6 import '../core_types.dart';
7 import '../elements/elements.dart' show ErroneousElement; 7 import '../elements/elements.dart' show ErroneousElement;
8 import '../elements/entities.dart'; 8 import '../elements/entities.dart';
9 import '../elements/resolution_types.dart' show MalformedType; 9 import '../elements/resolution_types.dart' show MalformedType;
10 import '../elements/types.dart'; 10 import '../elements/types.dart';
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 124
125 class CheckedModeHelpers { 125 class CheckedModeHelpers {
126 final CommonElements _commonElements; 126 final CommonElements _commonElements;
127 final BackendHelpers _helpers; 127 final BackendHelpers _helpers;
128 128
129 CheckedModeHelpers(this._commonElements, this._helpers); 129 CheckedModeHelpers(this._commonElements, this._helpers);
130 130
131 /// All the checked mode helpers. 131 /// All the checked mode helpers.
132 static const List<CheckedModeHelper> helpers = const <CheckedModeHelper>[ 132 static const List<CheckedModeHelper> helpers = const <CheckedModeHelper>[
133 const MalformedCheckedModeHelper('checkMalformedType'), 133 const MalformedCheckedModeHelper('checkMalformedType'),
134 const CheckedModeHelper('voidTypeCheck'),
135 const CheckedModeHelper('stringTypeCast'), 134 const CheckedModeHelper('stringTypeCast'),
136 const CheckedModeHelper('stringTypeCheck'), 135 const CheckedModeHelper('stringTypeCheck'),
137 const CheckedModeHelper('doubleTypeCast'), 136 const CheckedModeHelper('doubleTypeCast'),
138 const CheckedModeHelper('doubleTypeCheck'), 137 const CheckedModeHelper('doubleTypeCheck'),
139 const CheckedModeHelper('numTypeCast'), 138 const CheckedModeHelper('numTypeCast'),
140 const CheckedModeHelper('numTypeCheck'), 139 const CheckedModeHelper('numTypeCheck'),
141 const CheckedModeHelper('boolTypeCast'), 140 const CheckedModeHelper('boolTypeCast'),
142 const CheckedModeHelper('boolTypeCheck'), 141 const CheckedModeHelper('boolTypeCheck'),
143 const CheckedModeHelper('intTypeCast'), 142 const CheckedModeHelper('intTypeCast'),
144 const CheckedModeHelper('intTypeCheck'), 143 const CheckedModeHelper('intTypeCheck'),
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 209
211 String getCheckedModeHelperNameInternal(DartType type, 210 String getCheckedModeHelperNameInternal(DartType type,
212 {bool typeCast, bool nativeCheckOnly}) { 211 {bool typeCast, bool nativeCheckOnly}) {
213 assert(!type.isTypedef); 212 assert(!type.isTypedef);
214 if (type.isMalformed) { 213 if (type.isMalformed) {
215 // The same error is thrown for type test and type cast of a malformed 214 // The same error is thrown for type test and type cast of a malformed
216 // type so we only need one check method. 215 // type so we only need one check method.
217 return 'checkMalformedType'; 216 return 'checkMalformedType';
218 } 217 }
219 218
220 if (type.isVoid) {
221 assert(!typeCast); // Cannot cast to void.
222 if (nativeCheckOnly) return null;
223 return 'voidTypeCheck';
224 }
225
226 if (type.isTypeVariable) { 219 if (type.isTypeVariable) {
227 return typeCast 220 return typeCast
228 ? 'subtypeOfRuntimeTypeCast' 221 ? 'subtypeOfRuntimeTypeCast'
229 : 'assertSubtypeOfRuntimeType'; 222 : 'assertSubtypeOfRuntimeType';
230 } 223 }
231 224
232 if (type.isFunctionType) { 225 if (type.isFunctionType) {
233 return typeCast ? 'functionTypeCast' : 'functionTypeCheck'; 226 return typeCast ? 'functionTypeCast' : 'functionTypeCheck';
234 } 227 }
235 228
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 297
305 if (nativeCheck) { 298 if (nativeCheck) {
306 // TODO(karlklose): can we get rid of this branch when we use 299 // TODO(karlklose): can we get rid of this branch when we use
307 // interceptors? 300 // interceptors?
308 return 'intercepted$suffix'; 301 return 'intercepted$suffix';
309 } else { 302 } else {
310 return 'property$suffix'; 303 return 'property$suffix';
311 } 304 }
312 } 305 }
313 } 306 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698