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

Side by Side Diff: pkg/compiler/lib/src/elements/modelx.dart

Issue 867233004: Support constructor declarations in analyzer2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 5 years, 10 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 elements.modelx; 5 library elements.modelx;
6 6
7 import 'elements.dart'; 7 import 'elements.dart';
8 import '../constants/expressions.dart'; 8 import '../constants/expressions.dart';
9 import '../helpers/helpers.dart'; // Included for debug helpers. 9 import '../helpers/helpers.dart'; // Included for debug helpers.
10 import '../tree/tree.dart'; 10 import '../tree/tree.dart';
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 292
293 get asyncMarker => AsyncMarker.SYNC; 293 get asyncMarker => AsyncMarker.SYNC;
294 Link<MetadataAnnotation> get metadata => unsupported(); 294 Link<MetadataAnnotation> get metadata => unsupported();
295 bool get hasNode => false; 295 bool get hasNode => false;
296 get node => unsupported(); 296 get node => unsupported();
297 get hasResolvedAst => false; 297 get hasResolvedAst => false;
298 get resolvedAst => unsupported(); 298 get resolvedAst => unsupported();
299 get type => unsupported(); 299 get type => unsupported();
300 get cachedNode => unsupported(); 300 get cachedNode => unsupported();
301 get functionSignature => unsupported(); 301 get functionSignature => unsupported();
302 get parameters => unsupported();
302 get patch => null; 303 get patch => null;
303 get origin => this; 304 get origin => this;
304 get immediateRedirectionTarget => unsupported(); 305 get immediateRedirectionTarget => unsupported();
305 get nestedClosures => unsupported(); 306 get nestedClosures => unsupported();
306 get memberContext => unsupported(); 307 get memberContext => unsupported();
307 get executableContext => unsupported(); 308 get executableContext => unsupported();
308 get isExternal => unsupported(); 309 get isExternal => unsupported();
309 310
310 bool get isRedirectingFactory => unsupported(); 311 bool get isRedirectingFactory => unsupported();
311 312
(...skipping 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 1526
1526 /// [Element] for a formal parameter. 1527 /// [Element] for a formal parameter.
1527 /// 1528 ///
1528 /// A [ParameterElementX] can be patched. A parameter of an external method is 1529 /// A [ParameterElementX] can be patched. A parameter of an external method is
1529 /// patched with the corresponding parameter of the patch method. This is done 1530 /// patched with the corresponding parameter of the patch method. This is done
1530 /// to ensure that default values on parameters are computed once (on the 1531 /// to ensure that default values on parameters are computed once (on the
1531 /// origin parameter) but can be found through both the origin and the patch. 1532 /// origin parameter) but can be found through both the origin and the patch.
1532 abstract class ParameterElementX extends FormalElementX 1533 abstract class ParameterElementX extends FormalElementX
1533 with PatchMixin<ParameterElement> implements ParameterElement { 1534 with PatchMixin<ParameterElement> implements ParameterElement {
1534 final Expression initializer; 1535 final Expression initializer;
1536 final bool isOptional;
1537 final bool isNamed;
1535 1538
1536 ParameterElementX(ElementKind elementKind, 1539 ParameterElementX(ElementKind elementKind,
1537 FunctionElement functionDeclaration, 1540 FunctionElement functionDeclaration,
1538 VariableDefinitions definitions, 1541 VariableDefinitions definitions,
1539 Identifier identifier, 1542 Identifier identifier,
1540 this.initializer) 1543 this.initializer,
1544 {this.isOptional: false,
1545 this.isNamed: false})
1541 : super(elementKind, functionDeclaration, definitions, identifier); 1546 : super(elementKind, functionDeclaration, definitions, identifier);
1542 1547
1543 FunctionElement get functionDeclaration => enclosingElement; 1548 FunctionElement get functionDeclaration => enclosingElement;
1544 1549
1545 ExecutableElement get executableContext => enclosingElement; 1550 ExecutableElement get executableContext => enclosingElement;
1546 1551
1547 MemberElement get memberContext => executableContext.memberContext; 1552 MemberElement get memberContext => executableContext.memberContext;
1548 1553
1549 accept(ElementVisitor visitor) => visitor.visitParameterElement(this); 1554 accept(ElementVisitor visitor) => visitor.visitParameterElement(this);
1550 1555
1551 bool get isLocal => true; 1556 bool get isLocal => true;
1552 } 1557 }
1553 1558
1554 class LocalParameterElementX extends ParameterElementX 1559 class LocalParameterElementX extends ParameterElementX
1555 implements LocalParameterElement { 1560 implements LocalParameterElement {
1561
1562
1556 LocalParameterElementX(FunctionElement functionDeclaration, 1563 LocalParameterElementX(FunctionElement functionDeclaration,
1557 VariableDefinitions definitions, 1564 VariableDefinitions definitions,
1558 Identifier identifier, 1565 Identifier identifier,
1559 Expression initializer) 1566 Expression initializer,
1567 {bool isOptional: false,
1568 bool isNamed: false})
1560 : super(ElementKind.PARAMETER, functionDeclaration, 1569 : super(ElementKind.PARAMETER, functionDeclaration,
1561 definitions, identifier, initializer); 1570 definitions, identifier, initializer,
1571 isOptional: isOptional, isNamed: isNamed);
1562 } 1572 }
1563 1573
1564 /// Parameters in constructors that directly initialize fields. For example: 1574 /// Parameters in constructors that directly initialize fields. For example:
1565 /// `A(this.field)`. 1575 /// `A(this.field)`.
1566 class InitializingFormalElementX extends ParameterElementX 1576 class InitializingFormalElementX extends ParameterElementX
1567 implements InitializingFormalElement { 1577 implements InitializingFormalElement {
1568 final FieldElement fieldElement; 1578 final FieldElement fieldElement;
1569 1579
1570 InitializingFormalElementX(ConstructorElement constructorDeclaration, 1580 InitializingFormalElementX(ConstructorElement constructorDeclaration,
1571 VariableDefinitions variables, 1581 VariableDefinitions variables,
1572 Identifier identifier, 1582 Identifier identifier,
1573 Expression initializer, 1583 Expression initializer,
1574 this.fieldElement) 1584 this.fieldElement,
1585 {bool isOptional: false,
1586 bool isNamed: false})
1575 : super(ElementKind.INITIALIZING_FORMAL, constructorDeclaration, 1587 : super(ElementKind.INITIALIZING_FORMAL, constructorDeclaration,
1576 variables, identifier, initializer); 1588 variables, identifier, initializer,
1589 isOptional: isOptional, isNamed: isNamed);
1577 1590
1578 accept(ElementVisitor visitor) => visitor.visitFieldParameterElement(this); 1591 accept(ElementVisitor visitor) => visitor.visitFieldParameterElement(this);
1579 1592
1580 MemberElement get memberContext => enclosingElement; 1593 MemberElement get memberContext => enclosingElement;
1581 1594
1582 bool get isLocal => false; 1595 bool get isLocal => false;
1583 } 1596 }
1584 1597
1585 class ErroneousInitializingFormalElementX extends ParameterElementX 1598 class ErroneousInitializingFormalElementX extends ParameterElementX
1586 implements InitializingFormalElementX { 1599 implements InitializingFormalElementX {
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1799 }); 1812 });
1800 return functionSignatureCache; 1813 return functionSignatureCache;
1801 } 1814 }
1802 1815
1803 FunctionSignature get functionSignature { 1816 FunctionSignature get functionSignature {
1804 assert(invariant(this, functionSignatureCache != null, 1817 assert(invariant(this, functionSignatureCache != null,
1805 message: "Function signature has not been computed for $this.")); 1818 message: "Function signature has not been computed for $this."));
1806 return functionSignatureCache; 1819 return functionSignatureCache;
1807 } 1820 }
1808 1821
1822 List<ParameterElement> get parameters {
1823 // TODO(johnniwinther): Store the list directly, possibly by using List
1824 // instead of Link in FunctionSignature.
1825 List<ParameterElement> list = <ParameterElement>[];
1826 functionSignature.forEachParameter((e) => list.add(e));
1827 return list;
1828 }
1829
1809 FunctionType computeType(Compiler compiler) { 1830 FunctionType computeType(Compiler compiler) {
1810 if (typeCache != null) return typeCache; 1831 if (typeCache != null) return typeCache;
1811 typeCache = computeSignature(compiler).type; 1832 typeCache = computeSignature(compiler).type;
1812 return typeCache; 1833 return typeCache;
1813 } 1834 }
1814 1835
1815 FunctionType get type { 1836 FunctionType get type {
1816 assert(invariant(this, typeCache != null, 1837 assert(invariant(this, typeCache != null,
1817 message: "Type has not been computed for $this.")); 1838 message: "Type has not been computed for $this."));
1818 return typeCache; 1839 return typeCache;
(...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after
3044 AstElement get definingElement; 3065 AstElement get definingElement;
3045 3066
3046 bool get hasResolvedAst => definingElement.hasTreeElements; 3067 bool get hasResolvedAst => definingElement.hasTreeElements;
3047 3068
3048 ResolvedAst get resolvedAst { 3069 ResolvedAst get resolvedAst {
3049 return new ResolvedAst(declaration, 3070 return new ResolvedAst(declaration,
3050 definingElement.node, definingElement.treeElements); 3071 definingElement.node, definingElement.treeElements);
3051 } 3072 }
3052 3073
3053 } 3074 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/elements/elements.dart ('k') | pkg/compiler/lib/src/resolution/signatures.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698