Chromium Code Reviews| Index: pkg/compiler/lib/src/ssa/codegen.dart |
| diff --git a/pkg/compiler/lib/src/ssa/codegen.dart b/pkg/compiler/lib/src/ssa/codegen.dart |
| index 4c97c464adcaf3c91da6339ce6fe6fda4845645d..58ff83099fa2b7d92218c8b7e21e72accbe12631 100644 |
| --- a/pkg/compiler/lib/src/ssa/codegen.dart |
| +++ b/pkg/compiler/lib/src/ssa/codegen.dart |
| @@ -2304,6 +2304,18 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor { |
| if (!negative) push(new js.Prefix('!', pop())); |
| } |
| + void checkTypeViaInstanceof( |
| + HInstruction input, DartType type, bool negative) { |
| + registry.registerIsCheck(type); |
| + |
| + use(input); |
| + |
| + js.Expression jsClassReference = |
| + backend.emitter.constructorAccess(type.element); |
|
floitsch
2015/01/16 14:14:33
Please confirm that `constructorAccess` is correct
sra1
2015/01/20 20:07:27
Verified.
|
| + push(js.js('# instanceof #', [pop(), jsClassReference])); |
| + if (negative) push(new js.Prefix('!', pop())); |
| + } |
| + |
| void handleNumberOrStringSupertypeCheck(HInstruction input, |
| HInstruction interceptor, |
| DartType type, |
| @@ -2421,6 +2433,10 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor { |
| js.Expression numTest = pop(); |
| checkBigInt(input, relation); |
| push(new js.Binary(negative ? '||' : '&&', numTest, pop()), node); |
| + } else if (node.useInstanceOf) { |
| + assert(interceptor == null); |
| + checkTypeViaInstanceof(input, type, negative); |
| + attachLocationToLast(node); |
| } else if (Elements.isNumberOrStringSupertype(element, compiler)) { |
| handleNumberOrStringSupertypeCheck( |
| input, interceptor, type, negative: negative); |