Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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 { | |
|
herhut
2015/01/28 14:12:50
Does this have to be a List or would an Iterable d
Johnni Winther
2015/01/29 07:51:07
Adding a TODO to store the list directly while rem
| |
| 1823 List<ParameterElement> list = <ParameterElement>[]; | |
| 1824 functionSignature.forEachParameter((e) => list.add(e)); | |
| 1825 return list; | |
| 1826 } | |
| 1827 | |
| 1809 FunctionType computeType(Compiler compiler) { | 1828 FunctionType computeType(Compiler compiler) { |
| 1810 if (typeCache != null) return typeCache; | 1829 if (typeCache != null) return typeCache; |
| 1811 typeCache = computeSignature(compiler).type; | 1830 typeCache = computeSignature(compiler).type; |
| 1812 return typeCache; | 1831 return typeCache; |
| 1813 } | 1832 } |
| 1814 | 1833 |
| 1815 FunctionType get type { | 1834 FunctionType get type { |
| 1816 assert(invariant(this, typeCache != null, | 1835 assert(invariant(this, typeCache != null, |
| 1817 message: "Type has not been computed for $this.")); | 1836 message: "Type has not been computed for $this.")); |
| 1818 return typeCache; | 1837 return typeCache; |
| (...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3044 AstElement get definingElement; | 3063 AstElement get definingElement; |
| 3045 | 3064 |
| 3046 bool get hasResolvedAst => definingElement.hasTreeElements; | 3065 bool get hasResolvedAst => definingElement.hasTreeElements; |
| 3047 | 3066 |
| 3048 ResolvedAst get resolvedAst { | 3067 ResolvedAst get resolvedAst { |
| 3049 return new ResolvedAst(declaration, | 3068 return new ResolvedAst(declaration, |
| 3050 definingElement.node, definingElement.treeElements); | 3069 definingElement.node, definingElement.treeElements); |
| 3051 } | 3070 } |
| 3052 | 3071 |
| 3053 } | 3072 } |
| OLD | NEW |