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 2237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2248 push(new js.Binary('||', | 2248 push(new js.Binary('||', |
2249 functionTest, | 2249 functionTest, |
2250 new js.Binary('&&', objectTest, pop()))); | 2250 new js.Binary('&&', objectTest, pop()))); |
2251 } | 2251 } |
2252 | 2252 |
2253 void checkType(HInstruction input, DartType type, {bool negative: false}) { | 2253 void checkType(HInstruction input, DartType type, {bool negative: false}) { |
2254 assert(invariant(input, !type.isMalformed, | 2254 assert(invariant(input, !type.isMalformed, |
2255 message: 'Attempt to check malformed type $type')); | 2255 message: 'Attempt to check malformed type $type')); |
2256 world.registerIsCheck(type, work.resolutionTree); | 2256 world.registerIsCheck(type, work.resolutionTree); |
2257 Element element = type.element; | 2257 Element element = type.element; |
2258 String operatorIs; | |
2259 if (type is FunctionType) { | |
ngeoffray
2013/03/13 09:30:46
Use the kind?
Johnni Winther
2013/03/22 07:30:24
Refactored.
| |
2260 operatorIs = backend.namer.operatorIsFunctionType(type); | |
2261 } else { | |
2262 operatorIs = backend.namer.operatorIs(element); | |
2263 } | |
2258 use(input); | 2264 use(input); |
2259 js.PropertyAccess field = | 2265 js.PropertyAccess field = |
2260 new js.PropertyAccess.field(pop(), backend.namer.operatorIs(element)); | 2266 new js.PropertyAccess.field(pop(), operatorIs); |
2261 if (backend.emitter.nativeEmitter.requiresNativeIsCheck(element)) { | 2267 if (backend.emitter.nativeEmitter.requiresNativeIsCheck(element)) { |
2262 push(new js.Call(field, <js.Expression>[])); | 2268 push(new js.Call(field, <js.Expression>[])); |
2263 if (negative) push(new js.Prefix('!', pop())); | 2269 if (negative) push(new js.Prefix('!', pop())); |
2264 } else { | 2270 } else { |
2265 // We always negate at least once so that the result is boolified. | 2271 // We always negate at least once so that the result is boolified. |
2266 push(new js.Prefix('!', field)); | 2272 push(new js.Prefix('!', field)); |
2267 // If the result is not negated, put another '!' in front. | 2273 // If the result is not negated, put another '!' in front. |
2268 if (!negative) push(new js.Prefix('!', pop())); | 2274 if (!negative) push(new js.Prefix('!', pop())); |
2269 } | 2275 } |
2270 } | 2276 } |
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2966 if (leftType.canBeNull() && rightType.canBeNull()) { | 2972 if (leftType.canBeNull() && rightType.canBeNull()) { |
2967 if (left.isConstantNull() || right.isConstantNull() || | 2973 if (left.isConstantNull() || right.isConstantNull() || |
2968 (leftType.isPrimitive() && leftType == rightType)) { | 2974 (leftType.isPrimitive() && leftType == rightType)) { |
2969 return '=='; | 2975 return '=='; |
2970 } | 2976 } |
2971 return null; | 2977 return null; |
2972 } else { | 2978 } else { |
2973 return '==='; | 2979 return '==='; |
2974 } | 2980 } |
2975 } | 2981 } |
OLD | NEW |