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

Unified Diff: lib/src/codegen/js_codegen.dart

Issue 1043003002: keep mixin and interface implementation info at runtime (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « lib/runtime/dart_runtime.js ('k') | test/codegen/expect/server_mode/html_input.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/codegen/js_codegen.dart
diff --git a/lib/src/codegen/js_codegen.dart b/lib/src/codegen/js_codegen.dart
index 578a4c886bb96b8fe3d04e64311a6163105d1d93..82188b1e647a3908490af64045c3030f43082694 100644
--- a/lib/src/codegen/js_codegen.dart
+++ b/lib/src/codegen/js_codegen.dart
@@ -287,8 +287,6 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor {
currentClass = node;
- var name = classElem.name;
-
var ctors = <ConstructorDeclaration>[];
var fields = <FieldDeclaration>[];
var staticFields = <FieldDeclaration>[];
@@ -300,10 +298,10 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor {
}
}
- var classExpr = new JS.ClassExpression(new JS.Identifier(name),
+ var classExpr = new JS.ClassExpression(new JS.Identifier(classElem.name),
_classHeritage(node), _emitClassMethods(node, ctors, fields));
- var body = _finishClassMembers(name, classExpr, ctors, staticFields);
+ var body = _finishClassMembers(classElem, classExpr, ctors, staticFields);
currentClass = null;
return _finishClassDef(classElem, body);
@@ -546,11 +544,23 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor {
/// Emit class members that need to come after the class declaration, such
/// as static fields. See [_emitClassMethods] for things that are emitted
/// insite the ES6 `class { ... }` node.
- JS.Statement _finishClassMembers(String name, JS.ClassExpression cls,
- List<ConstructorDeclaration> ctors, List<FieldDeclaration> staticFields) {
+ JS.Statement _finishClassMembers(ClassElement classElem,
+ JS.ClassExpression cls, List<ConstructorDeclaration> ctors,
+ List<FieldDeclaration> staticFields) {
+ var name = classElem.name;
+
var body = <JS.Statement>[];
body.add(new JS.ClassDeclaration(cls));
+ // Interfaces
+ if (classElem.interfaces.isNotEmpty) {
+ body.add(js.statement('#[dart.implements] = #;', [
+ name,
+ new JS.ArrayInitializer(
+ classElem.interfaces.map(_emitTypeName).toList())
+ ]));
+ }
+
// Named constructors
for (ConstructorDeclaration member in ctors) {
if (member.name != null) {
@@ -577,6 +587,7 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor {
}
var lazy = _emitLazyFields(new JS.Identifier(name), lazyStatics);
if (lazy != null) body.add(lazy);
+
return _statement(body);
}
« no previous file with comments | « lib/runtime/dart_runtime.js ('k') | test/codegen/expect/server_mode/html_input.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698