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

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

Issue 1122883002: Do not suppress implicit constructors that need a super call. (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 7 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/core.js ('k') | test/codegen/expect/cascade.js » ('j') | 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; 7 import 'dart:collection' show HashSet, HashMap;
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 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 ]); 675 ]);
676 } 676 }
677 677
678 /// Generates the implicit default constructor for class C of the form 678 /// Generates the implicit default constructor for class C of the form
679 /// `C() : super() {}`. 679 /// `C() : super() {}`.
680 JS.Method _emitImplicitConstructor( 680 JS.Method _emitImplicitConstructor(
681 ClassDeclaration node, String name, List<FieldDeclaration> fields) { 681 ClassDeclaration node, String name, List<FieldDeclaration> fields) {
682 assert(_hasUnnamedConstructor(node.element) == fields.isNotEmpty); 682 assert(_hasUnnamedConstructor(node.element) == fields.isNotEmpty);
683 683
684 // If we don't have a method body, skip this. 684 // If we don't have a method body, skip this.
685 if (fields.isEmpty) return null; 685 var superCall = _superConstructorCall(node);
686 if (fields.isEmpty && superCall == null) return null;
686 687
687 dynamic body = _initializeFields(fields); 688 dynamic body = _initializeFields(fields);
688 var superCall = _superConstructorCall(node);
689 if (superCall != null) body = [[body, superCall]]; 689 if (superCall != null) body = [[body, superCall]];
690 return new JS.Method( 690 return new JS.Method(
691 _propertyName(name), js.call('function() { #; }', body)); 691 _propertyName(name), js.call('function() { #; }', body));
692 } 692 }
693 693
694 JS.Method _emitConstructor(ConstructorDeclaration node, String className, 694 JS.Method _emitConstructor(ConstructorDeclaration node, String className,
695 List<FieldDeclaration> fields, bool isObject) { 695 List<FieldDeclaration> fields, bool isObject) {
696 if (_externalOrNative(node)) return null; 696 if (_externalOrNative(node)) return null;
697 697
698 var name = _constructorName(className, node.name); 698 var name = _constructorName(className, node.name);
(...skipping 1839 matching lines...) Expand 10 before | Expand all | Expand 10 after
2538 // TODO(jmesserly): validate the library. See issue #135. 2538 // TODO(jmesserly): validate the library. See issue #135.
2539 bool _isJsNameAnnotation(DartObjectImpl value) => value.type.name == 'JsName'; 2539 bool _isJsNameAnnotation(DartObjectImpl value) => value.type.name == 'JsName';
2540 2540
2541 bool _isJsPeerInterface(DartObjectImpl value) => 2541 bool _isJsPeerInterface(DartObjectImpl value) =>
2542 value.type.name == 'JsPeerInterface'; 2542 value.type.name == 'JsPeerInterface';
2543 2543
2544 // TODO(jacobr): we would like to do something like the following 2544 // TODO(jacobr): we would like to do something like the following
2545 // but we don't have summary support yet. 2545 // but we don't have summary support yet.
2546 // bool _supportJsExtensionMethod(AnnotatedNode node) => 2546 // bool _supportJsExtensionMethod(AnnotatedNode node) =>
2547 // _getAnnotation(node, "SupportJsExtensionMethod") != null; 2547 // _getAnnotation(node, "SupportJsExtensionMethod") != null;
OLDNEW
« no previous file with comments | « lib/runtime/dart/core.js ('k') | test/codegen/expect/cascade.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698