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 '../common.dart'; | 7 import '../common.dart'; |
8 import '../common/resolution.dart' show Resolution, Parsing; | 8 import '../common/resolution.dart' show Resolution, ParsingContext; |
9 import '../compiler.dart' show Compiler; | 9 import '../compiler.dart' show Compiler; |
10 import '../constants/constant_constructors.dart'; | 10 import '../constants/constant_constructors.dart'; |
11 import '../constants/constructors.dart'; | 11 import '../constants/constructors.dart'; |
12 import '../constants/expressions.dart'; | 12 import '../constants/expressions.dart'; |
13 import '../dart_types.dart'; | 13 import '../dart_types.dart'; |
14 import '../diagnostics/messages.dart' show MessageTemplate; | 14 import '../diagnostics/messages.dart' show MessageTemplate; |
15 import '../ordered_typeset.dart' show OrderedTypeSet; | 15 import '../ordered_typeset.dart' show OrderedTypeSet; |
16 import '../resolution/class_members.dart' show ClassMemberMixin; | 16 import '../resolution/class_members.dart' show ClassMemberMixin; |
17 import '../resolution/scope.dart' | 17 import '../resolution/scope.dart' |
18 show ClassScope, LibraryScope, Scope, TypeDeclarationScope; | 18 show ClassScope, LibraryScope, Scope, TypeDeclarationScope; |
(...skipping 26 matching lines...) Expand all Loading... |
45 final Element enclosingElement; | 45 final Element enclosingElement; |
46 final int hashCode = ++elementHashCode; | 46 final int hashCode = ++elementHashCode; |
47 List<MetadataAnnotation> metadataInternal; | 47 List<MetadataAnnotation> metadataInternal; |
48 | 48 |
49 ElementX(this.name, this.kind, this.enclosingElement) { | 49 ElementX(this.name, this.kind, this.enclosingElement) { |
50 assert(isError || implementationLibrary != null); | 50 assert(isError || implementationLibrary != null); |
51 } | 51 } |
52 | 52 |
53 Modifiers get modifiers => Modifiers.EMPTY; | 53 Modifiers get modifiers => Modifiers.EMPTY; |
54 | 54 |
55 Node parseNode(Parsing parsing) { | 55 Node parseNode(ParsingContext parsing) { |
56 parsing.reporter.internalError(this, 'parseNode not implemented on $this.'); | 56 parsing.reporter.internalError(this, 'parseNode not implemented on $this.'); |
57 return null; | 57 return null; |
58 } | 58 } |
59 | 59 |
60 void set metadata(List<MetadataAnnotation> metadata) { | 60 void set metadata(List<MetadataAnnotation> metadata) { |
61 assert(metadataInternal == null); | 61 assert(metadataInternal == null); |
62 for (MetadataAnnotationX annotation in metadata) { | 62 for (MetadataAnnotationX annotation in metadata) { |
63 assert(annotation.annotatedElement == null); | 63 assert(annotation.annotatedElement == null); |
64 annotation.annotatedElement = this; | 64 annotation.annotatedElement = this; |
65 } | 65 } |
(...skipping 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1321 * kept to provide full information about parameter names through the mirror | 1321 * kept to provide full information about parameter names through the mirror |
1322 * system. | 1322 * system. |
1323 * | 1323 * |
1324 * The [functionSignature] is not available until the typedef element has been | 1324 * The [functionSignature] is not available until the typedef element has been |
1325 * resolved. | 1325 * resolved. |
1326 */ | 1326 */ |
1327 FunctionSignature functionSignature; | 1327 FunctionSignature functionSignature; |
1328 | 1328 |
1329 TypedefType computeType(Resolution resolution) { | 1329 TypedefType computeType(Resolution resolution) { |
1330 if (thisTypeCache != null) return thisTypeCache; | 1330 if (thisTypeCache != null) return thisTypeCache; |
1331 Typedef node = parseNode(resolution.parsing); | 1331 Typedef node = parseNode(resolution.parsingContext); |
1332 setThisAndRawTypes(createTypeVariables(node.typeParameters)); | 1332 setThisAndRawTypes(createTypeVariables(node.typeParameters)); |
1333 ensureResolved(resolution); | 1333 ensureResolved(resolution); |
1334 return thisTypeCache; | 1334 return thisTypeCache; |
1335 } | 1335 } |
1336 | 1336 |
1337 void ensureResolved(Resolution resolution) { | 1337 void ensureResolved(Resolution resolution) { |
1338 if (resolutionState == STATE_NOT_STARTED) { | 1338 if (resolutionState == STATE_NOT_STARTED) { |
1339 resolution.resolveTypedef(this); | 1339 resolution.resolveTypedef(this); |
1340 } | 1340 } |
1341 } | 1341 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1394 // @foo @bar var a, b, c | 1394 // @foo @bar var a, b, c |
1395 // | 1395 // |
1396 // the metadata list is reported through the declaration of `a`, and `b` | 1396 // the metadata list is reported through the declaration of `a`, and `b` |
1397 // and `c` report an empty list of metadata. | 1397 // and `c` report an empty list of metadata. |
1398 return; | 1398 return; |
1399 } | 1399 } |
1400 assert(metadataInternal == null); | 1400 assert(metadataInternal == null); |
1401 metadataInternal = metadata; | 1401 metadataInternal = metadata; |
1402 } | 1402 } |
1403 | 1403 |
1404 VariableDefinitions parseNode(Element element, Parsing parsing) { | 1404 VariableDefinitions parseNode(Element element, ParsingContext parsing) { |
1405 return definitions; | 1405 return definitions; |
1406 } | 1406 } |
1407 | 1407 |
1408 DartType computeType(Element element, Resolution resolution) => type; | 1408 DartType computeType(Element element, Resolution resolution) => type; |
1409 } | 1409 } |
1410 | 1410 |
1411 abstract class ConstantVariableMixin implements VariableElement { | 1411 abstract class ConstantVariableMixin implements VariableElement { |
1412 ConstantExpression constantCache; | 1412 ConstantExpression constantCache; |
1413 | 1413 |
1414 ConstantExpression get constant { | 1414 ConstantExpression get constant { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1473 message: "Node has not been computed for $this.")); | 1473 message: "Node has not been computed for $this.")); |
1474 return definitionsCache; | 1474 return definitionsCache; |
1475 } | 1475 } |
1476 | 1476 |
1477 Expression get initializer { | 1477 Expression get initializer { |
1478 assert(invariant(this, definitionsCache != null, | 1478 assert(invariant(this, definitionsCache != null, |
1479 message: "Initializer has not been computed for $this.")); | 1479 message: "Initializer has not been computed for $this.")); |
1480 return initializerCache; | 1480 return initializerCache; |
1481 } | 1481 } |
1482 | 1482 |
1483 Node parseNode(Parsing parsing) { | 1483 Node parseNode(ParsingContext parsing) { |
1484 if (definitionsCache != null) return definitionsCache; | 1484 if (definitionsCache != null) return definitionsCache; |
1485 | 1485 |
1486 VariableDefinitions definitions = variables.parseNode(this, parsing); | 1486 VariableDefinitions definitions = variables.parseNode(this, parsing); |
1487 createDefinitions(definitions); | 1487 createDefinitions(definitions); |
1488 return definitionsCache; | 1488 return definitionsCache; |
1489 } | 1489 } |
1490 | 1490 |
1491 void createDefinitions(VariableDefinitions definitions) { | 1491 void createDefinitions(VariableDefinitions definitions) { |
1492 assert(invariant(this, definitionsCache == null, | 1492 assert(invariant(this, definitionsCache == null, |
1493 message: "VariableDefinitions has already been computed for $this.")); | 1493 message: "VariableDefinitions has already been computed for $this.")); |
(...skipping 29 matching lines...) Expand all Loading... |
1523 definitions.definitions.beginToken, | 1523 definitions.definitions.beginToken, |
1524 const Link<Node>().prepend(node), | 1524 const Link<Node>().prepend(node), |
1525 definitions.definitions.endToken)); | 1525 definitions.definitions.endToken)); |
1526 } | 1526 } |
1527 } | 1527 } |
1528 | 1528 |
1529 DartType computeType(Resolution resolution) { | 1529 DartType computeType(Resolution resolution) { |
1530 if (variables.type != null) return variables.type; | 1530 if (variables.type != null) return variables.type; |
1531 // Call [parseNode] to ensure that [definitionsCache] and [initializerCache] | 1531 // Call [parseNode] to ensure that [definitionsCache] and [initializerCache] |
1532 // are set as a consequence of calling [computeType]. | 1532 // are set as a consequence of calling [computeType]. |
1533 parseNode(resolution.parsing); | 1533 parseNode(resolution.parsingContext); |
1534 return variables.computeType(this, resolution); | 1534 return variables.computeType(this, resolution); |
1535 } | 1535 } |
1536 | 1536 |
1537 DartType get type { | 1537 DartType get type { |
1538 assert(invariant(this, variables.type != null, | 1538 assert(invariant(this, variables.type != null, |
1539 message: "Type has not been computed for $this.")); | 1539 message: "Type has not been computed for $this.")); |
1540 return variables.type; | 1540 return variables.type; |
1541 } | 1541 } |
1542 | 1542 |
1543 bool get isInstanceMember => isClassMember && !isStatic; | 1543 bool get isInstanceMember => isClassMember && !isStatic; |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1693 this.definitions, Identifier identifier) | 1693 this.definitions, Identifier identifier) |
1694 : this.identifier = identifier, | 1694 : this.identifier = identifier, |
1695 super(identifier.source, elementKind, enclosingElement); | 1695 super(identifier.source, elementKind, enclosingElement); |
1696 | 1696 |
1697 FunctionTypedElement get functionDeclaration => enclosingElement; | 1697 FunctionTypedElement get functionDeclaration => enclosingElement; |
1698 | 1698 |
1699 Modifiers get modifiers => definitions.modifiers; | 1699 Modifiers get modifiers => definitions.modifiers; |
1700 | 1700 |
1701 Token get position => identifier.getBeginToken(); | 1701 Token get position => identifier.getBeginToken(); |
1702 | 1702 |
1703 Node parseNode(Parsing parsing) => definitions; | 1703 Node parseNode(ParsingContext parsing) => definitions; |
1704 | 1704 |
1705 DartType computeType(Resolution resolution) { | 1705 DartType computeType(Resolution resolution) { |
1706 assert(invariant(this, type != null, | 1706 assert(invariant(this, type != null, |
1707 message: "Parameter type has not been set for $this.")); | 1707 message: "Parameter type has not been set for $this.")); |
1708 return type; | 1708 return type; |
1709 } | 1709 } |
1710 | 1710 |
1711 DartType get type { | 1711 DartType get type { |
1712 assert(invariant(this, typeCache != null, | 1712 assert(invariant(this, typeCache != null, |
1713 message: "Parameter type has not been set for $this.")); | 1713 message: "Parameter type has not been set for $this.")); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1853 GetterElementX getter; | 1853 GetterElementX getter; |
1854 SetterElementX setter; | 1854 SetterElementX setter; |
1855 | 1855 |
1856 AbstractFieldElementX(String name, Element enclosing) | 1856 AbstractFieldElementX(String name, Element enclosing) |
1857 : super(name, ElementKind.ABSTRACT_FIELD, enclosing); | 1857 : super(name, ElementKind.ABSTRACT_FIELD, enclosing); |
1858 | 1858 |
1859 DartType computeType(Compiler compiler) { | 1859 DartType computeType(Compiler compiler) { |
1860 throw "internal error: AbstractFieldElement has no type"; | 1860 throw "internal error: AbstractFieldElement has no type"; |
1861 } | 1861 } |
1862 | 1862 |
1863 Node parseNode(Parsing parsing) { | 1863 Node parseNode(ParsingContext parsing) { |
1864 throw "internal error: AbstractFieldElement has no node"; | 1864 throw "internal error: AbstractFieldElement has no node"; |
1865 } | 1865 } |
1866 | 1866 |
1867 Token get position { | 1867 Token get position { |
1868 // The getter and setter may be defined in two different | 1868 // The getter and setter may be defined in two different |
1869 // compilation units. However, we know that one of them is | 1869 // compilation units. However, we know that one of them is |
1870 // non-null and defined in the same compilation unit as the | 1870 // non-null and defined in the same compilation unit as the |
1871 // abstract element. | 1871 // abstract element. |
1872 // TODO(lrn): No we don't know that if the element from the same | 1872 // TODO(lrn): No we don't know that if the element from the same |
1873 // compilation unit is patched. | 1873 // compilation unit is patched. |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2107 LocalFunctionElementX(String name, FunctionExpression this.node, | 2107 LocalFunctionElementX(String name, FunctionExpression this.node, |
2108 ElementKind kind, Modifiers modifiers, ExecutableElement enclosing) | 2108 ElementKind kind, Modifiers modifiers, ExecutableElement enclosing) |
2109 : super(name, kind, modifiers, enclosing); | 2109 : super(name, kind, modifiers, enclosing); |
2110 | 2110 |
2111 ExecutableElement get executableContext => enclosingElement; | 2111 ExecutableElement get executableContext => enclosingElement; |
2112 | 2112 |
2113 MemberElement get memberContext => executableContext.memberContext; | 2113 MemberElement get memberContext => executableContext.memberContext; |
2114 | 2114 |
2115 bool get hasNode => true; | 2115 bool get hasNode => true; |
2116 | 2116 |
2117 FunctionExpression parseNode(Parsing parsing) => node; | 2117 FunctionExpression parseNode(ParsingContext parsing) => node; |
2118 | 2118 |
2119 Token get position { | 2119 Token get position { |
2120 // Use the name as position if this is not an unnamed closure. | 2120 // Use the name as position if this is not an unnamed closure. |
2121 if (node.name != null) { | 2121 if (node.name != null) { |
2122 return node.name.getBeginToken(); | 2122 return node.name.getBeginToken(); |
2123 } else { | 2123 } else { |
2124 return node.getBeginToken(); | 2124 return node.getBeginToken(); |
2125 } | 2125 } |
2126 } | 2126 } |
2127 | 2127 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2264 | 2264 |
2265 bool get isSynthesized => true; | 2265 bool get isSynthesized => true; |
2266 | 2266 |
2267 bool get isDeferredLoaderGetter => true; | 2267 bool get isDeferredLoaderGetter => true; |
2268 | 2268 |
2269 bool get isTopLevel => true; | 2269 bool get isTopLevel => true; |
2270 // By having position null, the enclosing elements location is printed in | 2270 // By having position null, the enclosing elements location is printed in |
2271 // error messages. | 2271 // error messages. |
2272 Token get position => null; | 2272 Token get position => null; |
2273 | 2273 |
2274 FunctionExpression parseNode(Parsing parsing) => null; | 2274 FunctionExpression parseNode(ParsingContext parsing) => null; |
2275 | 2275 |
2276 bool get hasNode => false; | 2276 bool get hasNode => false; |
2277 | 2277 |
2278 FunctionExpression get node => null; | 2278 FunctionExpression get node => null; |
2279 | 2279 |
2280 @override | 2280 @override |
2281 SetterElement get setter => null; | 2281 SetterElement get setter => null; |
2282 } | 2282 } |
2283 | 2283 |
2284 class ConstructorBodyElementX extends BaseFunctionElementX | 2284 class ConstructorBodyElementX extends BaseFunctionElementX |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2345 functionSignature = new FunctionSignatureX( | 2345 functionSignature = new FunctionSignatureX( |
2346 type: new FunctionType.synthesized(enclosingClass.thisType)); | 2346 type: new FunctionType.synthesized(enclosingClass.thisType)); |
2347 _resolvedAst = | 2347 _resolvedAst = |
2348 new SynthesizedResolvedAst(this, ResolvedAstKind.DEFAULT_CONSTRUCTOR); | 2348 new SynthesizedResolvedAst(this, ResolvedAstKind.DEFAULT_CONSTRUCTOR); |
2349 } | 2349 } |
2350 | 2350 |
2351 bool get isDefaultConstructor { | 2351 bool get isDefaultConstructor { |
2352 return _resolvedAst.kind == ResolvedAstKind.DEFAULT_CONSTRUCTOR; | 2352 return _resolvedAst.kind == ResolvedAstKind.DEFAULT_CONSTRUCTOR; |
2353 } | 2353 } |
2354 | 2354 |
2355 FunctionExpression parseNode(Parsing parsing) => null; | 2355 FunctionExpression parseNode(ParsingContext parsing) => null; |
2356 | 2356 |
2357 bool get hasNode => false; | 2357 bool get hasNode => false; |
2358 | 2358 |
2359 FunctionExpression get node => null; | 2359 FunctionExpression get node => null; |
2360 | 2360 |
2361 Token get position => enclosingElement.position; | 2361 Token get position => enclosingElement.position; |
2362 | 2362 |
2363 bool get isSynthesized => true; | 2363 bool get isSynthesized => true; |
2364 | 2364 |
2365 bool get hasResolvedAst => true; | 2365 bool get hasResolvedAst => true; |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2526 @override | 2526 @override |
2527 bool get isEnumClass => false; | 2527 bool get isEnumClass => false; |
2528 | 2528 |
2529 InterfaceType computeType(Resolution resolution) { | 2529 InterfaceType computeType(Resolution resolution) { |
2530 if (isPatch) { | 2530 if (isPatch) { |
2531 origin.computeType(resolution); | 2531 origin.computeType(resolution); |
2532 thisTypeCache = origin.thisType; | 2532 thisTypeCache = origin.thisType; |
2533 rawTypeCache = origin.rawType; | 2533 rawTypeCache = origin.rawType; |
2534 } else if (thisTypeCache == null) { | 2534 } else if (thisTypeCache == null) { |
2535 computeThisAndRawType( | 2535 computeThisAndRawType( |
2536 resolution, computeTypeParameters(resolution.parsing)); | 2536 resolution, computeTypeParameters(resolution.parsingContext)); |
2537 } | 2537 } |
2538 return thisTypeCache; | 2538 return thisTypeCache; |
2539 } | 2539 } |
2540 | 2540 |
2541 void computeThisAndRawType( | 2541 void computeThisAndRawType( |
2542 Resolution resolution, List<DartType> typeVariables) { | 2542 Resolution resolution, List<DartType> typeVariables) { |
2543 if (thisTypeCache == null) { | 2543 if (thisTypeCache == null) { |
2544 if (origin == null) { | 2544 if (origin == null) { |
2545 setThisAndRawTypes(typeVariables); | 2545 setThisAndRawTypes(typeVariables); |
2546 } else { | 2546 } else { |
2547 thisTypeCache = origin.computeType(resolution); | 2547 thisTypeCache = origin.computeType(resolution); |
2548 rawTypeCache = origin.rawType; | 2548 rawTypeCache = origin.rawType; |
2549 } | 2549 } |
2550 } | 2550 } |
2551 } | 2551 } |
2552 | 2552 |
2553 @override | 2553 @override |
2554 InterfaceType createType(List<DartType> typeArguments) { | 2554 InterfaceType createType(List<DartType> typeArguments) { |
2555 return new InterfaceType(this, typeArguments); | 2555 return new InterfaceType(this, typeArguments); |
2556 } | 2556 } |
2557 | 2557 |
2558 List<DartType> computeTypeParameters(Parsing parsing); | 2558 List<DartType> computeTypeParameters(ParsingContext parsing); |
2559 | 2559 |
2560 bool get isObject { | 2560 bool get isObject { |
2561 assert(invariant(this, isResolved, | 2561 assert(invariant(this, isResolved, |
2562 message: "isObject has not been computed for $this.")); | 2562 message: "isObject has not been computed for $this.")); |
2563 return supertype == null; | 2563 return supertype == null; |
2564 } | 2564 } |
2565 | 2565 |
2566 void ensureResolved(Resolution resolution) { | 2566 void ensureResolved(Resolution resolution) { |
2567 if (resolutionState == STATE_NOT_STARTED) { | 2567 if (resolutionState == STATE_NOT_STARTED) { |
2568 resolution.resolveClass(this); | 2568 resolution.resolveClass(this); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2680 } | 2680 } |
2681 return false; | 2681 return false; |
2682 } | 2682 } |
2683 | 2683 |
2684 void setDefaultConstructor( | 2684 void setDefaultConstructor( |
2685 FunctionElement constructor, DiagnosticReporter reporter) { | 2685 FunctionElement constructor, DiagnosticReporter reporter) { |
2686 // The default constructor, although synthetic, is part of a class' API. | 2686 // The default constructor, although synthetic, is part of a class' API. |
2687 addMember(constructor, reporter); | 2687 addMember(constructor, reporter); |
2688 } | 2688 } |
2689 | 2689 |
2690 List<DartType> computeTypeParameters(Parsing parsing) { | 2690 List<DartType> computeTypeParameters(ParsingContext parsing) { |
2691 ClassNode node = parseNode(parsing); | 2691 ClassNode node = parseNode(parsing); |
2692 return createTypeVariables(node.typeParameters); | 2692 return createTypeVariables(node.typeParameters); |
2693 } | 2693 } |
2694 | 2694 |
2695 Scope buildScope() => new ClassScope(enclosingElement.buildScope(), this); | 2695 Scope buildScope() => new ClassScope(enclosingElement.buildScope(), this); |
2696 | 2696 |
2697 String toString() { | 2697 String toString() { |
2698 if (origin != null) { | 2698 if (origin != null) { |
2699 return 'patch ${super.toString()}'; | 2699 return 'patch ${super.toString()}'; |
2700 } else if (patch != null) { | 2700 } else if (patch != null) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2741 @override | 2741 @override |
2742 bool get hasNode => true; | 2742 bool get hasNode => true; |
2743 | 2743 |
2744 @override | 2744 @override |
2745 Token get position => node.name.token; | 2745 Token get position => node.name.token; |
2746 | 2746 |
2747 @override | 2747 @override |
2748 bool get isEnumClass => true; | 2748 bool get isEnumClass => true; |
2749 | 2749 |
2750 @override | 2750 @override |
2751 Node parseNode(Parsing parsing) => node; | 2751 Node parseNode(ParsingContext parsing) => node; |
2752 | 2752 |
2753 @override | 2753 @override |
2754 accept(ElementVisitor visitor, arg) { | 2754 accept(ElementVisitor visitor, arg) { |
2755 return visitor.visitEnumClassElement(this, arg); | 2755 return visitor.visitEnumClassElement(this, arg); |
2756 } | 2756 } |
2757 | 2757 |
2758 List<DartType> computeTypeParameters(Parsing parsing) => const <DartType>[]; | 2758 List<DartType> computeTypeParameters(ParsingContext parsing) => |
| 2759 const <DartType>[]; |
2759 | 2760 |
2760 List<FieldElement> get enumValues { | 2761 List<FieldElement> get enumValues { |
2761 assert(invariant(this, _enumValues != null, | 2762 assert(invariant(this, _enumValues != null, |
2762 message: "enumValues has not been computed for $this.")); | 2763 message: "enumValues has not been computed for $this.")); |
2763 return _enumValues; | 2764 return _enumValues; |
2764 } | 2765 } |
2765 | 2766 |
2766 void set enumValues(List<FieldElement> values) { | 2767 void set enumValues(List<FieldElement> values) { |
2767 assert(invariant(this, _enumValues == null, | 2768 assert(invariant(this, _enumValues == null, |
2768 message: "enumValues has already been computed for $this.")); | 2769 message: "enumValues has already been computed for $this.")); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2806 : super( | 2807 : super( |
2807 '', // Name. | 2808 '', // Name. |
2808 ElementKind.GENERATIVE_CONSTRUCTOR, | 2809 ElementKind.GENERATIVE_CONSTRUCTOR, |
2809 modifiers, | 2810 modifiers, |
2810 enumClass); | 2811 enumClass); |
2811 | 2812 |
2812 @override | 2813 @override |
2813 bool get hasNode => true; | 2814 bool get hasNode => true; |
2814 | 2815 |
2815 @override | 2816 @override |
2816 FunctionExpression parseNode(Parsing parsing) => node; | 2817 FunctionExpression parseNode(ParsingContext parsing) => node; |
2817 | 2818 |
2818 @override | 2819 @override |
2819 SourceSpan get sourcePosition => enclosingClass.sourcePosition; | 2820 SourceSpan get sourcePosition => enclosingClass.sourcePosition; |
2820 } | 2821 } |
2821 | 2822 |
2822 /// This element is used to encode the implicit methods in an enum class. | 2823 /// This element is used to encode the implicit methods in an enum class. |
2823 /// | 2824 /// |
2824 /// For instance | 2825 /// For instance |
2825 /// | 2826 /// |
2826 /// enum A { b, c, } | 2827 /// enum A { b, c, } |
(...skipping 21 matching lines...) Expand all Loading... |
2848 final FunctionExpression node; | 2849 final FunctionExpression node; |
2849 | 2850 |
2850 EnumMethodElementX( | 2851 EnumMethodElementX( |
2851 String name, EnumClassElementX enumClass, Modifiers modifiers, this.node) | 2852 String name, EnumClassElementX enumClass, Modifiers modifiers, this.node) |
2852 : super(name, ElementKind.FUNCTION, modifiers, enumClass, true); | 2853 : super(name, ElementKind.FUNCTION, modifiers, enumClass, true); |
2853 | 2854 |
2854 @override | 2855 @override |
2855 bool get hasNode => true; | 2856 bool get hasNode => true; |
2856 | 2857 |
2857 @override | 2858 @override |
2858 FunctionExpression parseNode(Parsing parsing) => node; | 2859 FunctionExpression parseNode(ParsingContext parsing) => node; |
2859 | 2860 |
2860 @override | 2861 @override |
2861 SourceSpan get sourcePosition => enclosingClass.sourcePosition; | 2862 SourceSpan get sourcePosition => enclosingClass.sourcePosition; |
2862 } | 2863 } |
2863 | 2864 |
2864 /// This element is used to encode the initializing formal of the implicit | 2865 /// This element is used to encode the initializing formal of the implicit |
2865 /// constructor in an enum class. | 2866 /// constructor in an enum class. |
2866 /// | 2867 /// |
2867 /// For instance | 2868 /// For instance |
2868 /// | 2869 /// |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3002 bool get hasConstructor => !constructors.isEmpty; | 3003 bool get hasConstructor => !constructors.isEmpty; |
3003 bool get hasLocalScopeMembers => !constructors.isEmpty; | 3004 bool get hasLocalScopeMembers => !constructors.isEmpty; |
3004 | 3005 |
3005 get patch => null; | 3006 get patch => null; |
3006 get origin => null; | 3007 get origin => null; |
3007 | 3008 |
3008 bool get hasNode => true; | 3009 bool get hasNode => true; |
3009 | 3010 |
3010 Token get position => node.getBeginToken(); | 3011 Token get position => node.getBeginToken(); |
3011 | 3012 |
3012 Node parseNode(Parsing parsing) => node; | 3013 Node parseNode(ParsingContext parsing) => node; |
3013 | 3014 |
3014 void addMember(Element element, DiagnosticReporter reporter) { | 3015 void addMember(Element element, DiagnosticReporter reporter) { |
3015 throw new UnsupportedError("Cannot add member to $this."); | 3016 throw new UnsupportedError("Cannot add member to $this."); |
3016 } | 3017 } |
3017 | 3018 |
3018 void addToScope(Element element, DiagnosticReporter reporter) { | 3019 void addToScope(Element element, DiagnosticReporter reporter) { |
3019 reporter.internalError(this, 'Cannot add to scope of $this.'); | 3020 reporter.internalError(this, 'Cannot add to scope of $this.'); |
3020 } | 3021 } |
3021 | 3022 |
3022 void addConstructor(FunctionElement constructor) { | 3023 void addConstructor(FunctionElement constructor) { |
3023 constructors = constructors.prepend(constructor); | 3024 constructors = constructors.prepend(constructor); |
3024 } | 3025 } |
3025 | 3026 |
3026 void setDefaultConstructor( | 3027 void setDefaultConstructor( |
3027 FunctionElement constructor, DiagnosticReporter reporter) { | 3028 FunctionElement constructor, DiagnosticReporter reporter) { |
3028 assert(!hasConstructor); | 3029 assert(!hasConstructor); |
3029 addConstructor(constructor); | 3030 addConstructor(constructor); |
3030 } | 3031 } |
3031 | 3032 |
3032 List<DartType> computeTypeParameters(Parsing parsing) { | 3033 List<DartType> computeTypeParameters(ParsingContext parsing) { |
3033 NamedMixinApplication named = node.asNamedMixinApplication(); | 3034 NamedMixinApplication named = node.asNamedMixinApplication(); |
3034 if (named == null) { | 3035 if (named == null) { |
3035 throw new SpannableAssertionFailure( | 3036 throw new SpannableAssertionFailure( |
3036 node, | 3037 node, |
3037 "Type variables on unnamed mixin applications must be set on " | 3038 "Type variables on unnamed mixin applications must be set on " |
3038 "creation."); | 3039 "creation."); |
3039 } | 3040 } |
3040 return createTypeVariables(named.typeParameters); | 3041 return createTypeVariables(named.typeParameters); |
3041 } | 3042 } |
3042 | 3043 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3146 } | 3147 } |
3147 | 3148 |
3148 DartType get bound { | 3149 DartType get bound { |
3149 assert(invariant(this, boundCache != null, | 3150 assert(invariant(this, boundCache != null, |
3150 message: "Bound has not been set on $this.")); | 3151 message: "Bound has not been set on $this.")); |
3151 return boundCache; | 3152 return boundCache; |
3152 } | 3153 } |
3153 | 3154 |
3154 bool get hasNode => true; | 3155 bool get hasNode => true; |
3155 | 3156 |
3156 Node parseNode(Parsing parsing) => node; | 3157 Node parseNode(ParsingContext parsing) => node; |
3157 | 3158 |
3158 Token get position => node.getBeginToken(); | 3159 Token get position => node.getBeginToken(); |
3159 | 3160 |
3160 accept(ElementVisitor visitor, arg) { | 3161 accept(ElementVisitor visitor, arg) { |
3161 return visitor.visitTypeVariableElement(this, arg); | 3162 return visitor.visitTypeVariableElement(this, arg); |
3162 } | 3163 } |
3163 | 3164 |
3164 // A type variable cannot be patched therefore defines itself. | 3165 // A type variable cannot be patched therefore defines itself. |
3165 AstElement get definingElement => this; | 3166 AstElement get definingElement => this; |
3166 } | 3167 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3209 if (annotatedElement.isClass || annotatedElement.isTypedef) { | 3210 if (annotatedElement.isClass || annotatedElement.isTypedef) { |
3210 TypeDeclarationElement typeDeclaration = annotatedElement; | 3211 TypeDeclarationElement typeDeclaration = annotatedElement; |
3211 typeDeclaration.ensureResolved(resolution); | 3212 typeDeclaration.ensureResolved(resolution); |
3212 } | 3213 } |
3213 if (resolutionState == STATE_NOT_STARTED) { | 3214 if (resolutionState == STATE_NOT_STARTED) { |
3214 resolution.resolveMetadataAnnotation(this); | 3215 resolution.resolveMetadataAnnotation(this); |
3215 } | 3216 } |
3216 return this; | 3217 return this; |
3217 } | 3218 } |
3218 | 3219 |
3219 Node parseNode(Parsing parsing); | 3220 Node parseNode(ParsingContext parsing); |
3220 | 3221 |
3221 String toString() => 'MetadataAnnotation($constant, $resolutionState)'; | 3222 String toString() => 'MetadataAnnotation($constant, $resolutionState)'; |
3222 } | 3223 } |
3223 | 3224 |
3224 /// Metadata annotation on a parameter. | 3225 /// Metadata annotation on a parameter. |
3225 class ParameterMetadataAnnotation extends MetadataAnnotationX { | 3226 class ParameterMetadataAnnotation extends MetadataAnnotationX { |
3226 final Metadata metadata; | 3227 final Metadata metadata; |
3227 | 3228 |
3228 ParameterMetadataAnnotation(Metadata this.metadata); | 3229 ParameterMetadataAnnotation(Metadata this.metadata); |
3229 | 3230 |
3230 Node parseNode(Parsing parsing) => metadata.expression; | 3231 Node parseNode(ParsingContext parsing) => metadata.expression; |
3231 | 3232 |
3232 Token get beginToken => metadata.getBeginToken(); | 3233 Token get beginToken => metadata.getBeginToken(); |
3233 | 3234 |
3234 Token get endToken => metadata.getEndToken(); | 3235 Token get endToken => metadata.getEndToken(); |
3235 | 3236 |
3236 bool get hasNode => true; | 3237 bool get hasNode => true; |
3237 | 3238 |
3238 Metadata get node => metadata; | 3239 Metadata get node => metadata; |
3239 } | 3240 } |
3240 | 3241 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3284 | 3285 |
3285 bool get hasResolvedAst { | 3286 bool get hasResolvedAst { |
3286 return definingElement.hasNode && definingElement.hasTreeElements; | 3287 return definingElement.hasNode && definingElement.hasTreeElements; |
3287 } | 3288 } |
3288 | 3289 |
3289 ResolvedAst get resolvedAst { | 3290 ResolvedAst get resolvedAst { |
3290 return new ParsedResolvedAst( | 3291 return new ParsedResolvedAst( |
3291 declaration, definingElement.node, definingElement.treeElements); | 3292 declaration, definingElement.node, definingElement.treeElements); |
3292 } | 3293 } |
3293 } | 3294 } |
OLD | NEW |