Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: pkg/compiler/lib/src/js_emitter/program_builder.dart

Issue 809433004: dart2js: is-checks for the new emitter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Improved test. Created 5 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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.
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/old_emitter/interceptor_emitter.dart ('k') | pkg/compiler/lib/src/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698