Chromium Code Reviews| Index: sdk/lib/_internal/compiler/implementation/js_emitter/type_test_emitter.dart |
| diff --git a/sdk/lib/_internal/compiler/implementation/js_emitter/type_test_emitter.dart b/sdk/lib/_internal/compiler/implementation/js_emitter/type_test_emitter.dart |
| index c2cb16be184f734ce89383a9af869eff74fd08e8..19808397c6a35f4601782127335adf5ac61f8f02 100644 |
| --- a/sdk/lib/_internal/compiler/implementation/js_emitter/type_test_emitter.dart |
| +++ b/sdk/lib/_internal/compiler/implementation/js_emitter/type_test_emitter.dart |
| @@ -279,25 +279,38 @@ class TypeTestEmitter extends CodeEmitterHelper { |
| // Add checks to the constructors of instantiated classes. |
| // TODO(sigurdm): We should avoid running through this list for each |
| // output unit. |
| + |
| + List<jsAst.Statement> statements = <jsAst.Statement>[]; |
| + |
| for (ClassElement cls in typeChecks) { |
| OutputUnit destination = |
| compiler.deferredLoadTask.outputUnitForElement(cls); |
| if (destination != outputUnit) continue; |
| // TODO(9556). The properties added to 'holder' should be generated |
| // directly as properties of the class object, not added later. |
| - String holder = namer.isolateAccess(backend.getImplementationClass(cls)); |
| + jsAst.Expression holder |
| + = namer.elementAccess(backend.getImplementationClass(cls)); |
| + |
| + List generators = []; |
| for (TypeCheck check in typeChecks[cls]) { |
| ClassElement cls = check.cls; |
| - buffer.write('$holder.${namer.operatorIs(cls)}$_=${_}true$N'); |
| + statements.add( |
| + js.statement('#.# = True', [holder, namer.operatorIs(cls)])); |
| Substitution substitution = check.substitution; |
| if (substitution != null) { |
| - CodeBuffer body = |
| - jsAst.prettyPrint(substitution.getCode(rti, false), compiler); |
| - buffer.write('$holder.${namer.substitutionName(cls)}$_=${_}'); |
| - buffer.write(body); |
| - buffer.write('$N'); |
| + jsAst.Expression body = substitution.getCode(rti, false); |
| + statements.add( |
| + js.statement('#.# = #', |
| + [holder, namer.substitutionName(cls), body])); |
| } |
| - }; |
| + } |
| + } |
| + |
| + if (statements.isNotEmpty) { |
| + buffer.write( |
| + jsAst.prettyPrint(js.statement( |
| + r'(function(){ var True = true; #; })();', [statements]), |
|
floitsch
2014/04/28 14:17:51
Nit: I would prefer if this change was done in a s
sra1
2014/04/28 23:00:41
Done.
|
| + compiler)); |
| } |
| } |