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 | 8 import '../common/resolution.dart' show |
9 Resolution, | 9 Resolution, |
10 Parsing; | 10 Parsing; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 abstract class ElementX extends Element with ElementCommon { | 51 abstract class ElementX extends Element with ElementCommon { |
52 static int elementHashCode = 0; | 52 static int elementHashCode = 0; |
53 | 53 |
54 final String name; | 54 final String name; |
55 final ElementKind kind; | 55 final ElementKind kind; |
56 final Element enclosingElement; | 56 final Element enclosingElement; |
57 final int hashCode = ++elementHashCode; | 57 final int hashCode = ++elementHashCode; |
58 List<MetadataAnnotation> metadataInternal; | 58 List<MetadataAnnotation> metadataInternal; |
59 | 59 |
60 ElementX(this.name, this.kind, this.enclosingElement) { | 60 ElementX(this.name, this.kind, this.enclosingElement) { |
61 assert(isErroneous || implementationLibrary != null); | 61 assert(isError || implementationLibrary != null); |
62 } | 62 } |
63 | 63 |
64 Modifiers get modifiers => Modifiers.EMPTY; | 64 Modifiers get modifiers => Modifiers.EMPTY; |
65 | 65 |
66 Node parseNode(Parsing parsing) { | 66 Node parseNode(Parsing parsing) { |
67 parsing.reporter.internalError(this, | 67 parsing.reporter.internalError(this, |
68 'parseNode not implemented on $this.'); | 68 'parseNode not implemented on $this.'); |
69 return null; | 69 return null; |
70 } | 70 } |
71 | 71 |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 ErroneousElementX(this.messageKind, this.messageArguments, | 316 ErroneousElementX(this.messageKind, this.messageArguments, |
317 String name, Element enclosing) | 317 String name, Element enclosing) |
318 : super(name, ElementKind.ERROR, enclosing); | 318 : super(name, ElementKind.ERROR, enclosing); |
319 | 319 |
320 bool get isTopLevel => false; | 320 bool get isTopLevel => false; |
321 | 321 |
322 bool get isSynthesized => true; | 322 bool get isSynthesized => true; |
323 | 323 |
324 bool get isCyclicRedirection => false; | 324 bool get isCyclicRedirection => false; |
325 | 325 |
| 326 bool get isMalformed => true; |
| 327 |
326 PrefixElement get redirectionDeferredPrefix => null; | 328 PrefixElement get redirectionDeferredPrefix => null; |
327 | 329 |
328 AbstractFieldElement abstractField; | 330 AbstractFieldElement abstractField; |
329 | 331 |
330 unsupported() { | 332 unsupported() { |
331 throw 'unsupported operation on erroneous element'; | 333 throw 'unsupported operation on erroneous element'; |
332 } | 334 } |
333 | 335 |
334 get asyncMarker => AsyncMarker.SYNC; | 336 get asyncMarker => AsyncMarker.SYNC; |
335 Iterable<MetadataAnnotation> get metadata => unsupported(); | 337 Iterable<MetadataAnnotation> get metadata => unsupported(); |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 | 631 |
630 /// Element synthesized to recover from a duplicated member of an element. | 632 /// Element synthesized to recover from a duplicated member of an element. |
631 class DuplicatedElementX extends AmbiguousElementX { | 633 class DuplicatedElementX extends AmbiguousElementX { |
632 DuplicatedElementX( | 634 DuplicatedElementX( |
633 MessageKind messageKind, | 635 MessageKind messageKind, |
634 Map messageArguments, | 636 Map messageArguments, |
635 Element enclosingElement, Element existingElement, Element newElement) | 637 Element enclosingElement, Element existingElement, Element newElement) |
636 : super(messageKind, messageArguments, enclosingElement, existingElement, | 638 : super(messageKind, messageArguments, enclosingElement, existingElement, |
637 newElement); | 639 newElement); |
638 | 640 |
639 bool get isErroneous => true; | 641 bool get isMalformed => true; |
640 } | 642 } |
641 | 643 |
642 class ScopeX { | 644 class ScopeX { |
643 final Map<String, Element> contents = new Map<String, Element>(); | 645 final Map<String, Element> contents = new Map<String, Element>(); |
644 | 646 |
645 bool get isEmpty => contents.isEmpty; | 647 bool get isEmpty => contents.isEmpty; |
646 Iterable<Element> get values => contents.values; | 648 Iterable<Element> get values => contents.values; |
647 | 649 |
648 Element lookup(String name) { | 650 Element lookup(String name) { |
649 return contents[name]; | 651 return contents[name]; |
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1700 set initializerCache(_) { | 1702 set initializerCache(_) { |
1701 throw new UnsupportedError("initializerCache="); | 1703 throw new UnsupportedError("initializerCache="); |
1702 } | 1704 } |
1703 | 1705 |
1704 void createDefinitions(VariableDefinitions definitions) { | 1706 void createDefinitions(VariableDefinitions definitions) { |
1705 throw new UnsupportedError("createDefinitions"); | 1707 throw new UnsupportedError("createDefinitions"); |
1706 } | 1708 } |
1707 | 1709 |
1708 get initializer => null; | 1710 get initializer => null; |
1709 | 1711 |
1710 bool get isErroneous => true; | 1712 bool get isMalformed => true; |
1711 | 1713 |
1712 get nestedClosures { | 1714 get nestedClosures { |
1713 throw new UnsupportedError("nestedClosures"); | 1715 throw new UnsupportedError("nestedClosures"); |
1714 } | 1716 } |
1715 | 1717 |
1716 set nestedClosures(_) { | 1718 set nestedClosures(_) { |
1717 throw new UnsupportedError("nestedClosures="); | 1719 throw new UnsupportedError("nestedClosures="); |
1718 } | 1720 } |
1719 | 1721 |
1720 // TODO(ahe): Should this throw or do nothing? | 1722 // TODO(ahe): Should this throw or do nothing? |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1906 super( | 1908 super( |
1907 ElementKind.INITIALIZING_FORMAL, | 1909 ElementKind.INITIALIZING_FORMAL, |
1908 enclosingElement, null, identifier, null); | 1910 enclosingElement, null, identifier, null); |
1909 | 1911 |
1910 VariableDefinitions get definitions => fieldElement.node; | 1912 VariableDefinitions get definitions => fieldElement.node; |
1911 | 1913 |
1912 MemberElement get memberContext => enclosingElement; | 1914 MemberElement get memberContext => enclosingElement; |
1913 | 1915 |
1914 bool get isLocal => false; | 1916 bool get isLocal => false; |
1915 | 1917 |
1916 bool get isErroneous => true; | 1918 bool get isMalformed => true; |
1917 | 1919 |
1918 DynamicType get type => const DynamicType(); | 1920 DynamicType get type => const DynamicType(); |
1919 } | 1921 } |
1920 | 1922 |
1921 class AbstractFieldElementX extends ElementX implements AbstractFieldElement { | 1923 class AbstractFieldElementX extends ElementX implements AbstractFieldElement { |
1922 GetterElementX getter; | 1924 GetterElementX getter; |
1923 SetterElementX setter; | 1925 SetterElementX setter; |
1924 | 1926 |
1925 AbstractFieldElementX(String name, Element enclosing) | 1927 AbstractFieldElementX(String name, Element enclosing) |
1926 : super(name, ElementKind.ABSTRACT_FIELD, enclosing); | 1928 : super(name, ElementKind.ABSTRACT_FIELD, enclosing); |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2273 /// This field is set by the post process queue when checking for cycles. | 2275 /// This field is set by the post process queue when checking for cycles. |
2274 ConstructorElement internalEffectiveTarget; | 2276 ConstructorElement internalEffectiveTarget; |
2275 DartType effectiveTargetType; | 2277 DartType effectiveTargetType; |
2276 | 2278 |
2277 void set effectiveTarget(ConstructorElement constructor) { | 2279 void set effectiveTarget(ConstructorElement constructor) { |
2278 assert(constructor != null && internalEffectiveTarget == null); | 2280 assert(constructor != null && internalEffectiveTarget == null); |
2279 internalEffectiveTarget = constructor; | 2281 internalEffectiveTarget = constructor; |
2280 } | 2282 } |
2281 | 2283 |
2282 ConstructorElement get effectiveTarget { | 2284 ConstructorElement get effectiveTarget { |
2283 if (Elements.isErroneous(immediateRedirectionTarget)) { | 2285 if (Elements.isMalformed(immediateRedirectionTarget)) { |
2284 return immediateRedirectionTarget; | 2286 return immediateRedirectionTarget; |
2285 } | 2287 } |
2286 assert(!isRedirectingFactory || internalEffectiveTarget != null); | 2288 assert(!isRedirectingFactory || internalEffectiveTarget != null); |
2287 if (isRedirectingFactory) return internalEffectiveTarget; | 2289 if (isRedirectingFactory) return internalEffectiveTarget; |
2288 if (isPatched) { | 2290 if (isPatched) { |
2289 return internalEffectiveTarget ?? this; | 2291 return internalEffectiveTarget ?? this; |
2290 } | 2292 } |
2291 return this; | 2293 return this; |
2292 } | 2294 } |
2293 | 2295 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2428 return super.type; | 2430 return super.type; |
2429 } else { | 2431 } else { |
2430 // TODO(johnniwinther): Ensure that the function type substitutes type | 2432 // TODO(johnniwinther): Ensure that the function type substitutes type |
2431 // variables correctly. | 2433 // variables correctly. |
2432 return definingConstructor.type; | 2434 return definingConstructor.type; |
2433 } | 2435 } |
2434 } | 2436 } |
2435 | 2437 |
2436 void _computeSignature(Resolution resolution) { | 2438 void _computeSignature(Resolution resolution) { |
2437 if (hasFunctionSignature) return; | 2439 if (hasFunctionSignature) return; |
2438 if (definingConstructor.isErroneous) { | 2440 if (definingConstructor.isMalformed) { |
2439 functionSignature = new FunctionSignatureX( | 2441 functionSignature = new FunctionSignatureX( |
2440 type: new FunctionType.synthesized(enclosingClass.thisType)); | 2442 type: new FunctionType.synthesized(enclosingClass.thisType)); |
2441 } | 2443 } |
2442 // TODO(johnniwinther): Ensure that the function signature (and with it the | 2444 // TODO(johnniwinther): Ensure that the function signature (and with it the |
2443 // function type) substitutes type variables correctly. | 2445 // function type) substitutes type variables correctly. |
2444 definingConstructor.computeType(resolution); | 2446 definingConstructor.computeType(resolution); |
2445 functionSignature = definingConstructor.functionSignature; | 2447 functionSignature = definingConstructor.functionSignature; |
2446 } | 2448 } |
2447 | 2449 |
2448 accept(ElementVisitor visitor, arg) { | 2450 accept(ElementVisitor visitor, arg) { |
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3183 AstElement get definingElement; | 3185 AstElement get definingElement; |
3184 | 3186 |
3185 bool get hasResolvedAst => definingElement.hasTreeElements; | 3187 bool get hasResolvedAst => definingElement.hasTreeElements; |
3186 | 3188 |
3187 ResolvedAst get resolvedAst { | 3189 ResolvedAst get resolvedAst { |
3188 return new ResolvedAst(declaration, | 3190 return new ResolvedAst(declaration, |
3189 definingElement.node, definingElement.treeElements); | 3191 definingElement.node, definingElement.treeElements); |
3190 } | 3192 } |
3191 | 3193 |
3192 } | 3194 } |
OLD | NEW |