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 '../tree/tree.dart'; | 8 import '../tree/tree.dart'; |
| 9 import '../util/util.dart'; | 9 import '../util/util.dart'; |
| 10 import '../resolution/resolution.dart'; | 10 import '../resolution/resolution.dart'; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 | 69 |
| 70 | 70 |
| 71 bool isFunction() => identical(kind, ElementKind.FUNCTION); | 71 bool isFunction() => identical(kind, ElementKind.FUNCTION); |
| 72 bool isConstructor() => isFactoryConstructor() || isGenerativeConstructor(); | 72 bool isConstructor() => isFactoryConstructor() || isGenerativeConstructor(); |
| 73 bool isClosure() => false; | 73 bool isClosure() => false; |
| 74 bool isMember() { | 74 bool isMember() { |
| 75 // Check that this element is defined in the scope of a Class. | 75 // Check that this element is defined in the scope of a Class. |
| 76 return enclosingElement != null && enclosingElement.isClass(); | 76 return enclosingElement != null && enclosingElement.isClass(); |
| 77 } | 77 } |
| 78 bool isInstanceMember() => false; | 78 bool isInstanceMember() => false; |
| 79 bool isDeferredLoaderFunction() => false; | |
| 79 | 80 |
| 80 bool isFactoryConstructor() => modifiers.isFactory(); | 81 bool isFactoryConstructor() => modifiers.isFactory(); |
| 81 bool isGenerativeConstructor() => | 82 bool isGenerativeConstructor() => |
| 82 identical(kind, ElementKind.GENERATIVE_CONSTRUCTOR); | 83 identical(kind, ElementKind.GENERATIVE_CONSTRUCTOR); |
| 83 bool isGenerativeConstructorBody() => | 84 bool isGenerativeConstructorBody() => |
| 84 identical(kind, ElementKind.GENERATIVE_CONSTRUCTOR_BODY); | 85 identical(kind, ElementKind.GENERATIVE_CONSTRUCTOR_BODY); |
| 85 bool isCompilationUnit() => identical(kind, ElementKind.COMPILATION_UNIT); | 86 bool isCompilationUnit() => identical(kind, ElementKind.COMPILATION_UNIT); |
| 86 bool isClass() => identical(kind, ElementKind.CLASS); | 87 bool isClass() => identical(kind, ElementKind.CLASS); |
| 87 bool isPrefix() => identical(kind, ElementKind.PREFIX); | 88 bool isPrefix() => identical(kind, ElementKind.PREFIX); |
| 88 bool isVariable() => identical(kind, ElementKind.VARIABLE); | 89 bool isVariable() => identical(kind, ElementKind.VARIABLE); |
| (...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1020 accept(ElementVisitor visitor) => visitor.visitLibraryElement(this); | 1021 accept(ElementVisitor visitor) => visitor.visitLibraryElement(this); |
| 1021 } | 1022 } |
| 1022 | 1023 |
| 1023 class PrefixElementX extends ElementX implements PrefixElement { | 1024 class PrefixElementX extends ElementX implements PrefixElement { |
| 1024 Token firstPosition; | 1025 Token firstPosition; |
| 1025 | 1026 |
| 1026 final ImportScope importScope = new ImportScope(); | 1027 final ImportScope importScope = new ImportScope(); |
| 1027 | 1028 |
| 1028 bool isDeferred = false; | 1029 bool isDeferred = false; |
| 1029 | 1030 |
| 1031 // Only needed for deferred imports. | |
| 1032 Import _import; | |
|
floitsch
2014/03/17 14:15:41
I don't really like this.
Every prefix comes from
Johnni Winther
2014/03/18 12:29:14
Or rename to `deferredImport` ?
sigurdm
2014/03/19 12:46:30
Done.
| |
| 1033 Import get import => _import; | |
| 1034 | |
| 1030 PrefixElementX(String prefix, Element enclosing, this.firstPosition) | 1035 PrefixElementX(String prefix, Element enclosing, this.firstPosition) |
| 1031 : super(prefix, ElementKind.PREFIX, enclosing); | 1036 : super(prefix, ElementKind.PREFIX, enclosing); |
| 1032 | 1037 |
| 1033 Element lookupLocalMember(String memberName) => importScope[memberName]; | 1038 Element lookupLocalMember(String memberName) => importScope[memberName]; |
| 1034 | 1039 |
| 1035 DartType computeType(Compiler compiler) => compiler.types.dynamicType; | 1040 DartType computeType(Compiler compiler) => compiler.types.dynamicType; |
| 1036 | 1041 |
| 1037 Token position() => firstPosition; | 1042 Token position() => firstPosition; |
| 1038 | 1043 |
| 1039 void addImport(Element element, Import import, DiagnosticListener listener) { | 1044 void addImport(Element element, Import import, DiagnosticListener listener) { |
| 1040 importScope.addImport(this, element, import, listener); | 1045 importScope.addImport(this, element, import, listener); |
| 1041 } | 1046 } |
| 1042 | 1047 |
| 1043 accept(ElementVisitor visitor) => visitor.visitPrefixElement(this); | 1048 accept(ElementVisitor visitor) => visitor.visitPrefixElement(this); |
| 1044 | 1049 |
| 1045 void markAsDeferred() { | 1050 void markAsDeferred(Import import) { |
| 1046 isDeferred = true; | 1051 isDeferred = true; |
| 1052 _import = import; | |
| 1047 } | 1053 } |
| 1048 } | 1054 } |
| 1049 | 1055 |
| 1050 class TypedefElementX extends ElementX | 1056 class TypedefElementX extends ElementX |
| 1051 with AnalyzableElement, TypeDeclarationElementX<TypedefType> | 1057 with AnalyzableElement, TypeDeclarationElementX<TypedefType> |
| 1052 implements TypedefElement { | 1058 implements TypedefElement { |
| 1053 Typedef cachedNode; | 1059 Typedef cachedNode; |
| 1054 | 1060 |
| 1055 /** | 1061 /** |
| 1056 * The type annotation which defines this typedef. | 1062 * The type annotation which defines this typedef. |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1648 | 1654 |
| 1649 bool get isAbstract { | 1655 bool get isAbstract { |
| 1650 return !modifiers.isExternal() && | 1656 return !modifiers.isExternal() && |
| 1651 (isFunction() || isAccessor()) && | 1657 (isFunction() || isAccessor()) && |
| 1652 _hasNoBody; | 1658 _hasNoBody; |
| 1653 } | 1659 } |
| 1654 | 1660 |
| 1655 accept(ElementVisitor visitor) => visitor.visitFunctionElement(this); | 1661 accept(ElementVisitor visitor) => visitor.visitFunctionElement(this); |
| 1656 } | 1662 } |
| 1657 | 1663 |
| 1664 class DeferredLoaderFunctionElementX extends FunctionElementX { | |
|
karlklose
2014/03/17 14:05:00
This element should have source code information.
sigurdm
2014/03/19 12:46:30
Done.
| |
| 1665 PrefixElement prefix; | |
| 1666 DeferredLoaderFunctionElementX(prefix) | |
|
karlklose
2014/03/17 14:05:00
`prefix` -> `this.prefix`.
sigurdm
2014/03/19 12:46:30
Not fixed - we still need to pass on the prefix to
| |
| 1667 : prefix = prefix, | |
| 1668 super("loadLibrary", | |
| 1669 ElementKind.FUNCTION, | |
| 1670 Modifiers.EMPTY, | |
| 1671 prefix, true); | |
| 1672 | |
| 1673 FunctionSignature computeSignature(Compiler compiler) { | |
| 1674 if (functionSignature != null) return functionSignature; | |
| 1675 compiler.withCurrentElement(this, () { | |
| 1676 functionSignature = new FunctionSignatureX(const Link(), | |
| 1677 const Link(), 0, 0, false, compiler.types.dynamicType); | |
| 1678 }); | |
| 1679 return functionSignature; | |
| 1680 } | |
| 1681 | |
| 1682 bool isMember() => false; | |
| 1683 | |
| 1684 bool get isSynthesized => true; | |
| 1685 | |
| 1686 bool isForeign(Compiler compiler) => true; | |
| 1687 | |
| 1688 bool isDeferredLoaderFunction() => true; | |
| 1689 } | |
| 1690 | |
| 1658 class ConstructorBodyElementX extends FunctionElementX | 1691 class ConstructorBodyElementX extends FunctionElementX |
| 1659 implements ConstructorBodyElement { | 1692 implements ConstructorBodyElement { |
| 1660 FunctionElement constructor; | 1693 FunctionElement constructor; |
| 1661 | 1694 |
| 1662 ConstructorBodyElementX(FunctionElement constructor) | 1695 ConstructorBodyElementX(FunctionElement constructor) |
| 1663 : this.constructor = constructor, | 1696 : this.constructor = constructor, |
| 1664 super(constructor.name, | 1697 super(constructor.name, |
| 1665 ElementKind.GENERATIVE_CONSTRUCTOR_BODY, | 1698 ElementKind.GENERATIVE_CONSTRUCTOR_BODY, |
| 1666 Modifiers.EMPTY, | 1699 Modifiers.EMPTY, |
| 1667 constructor.enclosingElement, false) { | 1700 constructor.enclosingElement, false) { |
| (...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2570 | 2603 |
| 2571 ParameterMetadataAnnotation(Metadata this.metadata); | 2604 ParameterMetadataAnnotation(Metadata this.metadata); |
| 2572 | 2605 |
| 2573 Node parseNode(DiagnosticListener listener) => metadata.expression; | 2606 Node parseNode(DiagnosticListener listener) => metadata.expression; |
| 2574 | 2607 |
| 2575 Token get beginToken => metadata.getBeginToken(); | 2608 Token get beginToken => metadata.getBeginToken(); |
| 2576 | 2609 |
| 2577 Token get endToken => metadata.getEndToken(); | 2610 Token get endToken => metadata.getEndToken(); |
| 2578 } | 2611 } |
| 2579 | 2612 |
| OLD | NEW |