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

Unified Diff: pkg/compiler/lib/src/resolution/send_structure.dart

Issue 1043723002: Handle NewExpression in SemanticSendVisitor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased+fix modely.dart 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 | « pkg/compiler/lib/src/resolution/send_resolver.dart ('k') | pkg/compiler/lib/src/resolved_visitor.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/resolution/send_structure.dart
diff --git a/pkg/compiler/lib/src/resolution/send_structure.dart b/pkg/compiler/lib/src/resolution/send_structure.dart
index e0f6d3090687c8a704b5b4f516516c6f99d0837c..d507dda98383057fd48f8468e2033630502daad8 100644
--- a/pkg/compiler/lib/src/resolution/send_structure.dart
+++ b/pkg/compiler/lib/src/resolution/send_structure.dart
@@ -7,8 +7,10 @@ library dart2js.send_structure;
import 'access_semantics.dart';
import 'operators.dart';
import 'semantic_visitor.dart';
-import '../tree/tree.dart';
import '../dart_types.dart';
+import '../constants/expressions.dart';
+import '../elements/elements.dart';
+import '../tree/tree.dart';
import '../universe/universe.dart';
import '../util/util.dart';
@@ -1808,3 +1810,67 @@ class PostfixStructure<R, A> implements SendStructure<R, A> {
String toString() => 'postfix($operator,$semantics)';
}
+/// The structure for a [NewExpression] of a new invocation.
+abstract class NewStructure<R, A> {
+ /// Calls the matching visit method on [visitor] with [node] and [arg].
+ R dispatch(SemanticSendVisitor<R, A> visitor, NewExpression node, A arg);
+}
+
+/// The structure for a [NewExpression] of a new invocation. For instance
+/// `new C()`.
+class NewInvokeStructure<R, A> extends NewStructure<R, A> {
+ final ConstructorAccessSemantics semantics;
+ final Selector selector;
+
+ NewInvokeStructure(this.semantics, this.selector);
+
+ R dispatch(SemanticSendVisitor<R, A> visitor, NewExpression node, A arg) {
+ switch (semantics.kind) {
+ case ConstructorAccessKind.GENERATIVE:
+ return visitor.visitGenerativeConstructorInvoke(
+ node, semantics.element, semantics.type,
+ node.send.argumentsNode, selector, arg);
+ case ConstructorAccessKind.REDIRECTING_GENERATIVE:
+ return visitor.visitRedirectingGenerativeConstructorInvoke(
+ node, semantics.element, semantics.type,
+ node.send.argumentsNode, selector, arg);
+ case ConstructorAccessKind.FACTORY:
+ return visitor.visitFactoryConstructorInvoke(
+ node, semantics.element, semantics.type,
+ node.send.argumentsNode, selector, arg);
+ case ConstructorAccessKind.REDIRECTING_FACTORY:
+ return visitor.visitRedirectingFactoryConstructorInvoke(
+ node, semantics.element, semantics.type,
+ semantics.effectiveTargetSemantics.element,
+ semantics.effectiveTargetSemantics.type,
+ node.send.argumentsNode, selector, arg);
+ case ConstructorAccessKind.ABSTRACT:
+ return visitor.errorAbstractClassConstructorInvoke(
+ node, semantics.element, semantics.type,
+ node.send.argumentsNode, selector, arg);
+ case ConstructorAccessKind.ERRONEOUS:
+ return visitor.errorUnresolvedConstructorInvoke(
+ node, semantics.element, semantics.type,
+ node.send.argumentsNode, selector, arg);
+ case ConstructorAccessKind.ERRONEOUS_REDIRECTING_FACTORY:
+ return visitor.errorUnresolvedRedirectingFactoryConstructorInvoke(
+ node, semantics.element, semantics.type,
+ node.send.argumentsNode, selector, arg);
+ }
+ throw new SpannableAssertionFailure(node,
+ "Unhandled constructor invocation kind: ${semantics.kind}");
+ }
+}
+
+/// The structure for a [NewExpression] of a constant invocation. For instance
+/// `const C()`.
+class ConstInvokeStructure<R, A> extends NewStructure<R, A> {
+ final ConstructedConstantExpression constant;
+
+ ConstInvokeStructure(this.constant);
+
+ R dispatch(SemanticSendVisitor<R, A> visitor, NewExpression node, A arg) {
+ return visitor.visitConstConstructorInvoke(node, constant, arg);
+ }
+}
+
« no previous file with comments | « pkg/compiler/lib/src/resolution/send_resolver.dart ('k') | pkg/compiler/lib/src/resolved_visitor.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698