Chromium Code Reviews| Index: pkg/compiler/lib/src/js_emitter/program_builder.dart |
| diff --git a/pkg/compiler/lib/src/js_emitter/program_builder.dart b/pkg/compiler/lib/src/js_emitter/program_builder.dart |
| index ea6dab875c7a1c426775619f9aacf1180c0fb59e..15959ee4ee6df724523fea40cb0d75ec78c1b369 100644 |
| --- a/pkg/compiler/lib/src/js_emitter/program_builder.dart |
| +++ b/pkg/compiler/lib/src/js_emitter/program_builder.dart |
| @@ -20,7 +20,9 @@ import '../closure.dart' show ClosureFieldElement; |
| import 'js_emitter.dart' as emitterTask show |
| CodeEmitterTask, |
| Emitter, |
| - InterceptorStubGenerator; |
| + InterceptorStubGenerator, |
| + TypeTestGenerator, |
| + TypeTestProperties; |
| import '../universe/universe.dart' show Universe; |
| import '../deferred_load.dart' show DeferredLoadTask, OutputUnit; |
| @@ -267,6 +269,25 @@ class ProgramBuilder { |
| if (!element.isMixinApplication) { |
| implementation.forEachMember(visitMember, includeBackendMembers: true); |
| } |
| + |
| + emitterTask.TypeTestGenerator generator = |
| + new emitterTask.TypeTestGenerator(_compiler, _task, namer); |
| + emitterTask.TypeTestProperties typeTests = |
| + generator.generateIsTests(element); |
| + |
| + // At this point a mixin application must not have any methods or fields. |
| + // Type-tests might be added to mixin applications, too. |
| + assert(!element.isMixinApplication || methods.isEmpty); |
| + assert(!element.isMixinApplication || fields.isEmpty); |
| + |
| + // TODO(floitsch): we should not add the code here, but have a list of |
| + // is/as classes in the Class object. |
| + // The individual emitters should then call the type test generator to |
| + // generate the code. |
| + typeTests.properties.forEach((String name, js.Node code) { |
|
kasperl
2015/01/05 08:19:09
You could consider a combination of keys.map/addAl
floitsch
2015/01/05 10:42:11
I don't see any good way without doing a hashtable
|
| + methods.add(_buildMethodWithName(name, code)); |
| + }); |
| + |
| String name = namer.getNameOfClass(element); |
| String holderName = namer.globalObjectFor(element); |
| Holder holder = _registry.registerHolder(holderName); |
| @@ -276,9 +297,7 @@ class ProgramBuilder { |
| Class result; |
| if (element.isMixinApplication) { |
| - assert(methods.isEmpty); |
| - assert(fields.isEmpty); |
| - result = new MixinApplication(name, holder, |
| + result = new MixinApplication(name, holder, methods, fields, |
| isDirectlyInstantiated: isInstantiated, |
| onlyForRti: onlyForRti); |
| } else { |
| @@ -295,6 +314,10 @@ class ProgramBuilder { |
| return new Method(name, code); |
| } |
| + Method _buildMethodWithName(String name, js.Expression code) { |
| + return new Method(name, code); |
| + } |
| + |
| // The getInterceptor methods directly access the prototype of classes. |
| // We must evaluate these classes eagerly so that the prototype is |
| // accessible. |