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

Side by Side Diff: lib/src/codegen/js_codegen.dart

Issue 1193083002: fixes #231, mixin application (aka ClassTypeAlias) implicit ctors (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 6 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 unified diff | Download patch
« no previous file with comments | « lib/runtime/dart/collection.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dev_compiler.src.codegen.js_codegen; 5 library dev_compiler.src.codegen.js_codegen;
6 6
7 import 'dart:collection' show HashSet, HashMap, SplayTreeSet; 7 import 'dart:collection' show HashSet, HashMap, SplayTreeSet;
8 8
9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; 9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator;
10 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator; 10 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator;
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 ]); 322 ]);
323 323
324 return _finishClassDef(type, fnType); 324 return _finishClassDef(type, fnType);
325 } 325 }
326 326
327 @override 327 @override
328 JS.Expression visitTypeName(TypeName node) => _emitTypeName(node.type); 328 JS.Expression visitTypeName(TypeName node) => _emitTypeName(node.type);
329 329
330 @override 330 @override
331 JS.Statement visitClassTypeAlias(ClassTypeAlias node) { 331 JS.Statement visitClassTypeAlias(ClassTypeAlias node) {
332 // If we've already emitted this class, skip it. 332 // If we've already emitted this class, skip it.
vsm 2015/06/19 23:20:40 Is this comment still valid?
Jennifer Messerly 2015/06/22 15:55:44 Good catch, removed (from 3 places!)
333 var element = node.element; 333 var element = node.element;
334 334
335 // Forward all generative constructors from the base class.
336 var body = [];
337
338 var supertype = element.supertype;
339 if (!supertype.isObject) {
340 for (var ctor in element.constructors) {
341 var parentCtor = supertype.lookUpConstructor(ctor.name, ctor.library);
342 var fun = js.call('function() { super.#(...#); }', [
vsm 2015/06/19 23:20:40 It'd be nice to have the args here to show the act
Jennifer Messerly 2015/06/22 15:55:44 Agreed. However, there are a few reasons for not d
343 _constructorName(parentCtor),
344 new JS.Identifier('arguments', allowRename: false)
345 ]);
346 body.add(new JS.Method(_constructorName(ctor), fun));
347 }
348 }
349
335 var classDecl = new JS.ClassDeclaration(new JS.ClassExpression( 350 var classDecl = new JS.ClassDeclaration(new JS.ClassExpression(
336 new JS.Identifier(element.name), _classHeritage(element), [])); 351 new JS.Identifier(element.name), _classHeritage(element), body));
337 352
338 return _finishClassDef(element.type, classDecl); 353 return _finishClassDef(element.type, classDecl);
339 } 354 }
340 355
341 JS.Statement _emitJsType(String dartClassName, DartObjectImpl jsName) { 356 JS.Statement _emitJsType(String dartClassName, DartObjectImpl jsName) {
342 var jsTypeName = getConstantField(jsName, 'name', types.stringType); 357 var jsTypeName = getConstantField(jsName, 'name', types.stringType);
343 358
344 if (jsTypeName != null && jsTypeName != dartClassName) { 359 if (jsTypeName != null && jsTypeName != dartClassName) {
345 // We export the JS type as if it was a Dart type. For example this allows 360 // We export the JS type as if it was a Dart type. For example this allows
346 // `dom.InputElement` to actually be HTMLInputElement. 361 // `dom.InputElement` to actually be HTMLInputElement.
(...skipping 2443 matching lines...) Expand 10 before | Expand all | Expand 10 after
2790 2805
2791 /// A special kind of element created by the compiler, signifying a temporary 2806 /// A special kind of element created by the compiler, signifying a temporary
2792 /// variable. These objects use instance equality, and should be shared 2807 /// variable. These objects use instance equality, and should be shared
2793 /// everywhere in the tree where they are treated as the same variable. 2808 /// everywhere in the tree where they are treated as the same variable.
2794 class TemporaryVariableElement extends LocalVariableElementImpl { 2809 class TemporaryVariableElement extends LocalVariableElementImpl {
2795 TemporaryVariableElement.forNode(Identifier name) : super.forNode(name); 2810 TemporaryVariableElement.forNode(Identifier name) : super.forNode(name);
2796 2811
2797 int get hashCode => identityHashCode(this); 2812 int get hashCode => identityHashCode(this);
2798 bool operator ==(Object other) => identical(this, other); 2813 bool operator ==(Object other) => identical(this, other);
2799 } 2814 }
OLDNEW
« no previous file with comments | « lib/runtime/dart/collection.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698