| 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/resolution.dart' show |
| 8 Resolution, |
| 9 Parsing; |
| 7 import '../compiler.dart' show | 10 import '../compiler.dart' show |
| 8 Compiler; | 11 Compiler; |
| 9 import '../constants/constant_constructors.dart'; | 12 import '../constants/constant_constructors.dart'; |
| 10 import '../constants/constructors.dart'; | 13 import '../constants/constructors.dart'; |
| 11 import '../constants/expressions.dart'; | 14 import '../constants/expressions.dart'; |
| 12 import '../dart_types.dart'; | 15 import '../dart_types.dart'; |
| 13 import '../diagnostics/diagnostic_listener.dart'; | 16 import '../diagnostics/diagnostic_listener.dart'; |
| 14 import '../diagnostics/invariant.dart' show | 17 import '../diagnostics/invariant.dart' show |
| 15 invariant; | 18 invariant; |
| 16 import '../diagnostics/messages.dart'; | 19 import '../diagnostics/messages.dart'; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 final Element enclosingElement; | 63 final Element enclosingElement; |
| 61 final int hashCode = ++elementHashCode; | 64 final int hashCode = ++elementHashCode; |
| 62 List<MetadataAnnotation> metadataInternal; | 65 List<MetadataAnnotation> metadataInternal; |
| 63 | 66 |
| 64 ElementX(this.name, this.kind, this.enclosingElement) { | 67 ElementX(this.name, this.kind, this.enclosingElement) { |
| 65 assert(isErroneous || implementationLibrary != null); | 68 assert(isErroneous || implementationLibrary != null); |
| 66 } | 69 } |
| 67 | 70 |
| 68 Modifiers get modifiers => Modifiers.EMPTY; | 71 Modifiers get modifiers => Modifiers.EMPTY; |
| 69 | 72 |
| 70 Node parseNode(DiagnosticListener listener) { | 73 Node parseNode(Parsing parsing) { |
| 71 listener.internalError(this, | 74 parsing.listener.internalError(this, |
| 72 'parseNode not implemented on $this.'); | 75 'parseNode not implemented on $this.'); |
| 73 return null; | 76 return null; |
| 74 } | 77 } |
| 75 | 78 |
| 76 void set metadata(List<MetadataAnnotation> metadata) { | 79 void set metadata(List<MetadataAnnotation> metadata) { |
| 77 assert(metadataInternal == null); | 80 assert(metadataInternal == null); |
| 78 for (MetadataAnnotationX annotation in metadata) { | 81 for (MetadataAnnotationX annotation in metadata) { |
| 79 assert(annotation.annotatedElement == null); | 82 assert(annotation.annotatedElement == null); |
| 80 annotation.annotatedElement = this; | 83 annotation.annotatedElement = this; |
| 81 } | 84 } |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 get immediateRedirectionTarget => unsupported(); | 308 get immediateRedirectionTarget => unsupported(); |
| 306 get nestedClosures => unsupported(); | 309 get nestedClosures => unsupported(); |
| 307 get memberContext => unsupported(); | 310 get memberContext => unsupported(); |
| 308 get executableContext => unsupported(); | 311 get executableContext => unsupported(); |
| 309 get isExternal => unsupported(); | 312 get isExternal => unsupported(); |
| 310 get constantConstructor => null; | 313 get constantConstructor => null; |
| 311 | 314 |
| 312 bool get isRedirectingGenerative => unsupported(); | 315 bool get isRedirectingGenerative => unsupported(); |
| 313 bool get isRedirectingFactory => unsupported(); | 316 bool get isRedirectingFactory => unsupported(); |
| 314 | 317 |
| 315 computeSignature(compiler) => unsupported(); | 318 computeSignature(Resolution resolution) => unsupported(); |
| 316 computeType(compiler) => unsupported(); | 319 computeType(Resolution resolution) => unsupported(); |
| 317 | 320 |
| 318 bool get hasFunctionSignature => false; | 321 bool get hasFunctionSignature => false; |
| 319 | 322 |
| 320 get effectiveTarget => this; | 323 get effectiveTarget => this; |
| 321 | 324 |
| 322 computeEffectiveTargetType(InterfaceType newType) => unsupported(); | 325 computeEffectiveTargetType(InterfaceType newType) => unsupported(); |
| 323 | 326 |
| 324 get definingConstructor => null; | 327 get definingConstructor => null; |
| 325 | 328 |
| 326 FunctionElement asFunctionElement() => this; | 329 FunctionElement asFunctionElement() => this; |
| (...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1274 PrefixElementX(String prefix, | 1277 PrefixElementX(String prefix, |
| 1275 Element enclosing, | 1278 Element enclosing, |
| 1276 this.firstPosition, | 1279 this.firstPosition, |
| 1277 this.deferredImport) | 1280 this.deferredImport) |
| 1278 : super(prefix, ElementKind.PREFIX, enclosing); | 1281 : super(prefix, ElementKind.PREFIX, enclosing); |
| 1279 | 1282 |
| 1280 bool get isTopLevel => false; | 1283 bool get isTopLevel => false; |
| 1281 | 1284 |
| 1282 Element lookupLocalMember(String memberName) => importScope[memberName]; | 1285 Element lookupLocalMember(String memberName) => importScope[memberName]; |
| 1283 | 1286 |
| 1284 DartType computeType(Compiler compiler) => const DynamicType(); | 1287 DartType computeType(Resolution resolution) => const DynamicType(); |
| 1285 | 1288 |
| 1286 Token get position => firstPosition; | 1289 Token get position => firstPosition; |
| 1287 | 1290 |
| 1288 void addImport(Element element, | 1291 void addImport(Element element, |
| 1289 ImportElement import, | 1292 ImportElement import, |
| 1290 DiagnosticListener listener) { | 1293 DiagnosticListener listener) { |
| 1291 importScope.addImport(this, element, import, listener); | 1294 importScope.addImport(this, element, import, listener); |
| 1292 } | 1295 } |
| 1293 | 1296 |
| 1294 accept(ElementVisitor visitor, arg) { | 1297 accept(ElementVisitor visitor, arg) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1329 /** | 1332 /** |
| 1330 * Function signature for a typedef of a function type. The signature is | 1333 * Function signature for a typedef of a function type. The signature is |
| 1331 * kept to provide full information about parameter names through the mirror | 1334 * kept to provide full information about parameter names through the mirror |
| 1332 * system. | 1335 * system. |
| 1333 * | 1336 * |
| 1334 * The [functionSignature] is not available until the typedef element has been | 1337 * The [functionSignature] is not available until the typedef element has been |
| 1335 * resolved. | 1338 * resolved. |
| 1336 */ | 1339 */ |
| 1337 FunctionSignature functionSignature; | 1340 FunctionSignature functionSignature; |
| 1338 | 1341 |
| 1339 TypedefType computeType(Compiler compiler) { | 1342 TypedefType computeType(Resolution resolution) { |
| 1340 if (thisTypeCache != null) return thisTypeCache; | 1343 if (thisTypeCache != null) return thisTypeCache; |
| 1341 Typedef node = parseNode(compiler); | 1344 Typedef node = parseNode(resolution.parsing); |
| 1342 setThisAndRawTypes(compiler, createTypeVariables(node.typeParameters)); | 1345 setThisAndRawTypes(createTypeVariables(node.typeParameters)); |
| 1343 ensureResolved(compiler); | 1346 ensureResolved(resolution); |
| 1344 return thisTypeCache; | 1347 return thisTypeCache; |
| 1345 } | 1348 } |
| 1346 | 1349 |
| 1347 void ensureResolved(Compiler compiler) { | 1350 void ensureResolved(Resolution resolution) { |
| 1348 if (resolutionState == STATE_NOT_STARTED) { | 1351 if (resolutionState == STATE_NOT_STARTED) { |
| 1349 compiler.resolver.resolve(this); | 1352 resolution.resolveTypedef(this); |
| 1350 } | 1353 } |
| 1351 } | 1354 } |
| 1352 | 1355 |
| 1353 TypedefType createType(List<DartType> typeArguments) { | 1356 TypedefType createType(List<DartType> typeArguments) { |
| 1354 return new TypedefType(this, typeArguments); | 1357 return new TypedefType(this, typeArguments); |
| 1355 } | 1358 } |
| 1356 | 1359 |
| 1357 Scope buildScope() { | 1360 Scope buildScope() { |
| 1358 return new TypeDeclarationScope(enclosingElement.buildScope(), this); | 1361 return new TypeDeclarationScope(enclosingElement.buildScope(), this); |
| 1359 } | 1362 } |
| 1360 | 1363 |
| 1361 void checkCyclicReference(Compiler compiler) { | 1364 void checkCyclicReference(Resolution resolution) { |
| 1362 if (hasBeenCheckedForCycles) return; | 1365 if (hasBeenCheckedForCycles) return; |
| 1363 var visitor = new TypedefCyclicVisitor(compiler, this); | 1366 var visitor = new TypedefCyclicVisitor(resolution.listener, this); |
| 1364 computeType(compiler).accept(visitor, null); | 1367 computeType(resolution).accept(visitor, null); |
| 1365 hasBeenCheckedForCycles = true; | 1368 hasBeenCheckedForCycles = true; |
| 1366 } | 1369 } |
| 1367 | 1370 |
| 1368 accept(ElementVisitor visitor, arg) { | 1371 accept(ElementVisitor visitor, arg) { |
| 1369 return visitor.visitTypedefElement(this, arg); | 1372 return visitor.visitTypedefElement(this, arg); |
| 1370 } | 1373 } |
| 1371 | 1374 |
| 1372 // A typedef cannot be patched therefore defines itself. | 1375 // A typedef cannot be patched therefore defines itself. |
| 1373 AstElement get definingElement => this; | 1376 AstElement get definingElement => this; |
| 1374 } | 1377 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1402 // @foo @bar var a, b, c | 1405 // @foo @bar var a, b, c |
| 1403 // | 1406 // |
| 1404 // the metadata list is reported through the declaration of `a`, and `b` | 1407 // the metadata list is reported through the declaration of `a`, and `b` |
| 1405 // and `c` report an empty list of metadata. | 1408 // and `c` report an empty list of metadata. |
| 1406 return; | 1409 return; |
| 1407 } | 1410 } |
| 1408 assert(metadataInternal == null); | 1411 assert(metadataInternal == null); |
| 1409 metadataInternal = metadata; | 1412 metadataInternal = metadata; |
| 1410 } | 1413 } |
| 1411 | 1414 |
| 1412 VariableDefinitions parseNode(Element element, DiagnosticListener listener) { | 1415 VariableDefinitions parseNode(Element element, Parsing parsing) { |
| 1413 return definitions; | 1416 return definitions; |
| 1414 } | 1417 } |
| 1415 | 1418 |
| 1416 DartType computeType(Element element, Compiler compiler) => type; | 1419 DartType computeType(Element element, Resolution resolution) => type; |
| 1417 } | 1420 } |
| 1418 | 1421 |
| 1419 abstract class ConstantVariableMixin implements VariableElement { | 1422 abstract class ConstantVariableMixin implements VariableElement { |
| 1420 ConstantExpression constantCache; | 1423 ConstantExpression constantCache; |
| 1421 | 1424 |
| 1422 ConstantExpression get constant { | 1425 ConstantExpression get constant { |
| 1423 if (isPatch) { | 1426 if (isPatch) { |
| 1424 ConstantVariableMixin originVariable = origin; | 1427 ConstantVariableMixin originVariable = origin; |
| 1425 return originVariable.constant; | 1428 return originVariable.constant; |
| 1426 } | 1429 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1485 message: "Node has not been computed for $this.")); | 1488 message: "Node has not been computed for $this.")); |
| 1486 return definitionsCache; | 1489 return definitionsCache; |
| 1487 } | 1490 } |
| 1488 | 1491 |
| 1489 Expression get initializer { | 1492 Expression get initializer { |
| 1490 assert(invariant(this, definitionsCache != null, | 1493 assert(invariant(this, definitionsCache != null, |
| 1491 message: "Initializer has not been computed for $this.")); | 1494 message: "Initializer has not been computed for $this.")); |
| 1492 return initializerCache; | 1495 return initializerCache; |
| 1493 } | 1496 } |
| 1494 | 1497 |
| 1495 Node parseNode(DiagnosticListener listener) { | 1498 Node parseNode(Parsing parsing) { |
| 1496 if (definitionsCache != null) return definitionsCache; | 1499 if (definitionsCache != null) return definitionsCache; |
| 1497 | 1500 |
| 1498 VariableDefinitions definitions = variables.parseNode(this, listener); | 1501 VariableDefinitions definitions = variables.parseNode(this, parsing); |
| 1499 createDefinitions(definitions); | 1502 createDefinitions(definitions); |
| 1500 return definitionsCache; | 1503 return definitionsCache; |
| 1501 } | 1504 } |
| 1502 | 1505 |
| 1503 void createDefinitions(VariableDefinitions definitions) { | 1506 void createDefinitions(VariableDefinitions definitions) { |
| 1504 assert(invariant(this, definitionsCache == null, | 1507 assert(invariant(this, definitionsCache == null, |
| 1505 message: "VariableDefinitions has already been computed for $this.")); | 1508 message: "VariableDefinitions has already been computed for $this.")); |
| 1506 Expression node; | 1509 Expression node; |
| 1507 int count = 0; | 1510 int count = 0; |
| 1508 for (Link<Node> link = definitions.definitions.nodes; | 1511 for (Link<Node> link = definitions.definitions.nodes; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1528 // Create a [VariableDefinitions] node for the single definition of | 1531 // Create a [VariableDefinitions] node for the single definition of |
| 1529 // [node]. | 1532 // [node]. |
| 1530 definitionsCache = new VariableDefinitions(definitions.type, | 1533 definitionsCache = new VariableDefinitions(definitions.type, |
| 1531 definitions.modifiers, new NodeList( | 1534 definitions.modifiers, new NodeList( |
| 1532 definitions.definitions.beginToken, | 1535 definitions.definitions.beginToken, |
| 1533 const Link<Node>().prepend(node), | 1536 const Link<Node>().prepend(node), |
| 1534 definitions.definitions.endToken)); | 1537 definitions.definitions.endToken)); |
| 1535 } | 1538 } |
| 1536 } | 1539 } |
| 1537 | 1540 |
| 1538 DartType computeType(Compiler compiler) { | 1541 DartType computeType(Resolution resolution) { |
| 1539 if (variables.type != null) return variables.type; | 1542 if (variables.type != null) return variables.type; |
| 1540 // Call [parseNode] to ensure that [definitionsCache] and [initializerCache] | 1543 // Call [parseNode] to ensure that [definitionsCache] and [initializerCache] |
| 1541 // are set as a consequence of calling [computeType]. | 1544 // are set as a consequence of calling [computeType]. |
| 1542 return compiler.withCurrentElement(this, () { | 1545 parseNode(resolution.parsing); |
| 1543 parseNode(compiler); | 1546 return variables.computeType(this, resolution); |
| 1544 return variables.computeType(this, compiler); | |
| 1545 }); | |
| 1546 } | 1547 } |
| 1547 | 1548 |
| 1548 DartType get type { | 1549 DartType get type { |
| 1549 assert(invariant(this, variables.type != null, | 1550 assert(invariant(this, variables.type != null, |
| 1550 message: "Type has not been computed for $this.")); | 1551 message: "Type has not been computed for $this.")); |
| 1551 return variables.type; | 1552 return variables.type; |
| 1552 } | 1553 } |
| 1553 | 1554 |
| 1554 bool get isInstanceMember => isClassMember && !isStatic; | 1555 bool get isInstanceMember => isClassMember && !isStatic; |
| 1555 | 1556 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1676 AstElement get definingElement => this; | 1677 AstElement get definingElement => this; |
| 1677 | 1678 |
| 1678 void reuseElement() { | 1679 void reuseElement() { |
| 1679 throw new UnsupportedError("reuseElement"); | 1680 throw new UnsupportedError("reuseElement"); |
| 1680 } | 1681 } |
| 1681 | 1682 |
| 1682 FieldElementX copyWithEnclosing(Element enclosingElement) { | 1683 FieldElementX copyWithEnclosing(Element enclosingElement) { |
| 1683 throw new UnsupportedError("copyWithEnclosing"); | 1684 throw new UnsupportedError("copyWithEnclosing"); |
| 1684 } | 1685 } |
| 1685 | 1686 |
| 1686 DartType computeType(Compiler compiler) => type; | 1687 DartType computeType(Resolution resolution) => type; |
| 1687 } | 1688 } |
| 1688 | 1689 |
| 1689 /// [Element] for a parameter-like element. | 1690 /// [Element] for a parameter-like element. |
| 1690 class FormalElementX extends ElementX | 1691 class FormalElementX extends ElementX |
| 1691 with AstElementMixin | 1692 with AstElementMixin |
| 1692 implements FormalElement { | 1693 implements FormalElement { |
| 1693 final VariableDefinitions definitions; | 1694 final VariableDefinitions definitions; |
| 1694 final Identifier identifier; | 1695 final Identifier identifier; |
| 1695 DartType typeCache; | 1696 DartType typeCache; |
| 1696 | 1697 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1707 Identifier identifier) | 1708 Identifier identifier) |
| 1708 : this.identifier = identifier, | 1709 : this.identifier = identifier, |
| 1709 super(identifier.source, elementKind, enclosingElement); | 1710 super(identifier.source, elementKind, enclosingElement); |
| 1710 | 1711 |
| 1711 FunctionTypedElement get functionDeclaration => enclosingElement; | 1712 FunctionTypedElement get functionDeclaration => enclosingElement; |
| 1712 | 1713 |
| 1713 Modifiers get modifiers => definitions.modifiers; | 1714 Modifiers get modifiers => definitions.modifiers; |
| 1714 | 1715 |
| 1715 Token get position => identifier.getBeginToken(); | 1716 Token get position => identifier.getBeginToken(); |
| 1716 | 1717 |
| 1717 Node parseNode(DiagnosticListener listener) => definitions; | 1718 Node parseNode(Parsing parsing) => definitions; |
| 1718 | 1719 |
| 1719 DartType computeType(Compiler compiler) { | 1720 DartType computeType(Resolution resolution) { |
| 1720 assert(invariant(this, type != null, | 1721 assert(invariant(this, type != null, |
| 1721 message: "Parameter type has not been set for $this.")); | 1722 message: "Parameter type has not been set for $this.")); |
| 1722 return type; | 1723 return type; |
| 1723 } | 1724 } |
| 1724 | 1725 |
| 1725 DartType get type { | 1726 DartType get type { |
| 1726 assert(invariant(this, typeCache != null, | 1727 assert(invariant(this, typeCache != null, |
| 1727 message: "Parameter type has not been set for $this.")); | 1728 message: "Parameter type has not been set for $this.")); |
| 1728 return typeCache; | 1729 return typeCache; |
| 1729 } | 1730 } |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1862 GetterElementX getter; | 1863 GetterElementX getter; |
| 1863 SetterElementX setter; | 1864 SetterElementX setter; |
| 1864 | 1865 |
| 1865 AbstractFieldElementX(String name, Element enclosing) | 1866 AbstractFieldElementX(String name, Element enclosing) |
| 1866 : super(name, ElementKind.ABSTRACT_FIELD, enclosing); | 1867 : super(name, ElementKind.ABSTRACT_FIELD, enclosing); |
| 1867 | 1868 |
| 1868 DartType computeType(Compiler compiler) { | 1869 DartType computeType(Compiler compiler) { |
| 1869 throw "internal error: AbstractFieldElement has no type"; | 1870 throw "internal error: AbstractFieldElement has no type"; |
| 1870 } | 1871 } |
| 1871 | 1872 |
| 1872 Node parseNode(DiagnosticListener listener) { | 1873 Node parseNode(Parsing parsing) { |
| 1873 throw "internal error: AbstractFieldElement has no node"; | 1874 throw "internal error: AbstractFieldElement has no node"; |
| 1874 } | 1875 } |
| 1875 | 1876 |
| 1876 Token get position { | 1877 Token get position { |
| 1877 // The getter and setter may be defined in two different | 1878 // The getter and setter may be defined in two different |
| 1878 // compilation units. However, we know that one of them is | 1879 // compilation units. However, we know that one of them is |
| 1879 // non-null and defined in the same compilation unit as the | 1880 // non-null and defined in the same compilation unit as the |
| 1880 // abstract element. | 1881 // abstract element. |
| 1881 // TODO(lrn): No we don't know that if the element from the same | 1882 // TODO(lrn): No we don't know that if the element from the same |
| 1882 // compilation unit is patched. | 1883 // compilation unit is patched. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1966 bool get isExternal => modifiers.isExternal; | 1967 bool get isExternal => modifiers.isExternal; |
| 1967 | 1968 |
| 1968 bool get isInstanceMember { | 1969 bool get isInstanceMember { |
| 1969 return isClassMember | 1970 return isClassMember |
| 1970 && !isConstructor | 1971 && !isConstructor |
| 1971 && !isStatic; | 1972 && !isStatic; |
| 1972 } | 1973 } |
| 1973 | 1974 |
| 1974 bool get hasFunctionSignature => functionSignatureCache != null; | 1975 bool get hasFunctionSignature => functionSignatureCache != null; |
| 1975 | 1976 |
| 1976 FunctionSignature computeSignature(Compiler compiler) { | 1977 FunctionSignature computeSignature(Resolution resolution) { |
| 1977 if (functionSignatureCache != null) return functionSignatureCache; | 1978 if (functionSignatureCache != null) return functionSignatureCache; |
| 1978 compiler.withCurrentElement(this, () { | 1979 functionSignatureCache = resolution.resolveSignature(this); |
| 1979 functionSignatureCache = compiler.resolver.resolveSignature(this); | |
| 1980 }); | |
| 1981 return functionSignatureCache; | 1980 return functionSignatureCache; |
| 1982 } | 1981 } |
| 1983 | 1982 |
| 1984 FunctionSignature get functionSignature { | 1983 FunctionSignature get functionSignature { |
| 1985 assert(invariant(this, functionSignatureCache != null, | 1984 assert(invariant(this, functionSignatureCache != null, |
| 1986 message: "Function signature has not been computed for $this.")); | 1985 message: "Function signature has not been computed for $this.")); |
| 1987 return functionSignatureCache; | 1986 return functionSignatureCache; |
| 1988 } | 1987 } |
| 1989 | 1988 |
| 1990 List<ParameterElement> get parameters { | 1989 List<ParameterElement> get parameters { |
| 1991 // TODO(johnniwinther): Store the list directly, possibly by using List | 1990 // TODO(johnniwinther): Store the list directly, possibly by using List |
| 1992 // instead of Link in FunctionSignature. | 1991 // instead of Link in FunctionSignature. |
| 1993 List<ParameterElement> list = <ParameterElement>[]; | 1992 List<ParameterElement> list = <ParameterElement>[]; |
| 1994 functionSignature.forEachParameter((e) => list.add(e)); | 1993 functionSignature.forEachParameter((e) => list.add(e)); |
| 1995 return list; | 1994 return list; |
| 1996 } | 1995 } |
| 1997 | 1996 |
| 1998 FunctionType computeType(Compiler compiler) { | 1997 FunctionType computeType(Resolution resolution) { |
| 1999 if (typeCache != null) return typeCache; | 1998 if (typeCache != null) return typeCache; |
| 2000 typeCache = computeSignature(compiler).type; | 1999 typeCache = computeSignature(resolution).type; |
| 2001 return typeCache; | 2000 return typeCache; |
| 2002 } | 2001 } |
| 2003 | 2002 |
| 2004 FunctionType get type { | 2003 FunctionType get type { |
| 2005 assert(invariant(this, typeCache != null, | 2004 assert(invariant(this, typeCache != null, |
| 2006 message: "Type has not been computed for $this.")); | 2005 message: "Type has not been computed for $this.")); |
| 2007 return typeCache; | 2006 return typeCache; |
| 2008 } | 2007 } |
| 2009 | 2008 |
| 2010 FunctionElement asFunctionElement() => this; | 2009 FunctionElement asFunctionElement() => this; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2107 Modifiers modifiers, | 2106 Modifiers modifiers, |
| 2108 ExecutableElement enclosing) | 2107 ExecutableElement enclosing) |
| 2109 : super(name, kind, modifiers, enclosing); | 2108 : super(name, kind, modifiers, enclosing); |
| 2110 | 2109 |
| 2111 ExecutableElement get executableContext => enclosingElement; | 2110 ExecutableElement get executableContext => enclosingElement; |
| 2112 | 2111 |
| 2113 MemberElement get memberContext => executableContext.memberContext; | 2112 MemberElement get memberContext => executableContext.memberContext; |
| 2114 | 2113 |
| 2115 bool get hasNode => true; | 2114 bool get hasNode => true; |
| 2116 | 2115 |
| 2117 FunctionExpression parseNode(DiagnosticListener listener) => node; | 2116 FunctionExpression parseNode(Parsing parsing) => node; |
| 2118 | 2117 |
| 2119 Token get position { | 2118 Token get position { |
| 2120 // Use the name as position if this is not an unnamed closure. | 2119 // Use the name as position if this is not an unnamed closure. |
| 2121 if (node.name != null) { | 2120 if (node.name != null) { |
| 2122 return node.name.getBeginToken(); | 2121 return node.name.getBeginToken(); |
| 2123 } else { | 2122 } else { |
| 2124 return node.getBeginToken(); | 2123 return node.getBeginToken(); |
| 2125 } | 2124 } |
| 2126 } | 2125 } |
| 2127 | 2126 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2228 implements GetterElement { | 2227 implements GetterElement { |
| 2229 final PrefixElement prefix; | 2228 final PrefixElement prefix; |
| 2230 | 2229 |
| 2231 DeferredLoaderGetterElementX(PrefixElement prefix) | 2230 DeferredLoaderGetterElementX(PrefixElement prefix) |
| 2232 : this.prefix = prefix, | 2231 : this.prefix = prefix, |
| 2233 super("loadLibrary", | 2232 super("loadLibrary", |
| 2234 Modifiers.EMPTY, | 2233 Modifiers.EMPTY, |
| 2235 prefix, | 2234 prefix, |
| 2236 false); | 2235 false); |
| 2237 | 2236 |
| 2238 FunctionSignature computeSignature(Compiler compiler) { | 2237 FunctionSignature computeSignature(Resolution resolution) { |
| 2239 if (functionSignatureCache != null) return functionSignature; | 2238 if (functionSignatureCache != null) return functionSignature; |
| 2240 compiler.withCurrentElement(this, () { | 2239 functionSignatureCache = |
| 2241 DartType inner = new FunctionType(this); | 2240 new FunctionSignatureX(type: new FunctionType(this)); |
| 2242 functionSignatureCache = new FunctionSignatureX(type: inner); | |
| 2243 }); | |
| 2244 return functionSignatureCache; | 2241 return functionSignatureCache; |
| 2245 } | 2242 } |
| 2246 | 2243 |
| 2247 bool get isClassMember => false; | 2244 bool get isClassMember => false; |
| 2248 | 2245 |
| 2249 bool get isSynthesized => true; | 2246 bool get isSynthesized => true; |
| 2250 | 2247 |
| 2251 bool get isDeferredLoaderGetter => true; | 2248 bool get isDeferredLoaderGetter => true; |
| 2252 | 2249 |
| 2253 bool get isTopLevel => true; | 2250 bool get isTopLevel => true; |
| 2254 // By having position null, the enclosing elements location is printed in | 2251 // By having position null, the enclosing elements location is printed in |
| 2255 // error messages. | 2252 // error messages. |
| 2256 Token get position => null; | 2253 Token get position => null; |
| 2257 | 2254 |
| 2258 FunctionExpression parseNode(DiagnosticListener listener) => null; | 2255 FunctionExpression parseNode(Parsing parsing) => null; |
| 2259 | 2256 |
| 2260 bool get hasNode => false; | 2257 bool get hasNode => false; |
| 2261 | 2258 |
| 2262 FunctionExpression get node => null; | 2259 FunctionExpression get node => null; |
| 2263 | 2260 |
| 2264 @override | 2261 @override |
| 2265 SetterElement get setter => null; | 2262 SetterElement get setter => null; |
| 2266 } | 2263 } |
| 2267 | 2264 |
| 2268 class ConstructorBodyElementX extends BaseFunctionElementX | 2265 class ConstructorBodyElementX extends BaseFunctionElementX |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2279 } | 2276 } |
| 2280 | 2277 |
| 2281 bool get hasNode => constructor.hasNode; | 2278 bool get hasNode => constructor.hasNode; |
| 2282 | 2279 |
| 2283 FunctionExpression get node => constructor.node; | 2280 FunctionExpression get node => constructor.node; |
| 2284 | 2281 |
| 2285 List<MetadataAnnotation> get metadata => constructor.metadata; | 2282 List<MetadataAnnotation> get metadata => constructor.metadata; |
| 2286 | 2283 |
| 2287 bool get isInstanceMember => true; | 2284 bool get isInstanceMember => true; |
| 2288 | 2285 |
| 2289 FunctionType computeType(Compiler compiler) { | 2286 FunctionType computeType(Resolution resolution) { |
| 2290 compiler.internalError(this, '$this.computeType.'); | 2287 resolution.listener.internalError(this, '$this.computeType.'); |
| 2291 return null; | 2288 return null; |
| 2292 } | 2289 } |
| 2293 | 2290 |
| 2294 Token get position => constructor.position; | 2291 Token get position => constructor.position; |
| 2295 | 2292 |
| 2296 Element get outermostEnclosingMemberOrTopLevel => constructor; | 2293 Element get outermostEnclosingMemberOrTopLevel => constructor; |
| 2297 | 2294 |
| 2298 Element get analyzableElement => constructor.analyzableElement; | 2295 Element get analyzableElement => constructor.analyzableElement; |
| 2299 | 2296 |
| 2300 accept(ElementVisitor visitor, arg) { | 2297 accept(ElementVisitor visitor, arg) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2328 Element enclosing) | 2325 Element enclosing) |
| 2329 : isDefaultConstructor = true, | 2326 : isDefaultConstructor = true, |
| 2330 super('', | 2327 super('', |
| 2331 ElementKind.GENERATIVE_CONSTRUCTOR, | 2328 ElementKind.GENERATIVE_CONSTRUCTOR, |
| 2332 Modifiers.EMPTY, | 2329 Modifiers.EMPTY, |
| 2333 enclosing) { | 2330 enclosing) { |
| 2334 typeCache = new FunctionType.synthesized(enclosingClass.thisType); | 2331 typeCache = new FunctionType.synthesized(enclosingClass.thisType); |
| 2335 functionSignatureCache = new FunctionSignatureX(type: type); | 2332 functionSignatureCache = new FunctionSignatureX(type: type); |
| 2336 } | 2333 } |
| 2337 | 2334 |
| 2338 FunctionExpression parseNode(DiagnosticListener listener) => null; | 2335 FunctionExpression parseNode(Parsing parsing) => null; |
| 2339 | 2336 |
| 2340 bool get hasNode => false; | 2337 bool get hasNode => false; |
| 2341 | 2338 |
| 2342 FunctionExpression get node => null; | 2339 FunctionExpression get node => null; |
| 2343 | 2340 |
| 2344 Token get position => enclosingElement.position; | 2341 Token get position => enclosingElement.position; |
| 2345 | 2342 |
| 2346 bool get isSynthesized => true; | 2343 bool get isSynthesized => true; |
| 2347 | 2344 |
| 2348 DartType get type { | 2345 DartType get type { |
| 2349 if (isDefaultConstructor) { | 2346 if (isDefaultConstructor) { |
| 2350 return super.type; | 2347 return super.type; |
| 2351 } else { | 2348 } else { |
| 2352 // TODO(johnniwinther): Ensure that the function type substitutes type | 2349 // TODO(johnniwinther): Ensure that the function type substitutes type |
| 2353 // variables correctly. | 2350 // variables correctly. |
| 2354 return definingConstructor.type; | 2351 return definingConstructor.type; |
| 2355 } | 2352 } |
| 2356 } | 2353 } |
| 2357 | 2354 |
| 2358 FunctionSignature computeSignature(compiler) { | 2355 FunctionSignature computeSignature(Resolution resolution) { |
| 2359 if (functionSignatureCache != null) return functionSignatureCache; | 2356 if (functionSignatureCache != null) return functionSignatureCache; |
| 2360 if (definingConstructor.isErroneous) { | 2357 if (definingConstructor.isErroneous) { |
| 2361 return functionSignatureCache = | 2358 typeCache = new FunctionType.synthesized(enclosingClass.thisType); |
| 2362 compiler.objectClass.localLookup('').computeSignature(compiler); | 2359 return functionSignatureCache = new FunctionSignatureX(type: type); |
| 2363 } | 2360 } |
| 2364 // TODO(johnniwinther): Ensure that the function signature (and with it the | 2361 // TODO(johnniwinther): Ensure that the function signature (and with it the |
| 2365 // function type) substitutes type variables correctly. | 2362 // function type) substitutes type variables correctly. |
| 2366 definingConstructor.computeType(compiler); | 2363 definingConstructor.computeType(resolution); |
| 2367 functionSignatureCache = definingConstructor.functionSignature; | 2364 functionSignatureCache = definingConstructor.functionSignature; |
| 2368 typeCache = definingConstructor.type; | 2365 typeCache = definingConstructor.type; |
| 2369 return functionSignatureCache; | 2366 return functionSignatureCache; |
| 2370 } | 2367 } |
| 2371 | 2368 |
| 2372 accept(ElementVisitor visitor, arg) { | 2369 accept(ElementVisitor visitor, arg) { |
| 2373 return visitor.visitConstructorElement(this, arg); | 2370 return visitor.visitConstructorElement(this, arg); |
| 2374 } | 2371 } |
| 2375 } | 2372 } |
| 2376 | 2373 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2416 } | 2413 } |
| 2417 | 2414 |
| 2418 T get rawType { | 2415 T get rawType { |
| 2419 assert(invariant(this, rawTypeCache != null, | 2416 assert(invariant(this, rawTypeCache != null, |
| 2420 message: 'Raw type has not been computed for $this')); | 2417 message: 'Raw type has not been computed for $this')); |
| 2421 return rawTypeCache; | 2418 return rawTypeCache; |
| 2422 } | 2419 } |
| 2423 | 2420 |
| 2424 T createType(List<DartType> typeArguments); | 2421 T createType(List<DartType> typeArguments); |
| 2425 | 2422 |
| 2426 void setThisAndRawTypes(Compiler compiler, List<DartType> typeParameters) { | 2423 void setThisAndRawTypes(List<DartType> typeParameters) { |
| 2427 assert(invariant(this, thisTypeCache == null, | 2424 assert(invariant(this, thisTypeCache == null, |
| 2428 message: "This type has already been set on $this.")); | 2425 message: "This type has already been set on $this.")); |
| 2429 assert(invariant(this, rawTypeCache == null, | 2426 assert(invariant(this, rawTypeCache == null, |
| 2430 message: "Raw type has already been set on $this.")); | 2427 message: "Raw type has already been set on $this.")); |
| 2431 thisTypeCache = createType(typeParameters); | 2428 thisTypeCache = createType(typeParameters); |
| 2432 if (typeParameters.isEmpty) { | 2429 if (typeParameters.isEmpty) { |
| 2433 rawTypeCache = thisTypeCache; | 2430 rawTypeCache = thisTypeCache; |
| 2434 } else { | 2431 } else { |
| 2435 List<DartType> dynamicParameters = | 2432 List<DartType> dynamicParameters = |
| 2436 new List.filled(typeParameters.length, const DynamicType()); | 2433 new List.filled(typeParameters.length, const DynamicType()); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2503 | 2500 |
| 2504 int get hashCode => id; | 2501 int get hashCode => id; |
| 2505 | 2502 |
| 2506 bool get hasBackendMembers => !backendMembers.isEmpty; | 2503 bool get hasBackendMembers => !backendMembers.isEmpty; |
| 2507 | 2504 |
| 2508 bool get isUnnamedMixinApplication => false; | 2505 bool get isUnnamedMixinApplication => false; |
| 2509 | 2506 |
| 2510 @override | 2507 @override |
| 2511 bool get isEnumClass => false; | 2508 bool get isEnumClass => false; |
| 2512 | 2509 |
| 2513 InterfaceType computeType(Compiler compiler) { | 2510 InterfaceType computeType(Resolution resolution) { |
| 2514 if (isPatch) { | 2511 if (isPatch) { |
| 2515 origin.computeType(compiler); | 2512 origin.computeType(resolution); |
| 2516 thisTypeCache = origin.thisType; | 2513 thisTypeCache = origin.thisType; |
| 2517 rawTypeCache = origin.rawType; | 2514 rawTypeCache = origin.rawType; |
| 2518 } else if (thisTypeCache == null) { | 2515 } else if (thisTypeCache == null) { |
| 2519 computeThisAndRawType(compiler, computeTypeParameters(compiler)); | 2516 computeThisAndRawType( |
| 2517 resolution, computeTypeParameters(resolution.parsing)); |
| 2520 } | 2518 } |
| 2521 return thisTypeCache; | 2519 return thisTypeCache; |
| 2522 } | 2520 } |
| 2523 | 2521 |
| 2524 void computeThisAndRawType(Compiler compiler, List<DartType> typeVariables) { | 2522 void computeThisAndRawType(Resolution resolution, |
| 2523 List<DartType> typeVariables) { |
| 2525 if (thisTypeCache == null) { | 2524 if (thisTypeCache == null) { |
| 2526 if (origin == null) { | 2525 if (origin == null) { |
| 2527 setThisAndRawTypes(compiler, typeVariables); | 2526 setThisAndRawTypes(typeVariables); |
| 2528 } else { | 2527 } else { |
| 2529 thisTypeCache = origin.computeType(compiler); | 2528 thisTypeCache = origin.computeType(resolution); |
| 2530 rawTypeCache = origin.rawType; | 2529 rawTypeCache = origin.rawType; |
| 2531 } | 2530 } |
| 2532 } | 2531 } |
| 2533 } | 2532 } |
| 2534 | 2533 |
| 2535 @override | 2534 @override |
| 2536 InterfaceType createType(List<DartType> typeArguments) { | 2535 InterfaceType createType(List<DartType> typeArguments) { |
| 2537 return new InterfaceType(this, typeArguments); | 2536 return new InterfaceType(this, typeArguments); |
| 2538 } | 2537 } |
| 2539 | 2538 |
| 2540 List<DartType> computeTypeParameters(Compiler compiler); | 2539 List<DartType> computeTypeParameters(Parsing parsing); |
| 2541 | 2540 |
| 2542 bool get isObject { | 2541 bool get isObject { |
| 2543 assert(invariant(this, isResolved, | 2542 assert(invariant(this, isResolved, |
| 2544 message: "isObject has not been computed for $this.")); | 2543 message: "isObject has not been computed for $this.")); |
| 2545 return supertype == null; | 2544 return supertype == null; |
| 2546 } | 2545 } |
| 2547 | 2546 |
| 2548 void ensureResolved(Compiler compiler) { | 2547 void ensureResolved(Resolution resolution) { |
| 2549 if (resolutionState == STATE_NOT_STARTED) { | 2548 if (resolutionState == STATE_NOT_STARTED) { |
| 2550 compiler.resolver.resolveClass(this); | 2549 resolution.resolveClass(this); |
| 2551 compiler.world.registerClass(this); | 2550 resolution.registerClass(this); |
| 2552 } | 2551 } |
| 2553 } | 2552 } |
| 2554 | 2553 |
| 2555 void setDefaultConstructor(FunctionElement constructor, Compiler compiler); | 2554 void setDefaultConstructor(FunctionElement constructor, |
| 2555 DiagnosticListener listener); |
| 2556 | 2556 |
| 2557 void addBackendMember(Element member) { | 2557 void addBackendMember(Element member) { |
| 2558 // TODO(ngeoffray): Deprecate this method. | 2558 // TODO(ngeoffray): Deprecate this method. |
| 2559 assert(member.isGenerativeConstructorBody); | 2559 assert(member.isGenerativeConstructorBody); |
| 2560 backendMembers = backendMembers.prepend(member); | 2560 backendMembers = backendMembers.prepend(member); |
| 2561 } | 2561 } |
| 2562 | 2562 |
| 2563 void reverseBackendMembers() { | 2563 void reverseBackendMembers() { |
| 2564 backendMembers = backendMembers.reverse(); | 2564 backendMembers = backendMembers.reverse(); |
| 2565 } | 2565 } |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2672 } | 2672 } |
| 2673 | 2673 |
| 2674 bool get hasConstructor { | 2674 bool get hasConstructor { |
| 2675 // Search in scope to be sure we search patched constructors. | 2675 // Search in scope to be sure we search patched constructors. |
| 2676 for (var element in localScope.values) { | 2676 for (var element in localScope.values) { |
| 2677 if (element.isConstructor) return true; | 2677 if (element.isConstructor) return true; |
| 2678 } | 2678 } |
| 2679 return false; | 2679 return false; |
| 2680 } | 2680 } |
| 2681 | 2681 |
| 2682 void setDefaultConstructor(FunctionElement constructor, Compiler compiler) { | 2682 void setDefaultConstructor(FunctionElement constructor, |
| 2683 DiagnosticListener listener) { |
| 2683 // The default constructor, although synthetic, is part of a class' API. | 2684 // The default constructor, although synthetic, is part of a class' API. |
| 2684 addMember(constructor, compiler); | 2685 addMember(constructor, listener); |
| 2685 } | 2686 } |
| 2686 | 2687 |
| 2687 List<DartType> computeTypeParameters(Compiler compiler) { | 2688 List<DartType> computeTypeParameters(Parsing parsing) { |
| 2688 ClassNode node = parseNode(compiler); | 2689 ClassNode node = parseNode(parsing); |
| 2689 return createTypeVariables(node.typeParameters); | 2690 return createTypeVariables(node.typeParameters); |
| 2690 } | 2691 } |
| 2691 | 2692 |
| 2692 Scope buildScope() => new ClassScope(enclosingElement.buildScope(), this); | 2693 Scope buildScope() => new ClassScope(enclosingElement.buildScope(), this); |
| 2693 | 2694 |
| 2694 String toString() { | 2695 String toString() { |
| 2695 if (origin != null) { | 2696 if (origin != null) { |
| 2696 return 'patch ${super.toString()}'; | 2697 return 'patch ${super.toString()}'; |
| 2697 } else if (patch != null) { | 2698 } else if (patch != null) { |
| 2698 return 'origin ${super.toString()}'; | 2699 return 'origin ${super.toString()}'; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2712 @override | 2713 @override |
| 2713 bool get hasNode => true; | 2714 bool get hasNode => true; |
| 2714 | 2715 |
| 2715 @override | 2716 @override |
| 2716 Token get position => node.name.token; | 2717 Token get position => node.name.token; |
| 2717 | 2718 |
| 2718 @override | 2719 @override |
| 2719 bool get isEnumClass => true; | 2720 bool get isEnumClass => true; |
| 2720 | 2721 |
| 2721 @override | 2722 @override |
| 2722 Node parseNode(Compiler compiler) => node; | 2723 Node parseNode(Parsing parsing) => node; |
| 2723 | 2724 |
| 2724 @override | 2725 @override |
| 2725 accept(ElementVisitor visitor, arg) { | 2726 accept(ElementVisitor visitor, arg) { |
| 2726 return visitor.visitEnumClassElement(this, arg); | 2727 return visitor.visitEnumClassElement(this, arg); |
| 2727 } | 2728 } |
| 2728 | 2729 |
| 2729 List<DartType> computeTypeParameters(Compiler compiler) => const <DartType>[]; | 2730 List<DartType> computeTypeParameters(Parsing parsing) => const <DartType>[]; |
| 2730 | 2731 |
| 2731 List<FieldElement> get enumValues { | 2732 List<FieldElement> get enumValues { |
| 2732 assert(invariant(this, _enumValues != null, | 2733 assert(invariant(this, _enumValues != null, |
| 2733 message: "enumValues has not been computed for $this.")); | 2734 message: "enumValues has not been computed for $this.")); |
| 2734 return _enumValues; | 2735 return _enumValues; |
| 2735 } | 2736 } |
| 2736 | 2737 |
| 2737 void set enumValues(List<FieldElement> values) { | 2738 void set enumValues(List<FieldElement> values) { |
| 2738 assert(invariant(this, _enumValues == null, | 2739 assert(invariant(this, _enumValues == null, |
| 2739 message: "enumValues has already been computed for $this.")); | 2740 message: "enumValues has already been computed for $this.")); |
| 2740 _enumValues = values; | 2741 _enumValues = values; |
| 2741 } | 2742 } |
| 2742 } | 2743 } |
| 2743 | 2744 |
| 2744 class EnumConstructorElementX extends ConstructorElementX { | 2745 class EnumConstructorElementX extends ConstructorElementX { |
| 2745 final FunctionExpression node; | 2746 final FunctionExpression node; |
| 2746 | 2747 |
| 2747 EnumConstructorElementX(EnumClassElementX enumClass, | 2748 EnumConstructorElementX(EnumClassElementX enumClass, |
| 2748 Modifiers modifiers, | 2749 Modifiers modifiers, |
| 2749 this.node) | 2750 this.node) |
| 2750 : super('', // Name. | 2751 : super('', // Name. |
| 2751 ElementKind.GENERATIVE_CONSTRUCTOR, | 2752 ElementKind.GENERATIVE_CONSTRUCTOR, |
| 2752 modifiers, | 2753 modifiers, |
| 2753 enumClass); | 2754 enumClass); |
| 2754 | 2755 |
| 2755 @override | 2756 @override |
| 2756 bool get hasNode => true; | 2757 bool get hasNode => true; |
| 2757 | 2758 |
| 2758 @override | 2759 @override |
| 2759 FunctionExpression parseNode(Compiler compiler) => node; | 2760 FunctionExpression parseNode(Parsing parsing) => node; |
| 2760 } | 2761 } |
| 2761 | 2762 |
| 2762 class EnumMethodElementX extends MethodElementX { | 2763 class EnumMethodElementX extends MethodElementX { |
| 2763 final FunctionExpression node; | 2764 final FunctionExpression node; |
| 2764 | 2765 |
| 2765 EnumMethodElementX(String name, | 2766 EnumMethodElementX(String name, |
| 2766 EnumClassElementX enumClass, | 2767 EnumClassElementX enumClass, |
| 2767 Modifiers modifiers, | 2768 Modifiers modifiers, |
| 2768 this.node) | 2769 this.node) |
| 2769 : super(name, ElementKind.FUNCTION, modifiers, enumClass, true); | 2770 : super(name, ElementKind.FUNCTION, modifiers, enumClass, true); |
| 2770 | 2771 |
| 2771 @override | 2772 @override |
| 2772 bool get hasNode => true; | 2773 bool get hasNode => true; |
| 2773 | 2774 |
| 2774 @override | 2775 @override |
| 2775 FunctionExpression parseNode(Compiler compiler) => node; | 2776 FunctionExpression parseNode(Parsing parsing) => node; |
| 2776 } | 2777 } |
| 2777 | 2778 |
| 2778 class EnumFormalElementX extends InitializingFormalElementX { | 2779 class EnumFormalElementX extends InitializingFormalElementX { |
| 2779 EnumFormalElementX(ConstructorElement constructor, | 2780 EnumFormalElementX(ConstructorElement constructor, |
| 2780 VariableDefinitions variables, | 2781 VariableDefinitions variables, |
| 2781 Identifier identifier, | 2782 Identifier identifier, |
| 2782 EnumFieldElementX fieldElement) | 2783 EnumFieldElementX fieldElement) |
| 2783 : super(constructor, variables, identifier, null, fieldElement) { | 2784 : super(constructor, variables, identifier, null, fieldElement) { |
| 2784 typeCache = fieldElement.type; | 2785 typeCache = fieldElement.type; |
| 2785 } | 2786 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2819 bool get hasConstructor => !constructors.isEmpty; | 2820 bool get hasConstructor => !constructors.isEmpty; |
| 2820 bool get hasLocalScopeMembers => !constructors.isEmpty; | 2821 bool get hasLocalScopeMembers => !constructors.isEmpty; |
| 2821 | 2822 |
| 2822 get patch => null; | 2823 get patch => null; |
| 2823 get origin => null; | 2824 get origin => null; |
| 2824 | 2825 |
| 2825 bool get hasNode => true; | 2826 bool get hasNode => true; |
| 2826 | 2827 |
| 2827 Token get position => node.getBeginToken(); | 2828 Token get position => node.getBeginToken(); |
| 2828 | 2829 |
| 2829 Node parseNode(DiagnosticListener listener) => node; | 2830 Node parseNode(Parsing parsing) => node; |
| 2830 | 2831 |
| 2831 FunctionElement lookupLocalConstructor(String name) { | 2832 FunctionElement lookupLocalConstructor(String name) { |
| 2832 for (Link<Element> link = constructors; | 2833 for (Link<Element> link = constructors; |
| 2833 !link.isEmpty; | 2834 !link.isEmpty; |
| 2834 link = link.tail) { | 2835 link = link.tail) { |
| 2835 if (link.head.name == name) return link.head; | 2836 if (link.head.name == name) return link.head; |
| 2836 } | 2837 } |
| 2837 return null; | 2838 return null; |
| 2838 } | 2839 } |
| 2839 | 2840 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2858 } | 2859 } |
| 2859 | 2860 |
| 2860 void addToScope(Element element, DiagnosticListener listener) { | 2861 void addToScope(Element element, DiagnosticListener listener) { |
| 2861 listener.internalError(this, 'Cannot add to scope of $this.'); | 2862 listener.internalError(this, 'Cannot add to scope of $this.'); |
| 2862 } | 2863 } |
| 2863 | 2864 |
| 2864 void addConstructor(FunctionElement constructor) { | 2865 void addConstructor(FunctionElement constructor) { |
| 2865 constructors = constructors.prepend(constructor); | 2866 constructors = constructors.prepend(constructor); |
| 2866 } | 2867 } |
| 2867 | 2868 |
| 2868 void setDefaultConstructor(FunctionElement constructor, Compiler compiler) { | 2869 void setDefaultConstructor(FunctionElement constructor, |
| 2870 DiagnosticListener listener) { |
| 2869 assert(!hasConstructor); | 2871 assert(!hasConstructor); |
| 2870 addConstructor(constructor); | 2872 addConstructor(constructor); |
| 2871 } | 2873 } |
| 2872 | 2874 |
| 2873 List<DartType> computeTypeParameters(Compiler compiler) { | 2875 List<DartType> computeTypeParameters(Parsing parsing) { |
| 2874 NamedMixinApplication named = node.asNamedMixinApplication(); | 2876 NamedMixinApplication named = node.asNamedMixinApplication(); |
| 2875 if (named == null) { | 2877 if (named == null) { |
| 2876 throw new SpannableAssertionFailure(node, | 2878 throw new SpannableAssertionFailure(node, |
| 2877 "Type variables on unnamed mixin applications must be set on " | 2879 "Type variables on unnamed mixin applications must be set on " |
| 2878 "creation."); | 2880 "creation."); |
| 2879 } | 2881 } |
| 2880 return createTypeVariables(named.typeParameters); | 2882 return createTypeVariables(named.typeParameters); |
| 2881 } | 2883 } |
| 2882 | 2884 |
| 2883 accept(ElementVisitor visitor, arg) { | 2885 accept(ElementVisitor visitor, arg) { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2948 DartType boundCache; | 2950 DartType boundCache; |
| 2949 | 2951 |
| 2950 TypeVariableElementX(String name, | 2952 TypeVariableElementX(String name, |
| 2951 TypeDeclarationElement enclosing, | 2953 TypeDeclarationElement enclosing, |
| 2952 this.index, | 2954 this.index, |
| 2953 this.node) | 2955 this.node) |
| 2954 : super(name, ElementKind.TYPE_VARIABLE, enclosing); | 2956 : super(name, ElementKind.TYPE_VARIABLE, enclosing); |
| 2955 | 2957 |
| 2956 TypeDeclarationElement get typeDeclaration => enclosingElement; | 2958 TypeDeclarationElement get typeDeclaration => enclosingElement; |
| 2957 | 2959 |
| 2958 TypeVariableType computeType(compiler) => type; | 2960 TypeVariableType computeType(Resolution resolution) => type; |
| 2959 | 2961 |
| 2960 TypeVariableType get type { | 2962 TypeVariableType get type { |
| 2961 assert(invariant(this, typeCache != null, | 2963 assert(invariant(this, typeCache != null, |
| 2962 message: "Type has not been set on $this.")); | 2964 message: "Type has not been set on $this.")); |
| 2963 return typeCache; | 2965 return typeCache; |
| 2964 } | 2966 } |
| 2965 | 2967 |
| 2966 DartType get bound { | 2968 DartType get bound { |
| 2967 assert(invariant(this, boundCache != null, | 2969 assert(invariant(this, boundCache != null, |
| 2968 message: "Bound has not been set on $this.")); | 2970 message: "Bound has not been set on $this.")); |
| 2969 return boundCache; | 2971 return boundCache; |
| 2970 } | 2972 } |
| 2971 | 2973 |
| 2972 bool get hasNode => true; | 2974 bool get hasNode => true; |
| 2973 | 2975 |
| 2974 Node parseNode(compiler) => node; | 2976 Node parseNode(Parsing parsing) => node; |
| 2975 | 2977 |
| 2976 Token get position => node.getBeginToken(); | 2978 Token get position => node.getBeginToken(); |
| 2977 | 2979 |
| 2978 accept(ElementVisitor visitor, arg) { | 2980 accept(ElementVisitor visitor, arg) { |
| 2979 return visitor.visitTypeVariableElement(this, arg); | 2981 return visitor.visitTypeVariableElement(this, arg); |
| 2980 } | 2982 } |
| 2981 | 2983 |
| 2982 // A type variable cannot be patched therefore defines itself. | 2984 // A type variable cannot be patched therefore defines itself. |
| 2983 AstElement get definingElement => this; | 2985 AstElement get definingElement => this; |
| 2984 } | 2986 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3016 Element annotatedElement; | 3018 Element annotatedElement; |
| 3017 int resolutionState; | 3019 int resolutionState; |
| 3018 | 3020 |
| 3019 /** | 3021 /** |
| 3020 * The beginning token of this annotation, or [:null:] if it is synthetic. | 3022 * The beginning token of this annotation, or [:null:] if it is synthetic. |
| 3021 */ | 3023 */ |
| 3022 Token get beginToken; | 3024 Token get beginToken; |
| 3023 | 3025 |
| 3024 MetadataAnnotationX([this.resolutionState = STATE_NOT_STARTED]); | 3026 MetadataAnnotationX([this.resolutionState = STATE_NOT_STARTED]); |
| 3025 | 3027 |
| 3026 MetadataAnnotation ensureResolved(Compiler compiler) { | 3028 MetadataAnnotation ensureResolved(Resolution resolution) { |
| 3027 if (annotatedElement.isClass || annotatedElement.isTypedef) { | 3029 if (annotatedElement.isClass || annotatedElement.isTypedef) { |
| 3028 TypeDeclarationElement typeDeclaration = annotatedElement; | 3030 TypeDeclarationElement typeDeclaration = annotatedElement; |
| 3029 typeDeclaration.ensureResolved(compiler); | 3031 typeDeclaration.ensureResolved(resolution); |
| 3030 } | 3032 } |
| 3031 if (resolutionState == STATE_NOT_STARTED) { | 3033 if (resolutionState == STATE_NOT_STARTED) { |
| 3032 compiler.resolver.resolveMetadataAnnotation(this); | 3034 resolution.resolveMetadataAnnotation(this); |
| 3033 } | 3035 } |
| 3034 return this; | 3036 return this; |
| 3035 } | 3037 } |
| 3036 | 3038 |
| 3037 Node parseNode(DiagnosticListener listener); | 3039 Node parseNode(Parsing parsing); |
| 3038 | 3040 |
| 3039 String toString() => 'MetadataAnnotation($constant, $resolutionState)'; | 3041 String toString() => 'MetadataAnnotation($constant, $resolutionState)'; |
| 3040 } | 3042 } |
| 3041 | 3043 |
| 3042 /// Metadata annotation on a parameter. | 3044 /// Metadata annotation on a parameter. |
| 3043 class ParameterMetadataAnnotation extends MetadataAnnotationX { | 3045 class ParameterMetadataAnnotation extends MetadataAnnotationX { |
| 3044 final Metadata metadata; | 3046 final Metadata metadata; |
| 3045 | 3047 |
| 3046 ParameterMetadataAnnotation(Metadata this.metadata); | 3048 ParameterMetadataAnnotation(Metadata this.metadata); |
| 3047 | 3049 |
| 3048 Node parseNode(DiagnosticListener listener) => metadata.expression; | 3050 Node parseNode(Parsing parsing) => metadata.expression; |
| 3049 | 3051 |
| 3050 Token get beginToken => metadata.getBeginToken(); | 3052 Token get beginToken => metadata.getBeginToken(); |
| 3051 | 3053 |
| 3052 Token get endToken => metadata.getEndToken(); | 3054 Token get endToken => metadata.getEndToken(); |
| 3053 | 3055 |
| 3054 bool get hasNode => true; | 3056 bool get hasNode => true; |
| 3055 | 3057 |
| 3056 Metadata get node => metadata; | 3058 Metadata get node => metadata; |
| 3057 } | 3059 } |
| 3058 | 3060 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3101 AstElement get definingElement; | 3103 AstElement get definingElement; |
| 3102 | 3104 |
| 3103 bool get hasResolvedAst => definingElement.hasTreeElements; | 3105 bool get hasResolvedAst => definingElement.hasTreeElements; |
| 3104 | 3106 |
| 3105 ResolvedAst get resolvedAst { | 3107 ResolvedAst get resolvedAst { |
| 3106 return new ResolvedAst(declaration, | 3108 return new ResolvedAst(declaration, |
| 3107 definingElement.node, definingElement.treeElements); | 3109 definingElement.node, definingElement.treeElements); |
| 3108 } | 3110 } |
| 3109 | 3111 |
| 3110 } | 3112 } |
| OLD | NEW |