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 class SsaCodeGeneratorTask extends CompilerTask { | 5 class SsaCodeGeneratorTask extends CompilerTask { |
6 | 6 |
7 final JavaScriptBackend backend; | 7 final JavaScriptBackend backend; |
8 | 8 |
9 SsaCodeGeneratorTask(JavaScriptBackend backend) | 9 SsaCodeGeneratorTask(JavaScriptBackend backend) |
10 : this.backend = backend, | 10 : this.backend = backend, |
(...skipping 2221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2232 checkTypeOf(input, '===', 'function'); | 2232 checkTypeOf(input, '===', 'function'); |
2233 js.Expression functionTest = pop(); | 2233 js.Expression functionTest = pop(); |
2234 checkObject(input, '==='); | 2234 checkObject(input, '==='); |
2235 js.Expression objectTest = pop(); | 2235 js.Expression objectTest = pop(); |
2236 checkType(input, type); | 2236 checkType(input, type); |
2237 push(new js.Binary('||', | 2237 push(new js.Binary('||', |
2238 functionTest, | 2238 functionTest, |
2239 new js.Binary('&&', objectTest, pop()))); | 2239 new js.Binary('&&', objectTest, pop()))); |
2240 } | 2240 } |
2241 | 2241 |
2242 void checkType(HInstruction input, DartType type, [bool negative = false]) { | 2242 void checkType(HInstruction input, DartType type, {bool negative: false}) { |
2243 world.registerIsCheck(type); | 2243 world.registerIsCheck(type); |
2244 Element element = type.element; | 2244 Element element = type.element; |
2245 use(input); | 2245 use(input); |
2246 js.PropertyAccess field = | 2246 js.PropertyAccess field = |
2247 new js.PropertyAccess.field(pop(), backend.namer.operatorIs(element)); | 2247 new js.PropertyAccess.field(pop(), backend.namer.operatorIs(element)); |
2248 if (backend.emitter.nativeEmitter.requiresNativeIsCheck(element)) { | 2248 if (backend.emitter.nativeEmitter.requiresNativeIsCheck(element)) { |
2249 push(new js.Call(field, <js.Expression>[])); | 2249 push(new js.Call(field, <js.Expression>[])); |
2250 if (negative) push(new js.Prefix('!', pop())); | 2250 if (negative) push(new js.Prefix('!', pop())); |
2251 } else { | 2251 } else { |
2252 // We always negate at least once so that the result is boolified. | 2252 // We always negate at least once so that the result is boolified. |
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2990 if (leftType.canBeNull() && rightType.canBeNull()) { | 2990 if (leftType.canBeNull() && rightType.canBeNull()) { |
2991 if (left.isConstantNull() || right.isConstantNull() || | 2991 if (left.isConstantNull() || right.isConstantNull() || |
2992 (leftType.isPrimitive() && leftType == rightType)) { | 2992 (leftType.isPrimitive() && leftType == rightType)) { |
2993 return '=='; | 2993 return '=='; |
2994 } | 2994 } |
2995 return null; | 2995 return null; |
2996 } else { | 2996 } else { |
2997 return '==='; | 2997 return '==='; |
2998 } | 2998 } |
2999 } | 2999 } |
OLD | NEW |