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

Side by Side 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, 8 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 | Annotate | Revision Log
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 dart2js.send_structure; 5 library dart2js.send_structure;
6 6
7 import 'access_semantics.dart'; 7 import 'access_semantics.dart';
8 import 'operators.dart'; 8 import 'operators.dart';
9 import 'semantic_visitor.dart'; 9 import 'semantic_visitor.dart';
10 import '../dart_types.dart';
11 import '../constants/expressions.dart';
12 import '../elements/elements.dart';
10 import '../tree/tree.dart'; 13 import '../tree/tree.dart';
11 import '../dart_types.dart';
12 import '../universe/universe.dart'; 14 import '../universe/universe.dart';
13 import '../util/util.dart'; 15 import '../util/util.dart';
14 16
15 /// Interface for the structure of the semantics of a [Send] node. 17 /// Interface for the structure of the semantics of a [Send] node.
16 /// 18 ///
17 /// Subclasses handle each of the [Send] variations; `assert(e)`, `a && b`, 19 /// Subclasses handle each of the [Send] variations; `assert(e)`, `a && b`,
18 /// `a.b`, `a.b(c)`, etc. 20 /// `a.b`, `a.b(c)`, etc.
19 abstract class SendStructure<R, A> { 21 abstract class SendStructure<R, A> {
20 /// Calls the matching visit method on [visitor] with [send] and [arg]. 22 /// Calls the matching visit method on [visitor] with [send] and [arg].
21 R dispatch(SemanticSendVisitor<R, A> visitor, Send send, A arg); 23 R dispatch(SemanticSendVisitor<R, A> visitor, Send send, A arg);
(...skipping 1779 matching lines...) Expand 10 before | Expand all | Expand 10 after
1801 arg); 1803 arg);
1802 } 1804 }
1803 } 1805 }
1804 throw new SpannableAssertionFailure(node, 1806 throw new SpannableAssertionFailure(node,
1805 "Invalid compound assigment: ${semantics}"); 1807 "Invalid compound assigment: ${semantics}");
1806 } 1808 }
1807 1809
1808 String toString() => 'postfix($operator,$semantics)'; 1810 String toString() => 'postfix($operator,$semantics)';
1809 } 1811 }
1810 1812
1813 /// The structure for a [NewExpression] of a new invocation.
1814 abstract class NewStructure<R, A> {
1815 /// Calls the matching visit method on [visitor] with [node] and [arg].
1816 R dispatch(SemanticSendVisitor<R, A> visitor, NewExpression node, A arg);
1817 }
1818
1819 /// The structure for a [NewExpression] of a new invocation. For instance
1820 /// `new C()`.
1821 class NewInvokeStructure<R, A> extends NewStructure<R, A> {
1822 final ConstructorAccessSemantics semantics;
1823 final Selector selector;
1824
1825 NewInvokeStructure(this.semantics, this.selector);
1826
1827 R dispatch(SemanticSendVisitor<R, A> visitor, NewExpression node, A arg) {
1828 switch (semantics.kind) {
1829 case ConstructorAccessKind.GENERATIVE:
1830 return visitor.visitGenerativeConstructorInvoke(
1831 node, semantics.element, semantics.type,
1832 node.send.argumentsNode, selector, arg);
1833 case ConstructorAccessKind.REDIRECTING_GENERATIVE:
1834 return visitor.visitRedirectingGenerativeConstructorInvoke(
1835 node, semantics.element, semantics.type,
1836 node.send.argumentsNode, selector, arg);
1837 case ConstructorAccessKind.FACTORY:
1838 return visitor.visitFactoryConstructorInvoke(
1839 node, semantics.element, semantics.type,
1840 node.send.argumentsNode, selector, arg);
1841 case ConstructorAccessKind.REDIRECTING_FACTORY:
1842 return visitor.visitRedirectingFactoryConstructorInvoke(
1843 node, semantics.element, semantics.type,
1844 semantics.effectiveTargetSemantics.element,
1845 semantics.effectiveTargetSemantics.type,
1846 node.send.argumentsNode, selector, arg);
1847 case ConstructorAccessKind.ABSTRACT:
1848 return visitor.errorAbstractClassConstructorInvoke(
1849 node, semantics.element, semantics.type,
1850 node.send.argumentsNode, selector, arg);
1851 case ConstructorAccessKind.ERRONEOUS:
1852 return visitor.errorUnresolvedConstructorInvoke(
1853 node, semantics.element, semantics.type,
1854 node.send.argumentsNode, selector, arg);
1855 case ConstructorAccessKind.ERRONEOUS_REDIRECTING_FACTORY:
1856 return visitor.errorUnresolvedRedirectingFactoryConstructorInvoke(
1857 node, semantics.element, semantics.type,
1858 node.send.argumentsNode, selector, arg);
1859 }
1860 throw new SpannableAssertionFailure(node,
1861 "Unhandled constructor invocation kind: ${semantics.kind}");
1862 }
1863 }
1864
1865 /// The structure for a [NewExpression] of a constant invocation. For instance
1866 /// `const C()`.
1867 class ConstInvokeStructure<R, A> extends NewStructure<R, A> {
1868 final ConstructedConstantExpression constant;
1869
1870 ConstInvokeStructure(this.constant);
1871
1872 R dispatch(SemanticSendVisitor<R, A> visitor, NewExpression node, A arg) {
1873 return visitor.visitConstConstructorInvoke(node, constant, arg);
1874 }
1875 }
1876
OLDNEW
« 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