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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/ssa/codegen.dart

Issue 11572009: Support for typedef in checked mode. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of ssa; 5 part of ssa;
6 6
7 class SsaCodeGeneratorTask extends CompilerTask { 7 class SsaCodeGeneratorTask extends CompilerTask {
8 8
9 final JavaScriptBackend backend; 9 final JavaScriptBackend backend;
10 10
(...skipping 2252 matching lines...) Expand 10 before | Expand all | Expand 10 after
2263 2263
2264 void checkFixedArray(HInstruction input) { 2264 void checkFixedArray(HInstruction input) {
2265 checkFieldExists(input, 'fixed\$length'); 2265 checkFieldExists(input, 'fixed\$length');
2266 } 2266 }
2267 2267
2268 void checkNull(HInstruction input) { 2268 void checkNull(HInstruction input) {
2269 use(input); 2269 use(input);
2270 push(new js.Binary('==', pop(), new js.LiteralNull())); 2270 push(new js.Binary('==', pop(), new js.LiteralNull()));
2271 } 2271 }
2272 2272
2273 void checkNonNull(HInstruction input) {
2274 use(input);
2275 push(new js.Binary('!=', pop(), new js.LiteralNull()));
2276 }
2277
2273 void checkFunction(HInstruction input, DartType type) { 2278 void checkFunction(HInstruction input, DartType type) {
2274 checkTypeOf(input, '===', 'function'); 2279 checkTypeOf(input, '===', 'function');
2275 js.Expression functionTest = pop(); 2280 js.Expression functionTest = pop();
2276 checkObject(input, '==='); 2281 checkObject(input, '===');
2277 js.Expression objectTest = pop(); 2282 js.Expression objectTest = pop();
2278 checkType(input, type); 2283 checkType(input, type);
2279 push(new js.Binary('||', 2284 push(new js.Binary('||',
2280 functionTest, 2285 functionTest,
2281 new js.Binary('&&', objectTest, pop()))); 2286 new js.Binary('&&', objectTest, pop())));
2282 } 2287 }
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
2387 } else if (Elements.isNumberOrStringSupertype(element, compiler)) { 2392 } else if (Elements.isNumberOrStringSupertype(element, compiler)) {
2388 handleNumberOrStringSupertypeCheck(input, type); 2393 handleNumberOrStringSupertypeCheck(input, type);
2389 attachLocationToLast(node); 2394 attachLocationToLast(node);
2390 } else if (Elements.isStringOnlySupertype(element, compiler)) { 2395 } else if (Elements.isStringOnlySupertype(element, compiler)) {
2391 handleStringSupertypeCheck(input, type); 2396 handleStringSupertypeCheck(input, type);
2392 attachLocationToLast(node); 2397 attachLocationToLast(node);
2393 } else if (identical(element, compiler.listClass) 2398 } else if (identical(element, compiler.listClass)
2394 || Elements.isListSupertype(element, compiler)) { 2399 || Elements.isListSupertype(element, compiler)) {
2395 handleListOrSupertypeCheck(input, type); 2400 handleListOrSupertypeCheck(input, type);
2396 attachLocationToLast(node); 2401 attachLocationToLast(node);
2402 } else if (element.isTypedef()) {
2403 checkNonNull(input);
2404 js.Expression nullTest = pop();
2405 checkType(input, type);
2406 push(new js.Binary('&&', nullTest, pop()));
2407 attachLocationToLast(node);
2397 } else if (types[input].canBePrimitive() || types[input].canBeNull()) { 2408 } else if (types[input].canBePrimitive() || types[input].canBeNull()) {
2398 checkObject(input, '==='); 2409 checkObject(input, '===');
2399 js.Expression objectTest = pop(); 2410 js.Expression objectTest = pop();
2400 checkType(input, type); 2411 checkType(input, type);
2401 push(new js.Binary('&&', objectTest, pop()), node); 2412 push(new js.Binary('&&', objectTest, pop()), node);
2402 } else { 2413 } else {
2403 checkType(input, type); 2414 checkType(input, type);
2404 attachLocationToLast(node); 2415 attachLocationToLast(node);
2405 } 2416 }
2406 if (node.hasArgumentChecks()) { 2417 if (node.hasArgumentChecks()) {
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
3046 if (leftType.canBeNull() && rightType.canBeNull()) { 3057 if (leftType.canBeNull() && rightType.canBeNull()) {
3047 if (left.isConstantNull() || right.isConstantNull() || 3058 if (left.isConstantNull() || right.isConstantNull() ||
3048 (leftType.isPrimitive() && leftType == rightType)) { 3059 (leftType.isPrimitive() && leftType == rightType)) {
3049 return '=='; 3060 return '==';
3050 } 3061 }
3051 return null; 3062 return null;
3052 } else { 3063 } else {
3053 return '==='; 3064 return '===';
3054 } 3065 }
3055 } 3066 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart ('k') | tests/co19/co19-dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698