OLD | NEW |
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 2238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2249 push(new js.Conditional( | 2249 push(new js.Conditional( |
2250 new js.Binary('==', | 2250 new js.Binary('==', |
2251 new js.Prefix("typeof", pop()), | 2251 new js.Prefix("typeof", pop()), |
2252 js.string('function')), | 2252 js.string('function')), |
2253 whenFunction, | 2253 whenFunction, |
2254 whenNotFunction)); | 2254 whenNotFunction)); |
2255 } | 2255 } |
2256 | 2256 |
2257 js.PropertyAccess field = | 2257 js.PropertyAccess field = |
2258 new js.PropertyAccess.field(pop(), backend.namer.operatorIs(element)); | 2258 new js.PropertyAccess.field(pop(), backend.namer.operatorIs(element)); |
2259 if (backend.emitter.nativeEmitter.requiresNativeIsCheck(element)) { | 2259 // We always negate at least once so that the result is boolified. |
2260 push(new js.Call(field, <js.Expression>[])); | 2260 push(new js.Prefix('!', field)); |
2261 if (negative) push(new js.Prefix('!', pop())); | 2261 // If the result is not negated, put another '!' in front. |
2262 } else { | 2262 if (!negative) push(new js.Prefix('!', pop())); |
2263 // We always negate at least once so that the result is boolified. | |
2264 push(new js.Prefix('!', field)); | |
2265 // If the result is not negated, put another '!' in front. | |
2266 if (!negative) push(new js.Prefix('!', pop())); | |
2267 } | |
2268 | |
2269 } | 2263 } |
2270 | 2264 |
2271 void handleNumberOrStringSupertypeCheck(HInstruction input, | 2265 void handleNumberOrStringSupertypeCheck(HInstruction input, |
2272 DartType type, | 2266 DartType type, |
2273 { bool negative: false }) { | 2267 { bool negative: false }) { |
2274 assert(!identical(type.element, compiler.listClass) | 2268 assert(!identical(type.element, compiler.listClass) |
2275 && !Elements.isListSupertype(type.element, compiler) | 2269 && !Elements.isListSupertype(type.element, compiler) |
2276 && !Elements.isStringOnlySupertype(type.element, compiler)); | 2270 && !Elements.isStringOnlySupertype(type.element, compiler)); |
2277 String relation = negative ? '!==' : '==='; | 2271 String relation = negative ? '!==' : '==='; |
2278 checkNum(input, relation); | 2272 checkNum(input, relation); |
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3005 if (leftType.canBeNull() && rightType.canBeNull()) { | 2999 if (leftType.canBeNull() && rightType.canBeNull()) { |
3006 if (left.isConstantNull() || right.isConstantNull() || | 3000 if (left.isConstantNull() || right.isConstantNull() || |
3007 (leftType.isPrimitive() && leftType == rightType)) { | 3001 (leftType.isPrimitive() && leftType == rightType)) { |
3008 return '=='; | 3002 return '=='; |
3009 } | 3003 } |
3010 return null; | 3004 return null; |
3011 } else { | 3005 } else { |
3012 return '==='; | 3006 return '==='; |
3013 } | 3007 } |
3014 } | 3008 } |
OLD | NEW |