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

Unified Diff: pkg/compiler/lib/src/constants/constructors.dart

Issue 1160153002: Support implicit super constructor invocation in SemanticDeclarationVisitor. (Closed) Base URL: https://github.com/dart-lang/sdk.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/compiler/lib/src/resolution/semantic_visitor.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/constants/constructors.dart
diff --git a/pkg/compiler/lib/src/constants/constructors.dart b/pkg/compiler/lib/src/constants/constructors.dart
index 3c09a94bc6086b6fdc761009017603dee8b6b718..2e83e56ee44f63ad27304c300d28abc97ca83c54 100644
--- a/pkg/compiler/lib/src/constants/constructors.dart
+++ b/pkg/compiler/lib/src/constants/constructors.dart
@@ -4,16 +4,17 @@
library dart2js.constants.constructors;
-import '../elements/elements.dart';
-import 'expressions.dart';
-import 'values.dart';
+import '../dart2jslib.dart';
import '../dart_types.dart';
+import '../elements/elements.dart';
import '../resolution/resolution.dart';
import '../resolution/operators.dart';
import '../resolution/semantic_visitor.dart';
import '../resolution/send_structure.dart';
-import '../dart2jslib.dart';
import '../tree/tree.dart';
+import '../universe/universe.dart' show CallStructure;
+import 'expressions.dart';
+import 'values.dart';
ConstantConstructor computeConstantConstructor(ResolvedAst resolvedAst) {
ConstantConstructorComputer visitor =
@@ -80,7 +81,7 @@ class ConstantConstructorComputer extends SemanticVisitor
_) {
applyParameters(parameters, _);
ConstructedConstantExpression constructorInvocation =
- applyInitializers(initializers, _);
+ applyInitializers(node, _);
return new GenerativeConstantConstructor(
currentClass.thisType, defaultValues, fieldMap, constructorInvocation);
}
@@ -93,7 +94,7 @@ class ConstantConstructorComputer extends SemanticVisitor
_) {
applyParameters(parameters, _);
ConstructedConstantExpression constructorInvocation =
- applyInitializers(initializers, _);
+ applyInitializers(node, _);
return new RedirectingGenerativeConstantConstructor(
defaultValues, constructorInvocation);
}
@@ -207,28 +208,18 @@ class ConstantConstructorComputer extends SemanticVisitor
}
/// Apply this visitor to the constructor [initializers].
- ConstructedConstantExpression applyInitializers(NodeList initializers, _) {
+ ConstructedConstantExpression applyInitializers(
+ FunctionExpression constructor, _) {
ConstructedConstantExpression constructorInvocation;
- if (initializers != null) {
- for (Node initializer in initializers) {
- InitializerStructure structure =
- computeInitializerStructure(initializer);
- if (structure is SuperConstructorInvokeStructure ||
- structure is ThisConstructorInvokeStructure) {
- constructorInvocation = structure.dispatch(this, initializer, _);
- } else {
- structure.dispatch(this, initializer, _);
- }
+ InitializersStructure initializers =
+ computeInitializersStructure(constructor);
+ for (InitializerStructure structure in initializers.initializers) {
+ if (structure.isConstructorInvoke) {
+ constructorInvocation = structure.dispatch(this, _);
+ } else {
+ structure.dispatch(this, _);
}
}
- if (constructorInvocation == null && !currentClass.isObject) {
- constructorInvocation =
- new ConstructedConstantExpression(null,
- currentClass.supertype,
- currentClass.superclass.lookupDefaultConstructor(),
- CallStructure.NO_ARGS,
- const <ConstantExpression>[]);
- }
return constructorInvocation;
}
@@ -257,29 +248,41 @@ class ConstantConstructorComputer extends SemanticVisitor
ConstructorElement superConstructor,
InterfaceType type,
NodeList arguments,
- Selector selector,
+ CallStructure callStructure,
_) {
List<ConstantExpression> argumentExpression =
arguments.nodes.map((a) => apply(a)).toList();
return new ConstructedConstantExpression(null,
type,
superConstructor,
- selector.callStructure,
+ callStructure,
argumentExpression);
}
+ ConstructedConstantExpression visitImplicitSuperConstructorInvoke(
+ FunctionExpression node,
+ ConstructorElement superConstructor,
+ InterfaceType type,
+ _) {
+ return new ConstructedConstantExpression(null,
+ type,
+ superConstructor,
+ CallStructure.NO_ARGS,
+ const <ConstantExpression>[]);
+ }
+
ConstructedConstantExpression visitThisConstructorInvoke(
Send node,
ConstructorElement thisConstructor,
NodeList arguments,
- Selector selector,
+ CallStructure callStructure,
_) {
List<ConstantExpression> argumentExpression =
arguments.nodes.map((a) => apply(a)).toList();
return new ConstructedConstantExpression(null,
currentClass.thisType,
thisConstructor,
- selector.callStructure,
+ callStructure,
argumentExpression);
}
« no previous file with comments | « no previous file | pkg/compiler/lib/src/resolution/semantic_visitor.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698