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

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

Issue 1559233002: WIP: Compute constant expressions in resolution. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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 | « pkg/compiler/lib/src/constants/constant_system.dart ('k') | pkg/compiler/lib/src/constants/evaluation.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 7faf5933f6e2fde3a23cc1a1f8c578a1c2e1b271..49cf3e2bb1cefad5bdc4cf9186d2d55f2cb71e47 100644
--- a/pkg/compiler/lib/src/constants/constructors.dart
+++ b/pkg/compiler/lib/src/constants/constructors.dart
@@ -18,6 +18,7 @@ enum ConstantConstructorKind {
GENERATIVE,
REDIRECTING_GENERATIVE,
REDIRECTING_FACTORY,
+ ERRONEOUS,
}
/// Definition of a constant constructor.
@@ -34,6 +35,8 @@ abstract class ConstantConstructor {
List<ConstantExpression> arguments,
CallStructure callStructure);
+ ConstructorElement get parentConstructor;
+
accept(ConstantConstructorVisitor visitor, arg);
}
@@ -49,6 +52,7 @@ abstract class ConstantConstructorVisitor<R, A> {
RedirectingGenerativeConstantConstructor constructor, A arg);
R visitRedirectingFactory(
RedirectingFactoryConstantConstructor constructor, A arg);
+ R visitErroneous(ErroneousConstantConstructor constructor, A arg);
}
/// A generative constant constructor.
@@ -70,6 +74,13 @@ class GenerativeConstantConstructor implements ConstantConstructor{
return type.substByContext(newType);
}
+ ConstructorElement get parentConstructor {
+ if (superConstructorInvocation != null) {
+ return superConstructorInvocation.target;
+ }
+ return null;
+ }
+
Map<FieldElement, ConstantExpression> computeInstanceFields(
List<ConstantExpression> arguments,
CallStructure callStructure) {
@@ -162,6 +173,10 @@ class RedirectingGenerativeConstantConstructor implements ConstantConstructor {
return ConstantConstructorKind.REDIRECTING_GENERATIVE;
}
+ ConstructorElement get parentConstructor {
+ return thisConstructorInvocation.target;
+ }
+
InterfaceType computeInstanceType(InterfaceType newType) {
return thisConstructorInvocation.computeInstanceType()
.substByContext(newType);
@@ -218,6 +233,10 @@ class RedirectingFactoryConstantConstructor implements ConstantConstructor {
return ConstantConstructorKind.REDIRECTING_FACTORY;
}
+ ConstructorElement get parentConstructor {
+ return targetConstructorInvocation.target;
+ }
+
InterfaceType computeInstanceType(InterfaceType newType) {
return targetConstructorInvocation.computeInstanceType()
.substByContext(newType);
@@ -253,3 +272,31 @@ class RedirectingFactoryConstantConstructor implements ConstantConstructor {
return sb.toString();
}
}
+
+/// An erroneous constant constructor.
+class ErroneousConstantConstructor implements ConstantConstructor {
+ const ErroneousConstantConstructor();
+
+ @override
+ accept(ConstantConstructorVisitor visitor, arg) {
+ return visitor.visitErroneous(this, arg);
+ }
+
+ @override
+ Map<FieldElement, ConstantExpression> computeInstanceFields(
+ List<ConstantExpression> arguments, CallStructure callStructure) {
+ return null;
+ }
+
+ @override
+ InterfaceType computeInstanceType(InterfaceType newType) {
+ throw new UnsupportedError(
+ 'ErroneousConstantConstructor.computeInstanceType is unsupported.');
+ }
+
+ @override
+ ConstantConstructorKind get kind => ConstantConstructorKind.ERRONEOUS;
+
+ @override
+ ConstructorElement get parentConstructor => null;
+}
« no previous file with comments | « pkg/compiler/lib/src/constants/constant_system.dart ('k') | pkg/compiler/lib/src/constants/evaluation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698