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

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: Update Kernel code. Created 3 years, 7 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 '../common_elements.dart'; 6 import '../common_elements.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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 } 110 }
111 111
112 class CheckedModeHelpers { 112 class CheckedModeHelpers {
113 final CommonElements _commonElements; 113 final CommonElements _commonElements;
114 114
115 CheckedModeHelpers(this._commonElements); 115 CheckedModeHelpers(this._commonElements);
116 116
117 /// All the checked mode helpers. 117 /// All the checked mode helpers.
118 static const List<CheckedModeHelper> helpers = const <CheckedModeHelper>[ 118 static const List<CheckedModeHelper> helpers = const <CheckedModeHelper>[
119 const MalformedCheckedModeHelper('checkMalformedType'), 119 const MalformedCheckedModeHelper('checkMalformedType'),
120 const CheckedModeHelper('voidTypeCheck'),
121 const CheckedModeHelper('stringTypeCast'), 120 const CheckedModeHelper('stringTypeCast'),
122 const CheckedModeHelper('stringTypeCheck'), 121 const CheckedModeHelper('stringTypeCheck'),
123 const CheckedModeHelper('doubleTypeCast'), 122 const CheckedModeHelper('doubleTypeCast'),
124 const CheckedModeHelper('doubleTypeCheck'), 123 const CheckedModeHelper('doubleTypeCheck'),
125 const CheckedModeHelper('numTypeCast'), 124 const CheckedModeHelper('numTypeCast'),
126 const CheckedModeHelper('numTypeCheck'), 125 const CheckedModeHelper('numTypeCheck'),
127 const CheckedModeHelper('boolTypeCast'), 126 const CheckedModeHelper('boolTypeCast'),
128 const CheckedModeHelper('boolTypeCheck'), 127 const CheckedModeHelper('boolTypeCheck'),
129 const CheckedModeHelper('intTypeCast'), 128 const CheckedModeHelper('intTypeCast'),
130 const CheckedModeHelper('intTypeCheck'), 129 const CheckedModeHelper('intTypeCheck'),
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 195
197 String getCheckedModeHelperNameInternal(DartType type, 196 String getCheckedModeHelperNameInternal(DartType type,
198 {bool typeCast, bool nativeCheckOnly}) { 197 {bool typeCast, bool nativeCheckOnly}) {
199 assert(!type.isTypedef); 198 assert(!type.isTypedef);
200 if (type.isMalformed) { 199 if (type.isMalformed) {
201 // The same error is thrown for type test and type cast of a malformed 200 // The same error is thrown for type test and type cast of a malformed
202 // type so we only need one check method. 201 // type so we only need one check method.
203 return 'checkMalformedType'; 202 return 'checkMalformedType';
204 } 203 }
205 204
206 if (type.isVoid) {
207 assert(!typeCast); // Cannot cast to void.
208 if (nativeCheckOnly) return null;
209 return 'voidTypeCheck';
210 }
211
212 if (type.isTypeVariable) { 205 if (type.isTypeVariable) {
213 return typeCast 206 return typeCast
214 ? 'subtypeOfRuntimeTypeCast' 207 ? 'subtypeOfRuntimeTypeCast'
215 : 'assertSubtypeOfRuntimeType'; 208 : 'assertSubtypeOfRuntimeType';
216 } 209 }
217 210
218 if (type.isFunctionType) { 211 if (type.isFunctionType) {
219 return typeCast ? 'functionTypeCast' : 'functionTypeCheck'; 212 return typeCast ? 'functionTypeCast' : 'functionTypeCheck';
220 } 213 }
221 214
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 283
291 if (nativeCheck) { 284 if (nativeCheck) {
292 // TODO(karlklose): can we get rid of this branch when we use 285 // TODO(karlklose): can we get rid of this branch when we use
293 // interceptors? 286 // interceptors?
294 return 'intercepted$suffix'; 287 return 'intercepted$suffix';
295 } else { 288 } else {
296 return 'property$suffix'; 289 return 'property$suffix';
297 } 290 }
298 } 291 }
299 } 292 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/inferrer/type_system.dart ('k') | pkg/compiler/lib/src/js_backend/impact_transformer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698