| 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/names.dart' show Identifiers; | 8 import '../common/names.dart' show Identifiers; |
| 9 import '../common/resolution.dart' show Resolution, ParsingContext; | 9 import '../common/resolution.dart' show Resolution, ParsingContext; |
| 10 import '../compiler.dart' show Compiler; | 10 import '../compiler.dart' show Compiler; |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 bool get isRedirectingFactory => unsupported(); | 259 bool get isRedirectingFactory => unsupported(); |
| 260 | 260 |
| 261 computeType(Resolution resolution) => unsupported(); | 261 computeType(Resolution resolution) => unsupported(); |
| 262 | 262 |
| 263 bool get hasFunctionSignature => false; | 263 bool get hasFunctionSignature => false; |
| 264 | 264 |
| 265 bool get hasEffectiveTarget => true; | 265 bool get hasEffectiveTarget => true; |
| 266 | 266 |
| 267 get effectiveTarget => this; | 267 get effectiveTarget => this; |
| 268 | 268 |
| 269 computeEffectiveTargetType(InterfaceType newType) => unsupported(); | 269 computeEffectiveTargetType(ResolutionInterfaceType newType) => unsupported(); |
| 270 | 270 |
| 271 get definingConstructor => null; | 271 get definingConstructor => null; |
| 272 | 272 |
| 273 FunctionElement asFunctionElement() => this; | 273 FunctionElement asFunctionElement() => this; |
| 274 | 274 |
| 275 String get message { | 275 String get message { |
| 276 return MessageTemplate.TEMPLATES[messageKind] | 276 return MessageTemplate.TEMPLATES[messageKind] |
| 277 .message(messageArguments) | 277 .message(messageArguments) |
| 278 .toString(); | 278 .toString(); |
| 279 } | 279 } |
| 280 | 280 |
| 281 String toString() => '<$name: $message>'; | 281 String toString() => '<$name: $message>'; |
| 282 | 282 |
| 283 accept(ElementVisitor visitor, arg) { | 283 accept(ElementVisitor visitor, arg) { |
| 284 return visitor.visitErroneousElement(this, arg); | 284 return visitor.visitErroneousElement(this, arg); |
| 285 } | 285 } |
| 286 | 286 |
| 287 @override | 287 @override |
| 288 get isEffectiveTargetMalformed { | 288 get isEffectiveTargetMalformed { |
| 289 throw new UnsupportedError("isEffectiveTargetMalformed"); | 289 throw new UnsupportedError("isEffectiveTargetMalformed"); |
| 290 } | 290 } |
| 291 | 291 |
| 292 @override | 292 @override |
| 293 List<DartType> get typeVariables => unsupported(); | 293 List<ResolutionDartType> get typeVariables => unsupported(); |
| 294 } | 294 } |
| 295 | 295 |
| 296 /// A constructor that was synthesized to recover from a compile-time error. | 296 /// A constructor that was synthesized to recover from a compile-time error. |
| 297 class ErroneousConstructorElementX extends ErroneousElementX | 297 class ErroneousConstructorElementX extends ErroneousElementX |
| 298 with | 298 with |
| 299 PatchMixin<FunctionElement>, | 299 PatchMixin<FunctionElement>, |
| 300 AnalyzableElementX, | 300 AnalyzableElementX, |
| 301 ConstantConstructorMixin | 301 ConstantConstructorMixin |
| 302 implements ConstructorElementX { | 302 implements ConstructorElementX { |
| 303 // TODO(ahe): Instead of subclassing [ErroneousElementX], this class should | 303 // TODO(ahe): Instead of subclassing [ErroneousElementX], this class should |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 set _isEffectiveTargetMalformed(_) { | 371 set _isEffectiveTargetMalformed(_) { |
| 372 throw new UnsupportedError("_isEffectiveTargetMalformed="); | 372 throw new UnsupportedError("_isEffectiveTargetMalformed="); |
| 373 } | 373 } |
| 374 | 374 |
| 375 @override | 375 @override |
| 376 get isEffectiveTargetMalformed { | 376 get isEffectiveTargetMalformed { |
| 377 throw new UnsupportedError("isEffectiveTargetMalformed"); | 377 throw new UnsupportedError("isEffectiveTargetMalformed"); |
| 378 } | 378 } |
| 379 | 379 |
| 380 @override | 380 @override |
| 381 void setEffectiveTarget(ConstructorElement target, InterfaceType type, | 381 void setEffectiveTarget( |
| 382 ConstructorElement target, ResolutionInterfaceType type, |
| 382 {bool isMalformed: false}) { | 383 {bool isMalformed: false}) { |
| 383 throw new UnsupportedError("setEffectiveTarget"); | 384 throw new UnsupportedError("setEffectiveTarget"); |
| 384 } | 385 } |
| 385 | 386 |
| 386 @override | 387 @override |
| 387 void _computeSignature(Resolution resolution) { | 388 void _computeSignature(Resolution resolution) { |
| 388 throw new UnsupportedError("_computeSignature"); | 389 throw new UnsupportedError("_computeSignature"); |
| 389 } | 390 } |
| 390 | 391 |
| 391 @override | 392 @override |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 Element context, DiagnosticReporter reporter) { | 559 Element context, DiagnosticReporter reporter) { |
| 559 return const <DiagnosticMessage>[]; | 560 return const <DiagnosticMessage>[]; |
| 560 } | 561 } |
| 561 | 562 |
| 562 accept(ElementVisitor visitor, arg) { | 563 accept(ElementVisitor visitor, arg) { |
| 563 return visitor.visitAmbiguousElement(this, arg); | 564 return visitor.visitAmbiguousElement(this, arg); |
| 564 } | 565 } |
| 565 | 566 |
| 566 bool get isTopLevel => false; | 567 bool get isTopLevel => false; |
| 567 | 568 |
| 568 DynamicType get type => const DynamicType(); | 569 ResolutionDynamicType get type => const ResolutionDynamicType(); |
| 569 } | 570 } |
| 570 | 571 |
| 571 /// Element synthesized to diagnose an ambiguous import. | 572 /// Element synthesized to diagnose an ambiguous import. |
| 572 class AmbiguousImportX extends AmbiguousElementX { | 573 class AmbiguousImportX extends AmbiguousElementX { |
| 573 AmbiguousImportX(MessageKind messageKind, Map messageArguments, | 574 AmbiguousImportX(MessageKind messageKind, Map messageArguments, |
| 574 Element enclosingElement, Element existingElement, Element newElement) | 575 Element enclosingElement, Element existingElement, Element newElement) |
| 575 : super(messageKind, messageArguments, enclosingElement, existingElement, | 576 : super(messageKind, messageArguments, enclosingElement, existingElement, |
| 576 newElement); | 577 newElement); |
| 577 | 578 |
| 578 List<DiagnosticMessage> computeInfos( | 579 List<DiagnosticMessage> computeInfos( |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1267 PrefixElementX( | 1268 PrefixElementX( |
| 1268 String prefix, Element enclosing, this.firstPosition, this.deferredImport) | 1269 String prefix, Element enclosing, this.firstPosition, this.deferredImport) |
| 1269 : super(prefix, ElementKind.PREFIX, enclosing); | 1270 : super(prefix, ElementKind.PREFIX, enclosing); |
| 1270 | 1271 |
| 1271 bool get isTopLevel => false; | 1272 bool get isTopLevel => false; |
| 1272 | 1273 |
| 1273 Element lookupLocalMember(String memberName) => importScope[memberName]; | 1274 Element lookupLocalMember(String memberName) => importScope[memberName]; |
| 1274 | 1275 |
| 1275 void forEachLocalMember(f(Element member)) => importScope.forEach(f); | 1276 void forEachLocalMember(f(Element member)) => importScope.forEach(f); |
| 1276 | 1277 |
| 1277 DartType computeType(Resolution resolution) => const DynamicType(); | 1278 ResolutionDartType computeType(Resolution resolution) => |
| 1279 const ResolutionDynamicType(); |
| 1278 | 1280 |
| 1279 Token get position => firstPosition; | 1281 Token get position => firstPosition; |
| 1280 | 1282 |
| 1281 void addImport( | 1283 void addImport( |
| 1282 Element element, ImportElement import, DiagnosticReporter reporter) { | 1284 Element element, ImportElement import, DiagnosticReporter reporter) { |
| 1283 importScope.addImport(this, element, import, reporter); | 1285 importScope.addImport(this, element, import, reporter); |
| 1284 } | 1286 } |
| 1285 | 1287 |
| 1286 accept(ElementVisitor visitor, arg) { | 1288 accept(ElementVisitor visitor, arg) { |
| 1287 return visitor.visitPrefixElement(this, arg); | 1289 return visitor.visitPrefixElement(this, arg); |
| 1288 } | 1290 } |
| 1289 | 1291 |
| 1290 @override | 1292 @override |
| 1291 GetterElement get loadLibrary { | 1293 GetterElement get loadLibrary { |
| 1292 return isDeferred ? lookupLocalMember(Identifiers.loadLibrary) : null; | 1294 return isDeferred ? lookupLocalMember(Identifiers.loadLibrary) : null; |
| 1293 } | 1295 } |
| 1294 | 1296 |
| 1295 String toString() => '$kind($name)'; | 1297 String toString() => '$kind($name)'; |
| 1296 } | 1298 } |
| 1297 | 1299 |
| 1298 class TypedefElementX extends ElementX | 1300 class TypedefElementX extends ElementX |
| 1299 with | 1301 with |
| 1300 AstElementMixin, | 1302 AstElementMixin, |
| 1301 AnalyzableElementX, | 1303 AnalyzableElementX, |
| 1302 TypeDeclarationElementX<TypedefType> | 1304 TypeDeclarationElementX<ResolutionTypedefType> |
| 1303 implements TypedefElement { | 1305 implements TypedefElement { |
| 1304 Typedef cachedNode; | 1306 Typedef cachedNode; |
| 1305 | 1307 |
| 1306 /** | 1308 /** |
| 1307 * The type annotation which defines this typedef. | 1309 * The type annotation which defines this typedef. |
| 1308 */ | 1310 */ |
| 1309 DartType aliasCache; | 1311 ResolutionDartType aliasCache; |
| 1310 | 1312 |
| 1311 DartType get alias { | 1313 ResolutionDartType get alias { |
| 1312 assert(invariant(this, hasBeenCheckedForCycles, | 1314 assert(invariant(this, hasBeenCheckedForCycles, |
| 1313 message: "$this has not been checked for cycles.")); | 1315 message: "$this has not been checked for cycles.")); |
| 1314 return aliasCache; | 1316 return aliasCache; |
| 1315 } | 1317 } |
| 1316 | 1318 |
| 1317 /// [:true:] if the typedef has been checked for cyclic reference. | 1319 /// [:true:] if the typedef has been checked for cyclic reference. |
| 1318 bool hasBeenCheckedForCycles = false; | 1320 bool hasBeenCheckedForCycles = false; |
| 1319 | 1321 |
| 1320 int resolutionState = STATE_NOT_STARTED; | 1322 int resolutionState = STATE_NOT_STARTED; |
| 1321 | 1323 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1333 /** | 1335 /** |
| 1334 * Function signature for a typedef of a function type. The signature is | 1336 * Function signature for a typedef of a function type. The signature is |
| 1335 * kept to provide full information about parameter names through the mirror | 1337 * kept to provide full information about parameter names through the mirror |
| 1336 * system. | 1338 * system. |
| 1337 * | 1339 * |
| 1338 * The [functionSignature] is not available until the typedef element has been | 1340 * The [functionSignature] is not available until the typedef element has been |
| 1339 * resolved. | 1341 * resolved. |
| 1340 */ | 1342 */ |
| 1341 FunctionSignature functionSignature; | 1343 FunctionSignature functionSignature; |
| 1342 | 1344 |
| 1343 TypedefType computeType(Resolution resolution) { | 1345 ResolutionTypedefType computeType(Resolution resolution) { |
| 1344 if (thisTypeCache != null) return thisTypeCache; | 1346 if (thisTypeCache != null) return thisTypeCache; |
| 1345 Typedef node = parseNode(resolution.parsingContext); | 1347 Typedef node = parseNode(resolution.parsingContext); |
| 1346 setThisAndRawTypes(createTypeVariables(node.typeParameters)); | 1348 setThisAndRawTypes(createTypeVariables(node.typeParameters)); |
| 1347 ensureResolved(resolution); | 1349 ensureResolved(resolution); |
| 1348 return thisTypeCache; | 1350 return thisTypeCache; |
| 1349 } | 1351 } |
| 1350 | 1352 |
| 1351 void ensureResolved(Resolution resolution) { | 1353 void ensureResolved(Resolution resolution) { |
| 1352 if (resolutionState == STATE_NOT_STARTED) { | 1354 if (resolutionState == STATE_NOT_STARTED) { |
| 1353 resolution.resolveTypedef(this); | 1355 resolution.resolveTypedef(this); |
| 1354 } | 1356 } |
| 1355 } | 1357 } |
| 1356 | 1358 |
| 1357 TypedefType createType(List<DartType> typeArguments) { | 1359 ResolutionTypedefType createType(List<ResolutionDartType> typeArguments) { |
| 1358 return new TypedefType(this, typeArguments); | 1360 return new ResolutionTypedefType(this, typeArguments); |
| 1359 } | 1361 } |
| 1360 | 1362 |
| 1361 Scope buildScope() { | 1363 Scope buildScope() { |
| 1362 return new TypeDeclarationScope(enclosingElement.buildScope(), this); | 1364 return new TypeDeclarationScope(enclosingElement.buildScope(), this); |
| 1363 } | 1365 } |
| 1364 | 1366 |
| 1365 void checkCyclicReference(Resolution resolution) { | 1367 void checkCyclicReference(Resolution resolution) { |
| 1366 if (hasBeenCheckedForCycles) return; | 1368 if (hasBeenCheckedForCycles) return; |
| 1367 TypedefCyclicVisitor visitor = | 1369 TypedefCyclicVisitor visitor = |
| 1368 new TypedefCyclicVisitor(resolution.reporter, this); | 1370 new TypedefCyclicVisitor(resolution.reporter, this); |
| 1369 computeType(resolution).accept(visitor, null); | 1371 computeType(resolution).accept(visitor, null); |
| 1370 hasBeenCheckedForCycles = true; | 1372 hasBeenCheckedForCycles = true; |
| 1371 } | 1373 } |
| 1372 | 1374 |
| 1373 accept(ElementVisitor visitor, arg) { | 1375 accept(ElementVisitor visitor, arg) { |
| 1374 return visitor.visitTypedefElement(this, arg); | 1376 return visitor.visitTypedefElement(this, arg); |
| 1375 } | 1377 } |
| 1376 | 1378 |
| 1377 // A typedef cannot be patched therefore defines itself. | 1379 // A typedef cannot be patched therefore defines itself. |
| 1378 AstElement get definingElement => this; | 1380 AstElement get definingElement => this; |
| 1379 } | 1381 } |
| 1380 | 1382 |
| 1381 // This class holds common information for a list of variable or field | 1383 // This class holds common information for a list of variable or field |
| 1382 // declarations. It contains the node, and the type. A [VariableElementX] | 1384 // declarations. It contains the node, and the type. A [VariableElementX] |
| 1383 // forwards its [computeType] and [parseNode] methods to this class. | 1385 // forwards its [computeType] and [parseNode] methods to this class. |
| 1384 class VariableList implements DeclarationSite { | 1386 class VariableList implements DeclarationSite { |
| 1385 VariableDefinitions definitions; | 1387 VariableDefinitions definitions; |
| 1386 DartType type; | 1388 ResolutionDartType type; |
| 1387 final Modifiers modifiers; | 1389 final Modifiers modifiers; |
| 1388 List<MetadataAnnotation> metadataInternal; | 1390 List<MetadataAnnotation> metadataInternal; |
| 1389 | 1391 |
| 1390 VariableList(Modifiers this.modifiers); | 1392 VariableList(Modifiers this.modifiers); |
| 1391 | 1393 |
| 1392 VariableList.node(VariableDefinitions node, this.type) | 1394 VariableList.node(VariableDefinitions node, this.type) |
| 1393 : this.definitions = node, | 1395 : this.definitions = node, |
| 1394 this.modifiers = node.modifiers { | 1396 this.modifiers = node.modifiers { |
| 1395 assert(modifiers != null); | 1397 assert(modifiers != null); |
| 1396 } | 1398 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1412 return; | 1414 return; |
| 1413 } | 1415 } |
| 1414 assert(metadataInternal == null); | 1416 assert(metadataInternal == null); |
| 1415 metadataInternal = metadata; | 1417 metadataInternal = metadata; |
| 1416 } | 1418 } |
| 1417 | 1419 |
| 1418 VariableDefinitions parseNode(Element element, ParsingContext parsing) { | 1420 VariableDefinitions parseNode(Element element, ParsingContext parsing) { |
| 1419 return definitions; | 1421 return definitions; |
| 1420 } | 1422 } |
| 1421 | 1423 |
| 1422 DartType computeType(Element element, Resolution resolution) => type; | 1424 ResolutionDartType computeType(Element element, Resolution resolution) => |
| 1425 type; |
| 1423 } | 1426 } |
| 1424 | 1427 |
| 1425 abstract class ConstantVariableMixin implements VariableElement { | 1428 abstract class ConstantVariableMixin implements VariableElement { |
| 1426 ConstantExpression constantCache; | 1429 ConstantExpression constantCache; |
| 1427 | 1430 |
| 1428 // TODO(johnniwinther): Update the on `constant = ...` when evaluation of | 1431 // TODO(johnniwinther): Update the on `constant = ...` when evaluation of |
| 1429 // constant expression can handle references to unanalyzed constant variables. | 1432 // constant expression can handle references to unanalyzed constant variables. |
| 1430 @override | 1433 @override |
| 1431 bool get hasConstant => false; | 1434 bool get hasConstant => false; |
| 1432 | 1435 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1552 } | 1555 } |
| 1553 } else if (identical(name, identifier.source)) { | 1556 } else if (identical(name, identifier.source)) { |
| 1554 definitionCache = initializedIdentifier; | 1557 definitionCache = initializedIdentifier; |
| 1555 } | 1558 } |
| 1556 } | 1559 } |
| 1557 invariant(definitions, definitionCache != null, | 1560 invariant(definitions, definitionCache != null, |
| 1558 message: "Could not find '$name'."); | 1561 message: "Could not find '$name'."); |
| 1559 definitionsCache = definitions; | 1562 definitionsCache = definitions; |
| 1560 } | 1563 } |
| 1561 | 1564 |
| 1562 DartType computeType(Resolution resolution) { | 1565 ResolutionDartType computeType(Resolution resolution) { |
| 1563 if (variables.type != null) return variables.type; | 1566 if (variables.type != null) return variables.type; |
| 1564 // Call [parseNode] to ensure that [definitionsCache] and [initializerCache] | 1567 // Call [parseNode] to ensure that [definitionsCache] and [initializerCache] |
| 1565 // are set as a consequence of calling [computeType]. | 1568 // are set as a consequence of calling [computeType]. |
| 1566 parseNode(resolution.parsingContext); | 1569 parseNode(resolution.parsingContext); |
| 1567 return variables.computeType(this, resolution); | 1570 return variables.computeType(this, resolution); |
| 1568 } | 1571 } |
| 1569 | 1572 |
| 1570 DartType get type { | 1573 ResolutionDartType get type { |
| 1571 assert(invariant(this, variables.type != null, | 1574 assert(invariant(this, variables.type != null, |
| 1572 message: "Type has not been computed for $this.")); | 1575 message: "Type has not been computed for $this.")); |
| 1573 return variables.type; | 1576 return variables.type; |
| 1574 } | 1577 } |
| 1575 | 1578 |
| 1576 bool get isInstanceMember => isClassMember && !isStatic; | 1579 bool get isInstanceMember => isClassMember && !isStatic; |
| 1577 | 1580 |
| 1578 // Note: cachedNode.beginToken will not be correct in all | 1581 // Note: cachedNode.beginToken will not be correct in all |
| 1579 // cases, for example, for function typed parameters. | 1582 // cases, for example, for function typed parameters. |
| 1580 Token get position => token; | 1583 Token get position => token; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1631 /// A field that was synthesized to recover from a compile-time error. | 1634 /// A field that was synthesized to recover from a compile-time error. |
| 1632 class ErroneousFieldElementX extends ElementX | 1635 class ErroneousFieldElementX extends ElementX |
| 1633 with ConstantVariableMixin | 1636 with ConstantVariableMixin |
| 1634 implements FieldElementX { | 1637 implements FieldElementX { |
| 1635 final VariableList variables; | 1638 final VariableList variables; |
| 1636 | 1639 |
| 1637 ErroneousFieldElementX(Identifier name, Element enclosingElement) | 1640 ErroneousFieldElementX(Identifier name, Element enclosingElement) |
| 1638 : variables = new VariableList(Modifiers.EMPTY) | 1641 : variables = new VariableList(Modifiers.EMPTY) |
| 1639 ..definitions = new VariableDefinitions( | 1642 ..definitions = new VariableDefinitions( |
| 1640 null, Modifiers.EMPTY, new NodeList.singleton(name)) | 1643 null, Modifiers.EMPTY, new NodeList.singleton(name)) |
| 1641 ..type = const DynamicType(), | 1644 ..type = const ResolutionDynamicType(), |
| 1642 super(name.source, ElementKind.FIELD, enclosingElement); | 1645 super(name.source, ElementKind.FIELD, enclosingElement); |
| 1643 | 1646 |
| 1644 VariableDefinitions get definitionsCache => variables.definitions; | 1647 VariableDefinitions get definitionsCache => variables.definitions; |
| 1645 | 1648 |
| 1646 set definitionsCache(VariableDefinitions _) { | 1649 set definitionsCache(VariableDefinitions _) { |
| 1647 throw new UnsupportedError("definitionsCache="); | 1650 throw new UnsupportedError("definitionsCache="); |
| 1648 } | 1651 } |
| 1649 | 1652 |
| 1650 bool get hasNode => true; | 1653 bool get hasNode => true; |
| 1651 | 1654 |
| 1652 VariableDefinitions get node => definitionsCache; | 1655 VariableDefinitions get node => definitionsCache; |
| 1653 | 1656 |
| 1654 bool get hasResolvedAst => false; | 1657 bool get hasResolvedAst => false; |
| 1655 | 1658 |
| 1656 ResolvedAst get resolvedAst { | 1659 ResolvedAst get resolvedAst { |
| 1657 throw new UnsupportedError("resolvedAst"); | 1660 throw new UnsupportedError("resolvedAst"); |
| 1658 } | 1661 } |
| 1659 | 1662 |
| 1660 DynamicType get type => const DynamicType(); | 1663 ResolutionDynamicType get type => const ResolutionDynamicType(); |
| 1661 | 1664 |
| 1662 Token get token => node.getBeginToken(); | 1665 Token get token => node.getBeginToken(); |
| 1663 | 1666 |
| 1664 get definitionCache { | 1667 get definitionCache { |
| 1665 throw new UnsupportedError("definitionCache"); | 1668 throw new UnsupportedError("definitionCache"); |
| 1666 } | 1669 } |
| 1667 | 1670 |
| 1668 set definitionCache(_) { | 1671 set definitionCache(_) { |
| 1669 throw new UnsupportedError("definitionCache="); | 1672 throw new UnsupportedError("definitionCache="); |
| 1670 } | 1673 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1707 AstElement get definingElement => this; | 1710 AstElement get definingElement => this; |
| 1708 | 1711 |
| 1709 void reuseElement() { | 1712 void reuseElement() { |
| 1710 throw new UnsupportedError("reuseElement"); | 1713 throw new UnsupportedError("reuseElement"); |
| 1711 } | 1714 } |
| 1712 | 1715 |
| 1713 FieldElementX copyWithEnclosing(Element enclosingElement) { | 1716 FieldElementX copyWithEnclosing(Element enclosingElement) { |
| 1714 throw new UnsupportedError("copyWithEnclosing"); | 1717 throw new UnsupportedError("copyWithEnclosing"); |
| 1715 } | 1718 } |
| 1716 | 1719 |
| 1717 DartType computeType(Resolution resolution) => type; | 1720 ResolutionDartType computeType(Resolution resolution) => type; |
| 1718 } | 1721 } |
| 1719 | 1722 |
| 1720 /// [Element] for a parameter-like element. | 1723 /// [Element] for a parameter-like element. |
| 1721 class FormalElementX extends ElementX | 1724 class FormalElementX extends ElementX |
| 1722 with AstElementMixin | 1725 with AstElementMixin |
| 1723 implements FormalElement { | 1726 implements FormalElement { |
| 1724 final VariableDefinitions definitions; | 1727 final VariableDefinitions definitions; |
| 1725 final Identifier identifier; | 1728 final Identifier identifier; |
| 1726 DartType typeCache; | 1729 ResolutionDartType typeCache; |
| 1727 | 1730 |
| 1728 @override | 1731 @override |
| 1729 List<DartType> get typeVariables => functionSignature.typeVariables; | 1732 List<ResolutionDartType> get typeVariables => functionSignature.typeVariables; |
| 1730 | 1733 |
| 1731 /** | 1734 /** |
| 1732 * Function signature for a variable with a function type. The signature is | 1735 * Function signature for a variable with a function type. The signature is |
| 1733 * kept to provide full information about parameter names through the mirror | 1736 * kept to provide full information about parameter names through the mirror |
| 1734 * system. | 1737 * system. |
| 1735 */ | 1738 */ |
| 1736 FunctionSignature _functionSignatureCache; | 1739 FunctionSignature _functionSignatureCache; |
| 1737 | 1740 |
| 1738 FormalElementX(ElementKind elementKind, FunctionTypedElement enclosingElement, | 1741 FormalElementX(ElementKind elementKind, FunctionTypedElement enclosingElement, |
| 1739 this.definitions, Identifier identifier) | 1742 this.definitions, Identifier identifier) |
| 1740 : this.identifier = identifier, | 1743 : this.identifier = identifier, |
| 1741 super(identifier.source, elementKind, enclosingElement); | 1744 super(identifier.source, elementKind, enclosingElement); |
| 1742 | 1745 |
| 1743 FunctionTypedElement get functionDeclaration => enclosingElement; | 1746 FunctionTypedElement get functionDeclaration => enclosingElement; |
| 1744 | 1747 |
| 1745 Modifiers get modifiers => definitions.modifiers; | 1748 Modifiers get modifiers => definitions.modifiers; |
| 1746 | 1749 |
| 1747 Token get position => identifier.getBeginToken(); | 1750 Token get position => identifier.getBeginToken(); |
| 1748 | 1751 |
| 1749 Node parseNode(ParsingContext parsing) => definitions; | 1752 Node parseNode(ParsingContext parsing) => definitions; |
| 1750 | 1753 |
| 1751 DartType computeType(Resolution resolution) { | 1754 ResolutionDartType computeType(Resolution resolution) { |
| 1752 assert(invariant(this, type != null, | 1755 assert(invariant(this, type != null, |
| 1753 message: "Parameter type has not been set for $this.")); | 1756 message: "Parameter type has not been set for $this.")); |
| 1754 return type; | 1757 return type; |
| 1755 } | 1758 } |
| 1756 | 1759 |
| 1757 DartType get type { | 1760 ResolutionDartType get type { |
| 1758 assert(invariant(this, typeCache != null, | 1761 assert(invariant(this, typeCache != null, |
| 1759 message: "Parameter type has not been set for $this.")); | 1762 message: "Parameter type has not been set for $this.")); |
| 1760 return typeCache; | 1763 return typeCache; |
| 1761 } | 1764 } |
| 1762 | 1765 |
| 1763 FunctionSignature get functionSignature { | 1766 FunctionSignature get functionSignature { |
| 1764 assert(invariant(this, _functionSignatureCache != null, | 1767 assert(invariant(this, _functionSignatureCache != null, |
| 1765 message: "Parameter signature has not been computed for $this.")); | 1768 message: "Parameter signature has not been computed for $this.")); |
| 1766 return _functionSignatureCache; | 1769 return _functionSignatureCache; |
| 1767 } | 1770 } |
| 1768 | 1771 |
| 1769 void set functionSignature(FunctionSignature value) { | 1772 void set functionSignature(FunctionSignature value) { |
| 1770 assert(invariant(this, _functionSignatureCache == null, | 1773 assert(invariant(this, _functionSignatureCache == null, |
| 1771 message: "Parameter signature has already been computed for $this.")); | 1774 message: "Parameter signature has already been computed for $this.")); |
| 1772 _functionSignatureCache = value; | 1775 _functionSignatureCache = value; |
| 1773 typeCache = _functionSignatureCache.type; | 1776 typeCache = _functionSignatureCache.type; |
| 1774 } | 1777 } |
| 1775 | 1778 |
| 1776 bool get hasNode => true; | 1779 bool get hasNode => true; |
| 1777 | 1780 |
| 1778 VariableDefinitions get node => definitions; | 1781 VariableDefinitions get node => definitions; |
| 1779 | 1782 |
| 1780 FunctionType get functionType => type; | 1783 ResolutionFunctionType get functionType => type; |
| 1781 | 1784 |
| 1782 accept(ElementVisitor visitor, arg) { | 1785 accept(ElementVisitor visitor, arg) { |
| 1783 return visitor.visitFormalElement(this, arg); | 1786 return visitor.visitFormalElement(this, arg); |
| 1784 } | 1787 } |
| 1785 | 1788 |
| 1786 // A parameter is defined by the declaration element. | 1789 // A parameter is defined by the declaration element. |
| 1787 AstElement get definingElement => declaration; | 1790 AstElement get definingElement => declaration; |
| 1788 } | 1791 } |
| 1789 | 1792 |
| 1790 /// [Element] for a formal parameter. | 1793 /// [Element] for a formal parameter. |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1889 identifier, null); | 1892 identifier, null); |
| 1890 | 1893 |
| 1891 VariableDefinitions get definitions => fieldElement.node; | 1894 VariableDefinitions get definitions => fieldElement.node; |
| 1892 | 1895 |
| 1893 MemberElement get memberContext => enclosingElement; | 1896 MemberElement get memberContext => enclosingElement; |
| 1894 | 1897 |
| 1895 bool get isLocal => false; | 1898 bool get isLocal => false; |
| 1896 | 1899 |
| 1897 bool get isMalformed => true; | 1900 bool get isMalformed => true; |
| 1898 | 1901 |
| 1899 DynamicType get type => const DynamicType(); | 1902 ResolutionDynamicType get type => const ResolutionDynamicType(); |
| 1900 } | 1903 } |
| 1901 | 1904 |
| 1902 class AbstractFieldElementX extends ElementX | 1905 class AbstractFieldElementX extends ElementX |
| 1903 with AbstractFieldElementCommon | 1906 with AbstractFieldElementCommon |
| 1904 implements AbstractFieldElement { | 1907 implements AbstractFieldElement { |
| 1905 GetterElementX getter; | 1908 GetterElementX getter; |
| 1906 SetterElementX setter; | 1909 SetterElementX setter; |
| 1907 | 1910 |
| 1908 AbstractFieldElementX(String name, Element enclosing) | 1911 AbstractFieldElementX(String name, Element enclosing) |
| 1909 : super(name, ElementKind.ABSTRACT_FIELD, enclosing); | 1912 : super(name, ElementKind.ABSTRACT_FIELD, enclosing); |
| 1910 | 1913 |
| 1911 DartType computeType(Compiler compiler) { | 1914 ResolutionDartType computeType(Compiler compiler) { |
| 1912 throw "internal error: AbstractFieldElement has no type"; | 1915 throw "internal error: AbstractFieldElement has no type"; |
| 1913 } | 1916 } |
| 1914 | 1917 |
| 1915 Node parseNode(ParsingContext parsing) { | 1918 Node parseNode(ParsingContext parsing) { |
| 1916 throw "internal error: AbstractFieldElement has no node"; | 1919 throw "internal error: AbstractFieldElement has no node"; |
| 1917 } | 1920 } |
| 1918 | 1921 |
| 1919 Token get position { | 1922 Token get position { |
| 1920 // The getter and setter may be defined in two different | 1923 // The getter and setter may be defined in two different |
| 1921 // compilation units. However, we know that one of them is | 1924 // compilation units. However, we know that one of them is |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1947 accept(ElementVisitor visitor, arg) { | 1950 accept(ElementVisitor visitor, arg) { |
| 1948 return visitor.visitAbstractFieldElement(this, arg); | 1951 return visitor.visitAbstractFieldElement(this, arg); |
| 1949 } | 1952 } |
| 1950 } | 1953 } |
| 1951 | 1954 |
| 1952 // TODO(johnniwinther): [FunctionSignature] should be merged with | 1955 // TODO(johnniwinther): [FunctionSignature] should be merged with |
| 1953 // [FunctionType]. | 1956 // [FunctionType]. |
| 1954 // TODO(karlklose): all these lists should have element type [FormalElement]. | 1957 // TODO(karlklose): all these lists should have element type [FormalElement]. |
| 1955 class FunctionSignatureX extends FunctionSignatureCommon | 1958 class FunctionSignatureX extends FunctionSignatureCommon |
| 1956 implements FunctionSignature { | 1959 implements FunctionSignature { |
| 1957 final List<DartType> typeVariables; | 1960 final List<ResolutionDartType> typeVariables; |
| 1958 final List<Element> requiredParameters; | 1961 final List<Element> requiredParameters; |
| 1959 final List<Element> optionalParameters; | 1962 final List<Element> optionalParameters; |
| 1960 final int requiredParameterCount; | 1963 final int requiredParameterCount; |
| 1961 final int optionalParameterCount; | 1964 final int optionalParameterCount; |
| 1962 final bool optionalParametersAreNamed; | 1965 final bool optionalParametersAreNamed; |
| 1963 final List<Element> orderedOptionalParameters; | 1966 final List<Element> orderedOptionalParameters; |
| 1964 final FunctionType type; | 1967 final ResolutionFunctionType type; |
| 1965 final bool hasOptionalParameters; | 1968 final bool hasOptionalParameters; |
| 1966 | 1969 |
| 1967 FunctionSignatureX( | 1970 FunctionSignatureX( |
| 1968 {this.typeVariables: const <DartType>[], | 1971 {this.typeVariables: const <ResolutionDartType>[], |
| 1969 this.requiredParameters: const <Element>[], | 1972 this.requiredParameters: const <Element>[], |
| 1970 this.requiredParameterCount: 0, | 1973 this.requiredParameterCount: 0, |
| 1971 List<Element> optionalParameters: const <Element>[], | 1974 List<Element> optionalParameters: const <Element>[], |
| 1972 this.optionalParameterCount: 0, | 1975 this.optionalParameterCount: 0, |
| 1973 this.optionalParametersAreNamed: false, | 1976 this.optionalParametersAreNamed: false, |
| 1974 this.orderedOptionalParameters: const <Element>[], | 1977 this.orderedOptionalParameters: const <Element>[], |
| 1975 this.type}) | 1978 this.type}) |
| 1976 : optionalParameters = optionalParameters, | 1979 : optionalParameters = optionalParameters, |
| 1977 hasOptionalParameters = !optionalParameters.isEmpty; | 1980 hasOptionalParameters = !optionalParameters.isEmpty; |
| 1978 } | 1981 } |
| 1979 | 1982 |
| 1980 abstract class BaseFunctionElementX extends ElementX | 1983 abstract class BaseFunctionElementX extends ElementX |
| 1981 with PatchMixin<FunctionElement>, AstElementMixin | 1984 with PatchMixin<FunctionElement>, AstElementMixin |
| 1982 implements FunctionElement { | 1985 implements FunctionElement { |
| 1983 DartType typeCache; | 1986 ResolutionDartType typeCache; |
| 1984 final Modifiers modifiers; | 1987 final Modifiers modifiers; |
| 1985 | 1988 |
| 1986 List<FunctionElement> nestedClosures = new List<FunctionElement>(); | 1989 List<FunctionElement> nestedClosures = new List<FunctionElement>(); |
| 1987 | 1990 |
| 1988 FunctionSignature _functionSignatureCache; | 1991 FunctionSignature _functionSignatureCache; |
| 1989 | 1992 |
| 1990 AsyncMarker asyncMarker = AsyncMarker.SYNC; | 1993 AsyncMarker asyncMarker = AsyncMarker.SYNC; |
| 1991 | 1994 |
| 1992 BaseFunctionElementX(String name, ElementKind kind, Modifiers this.modifiers, | 1995 BaseFunctionElementX(String name, ElementKind kind, Modifiers this.modifiers, |
| 1993 Element enclosing) | 1996 Element enclosing) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2024 } | 2027 } |
| 2025 | 2028 |
| 2026 List<ParameterElement> get parameters { | 2029 List<ParameterElement> get parameters { |
| 2027 // TODO(johnniwinther): Store the list directly, possibly by using List | 2030 // TODO(johnniwinther): Store the list directly, possibly by using List |
| 2028 // instead of Link in FunctionSignature. | 2031 // instead of Link in FunctionSignature. |
| 2029 List<ParameterElement> list = <ParameterElement>[]; | 2032 List<ParameterElement> list = <ParameterElement>[]; |
| 2030 functionSignature.forEachParameter((e) => list.add(e)); | 2033 functionSignature.forEachParameter((e) => list.add(e)); |
| 2031 return list; | 2034 return list; |
| 2032 } | 2035 } |
| 2033 | 2036 |
| 2034 FunctionType computeType(Resolution resolution) { | 2037 ResolutionFunctionType computeType(Resolution resolution) { |
| 2035 if (typeCache != null) return typeCache; | 2038 if (typeCache != null) return typeCache; |
| 2036 _computeSignature(resolution); | 2039 _computeSignature(resolution); |
| 2037 assert(invariant(this, typeCache != null, | 2040 assert(invariant(this, typeCache != null, |
| 2038 message: "Type cache expected to be set on $this.")); | 2041 message: "Type cache expected to be set on $this.")); |
| 2039 return typeCache; | 2042 return typeCache; |
| 2040 } | 2043 } |
| 2041 | 2044 |
| 2042 FunctionType get type { | 2045 ResolutionFunctionType get type { |
| 2043 assert(invariant(this, typeCache != null, | 2046 assert(invariant(this, typeCache != null, |
| 2044 message: "Type has not been computed for $this.")); | 2047 message: "Type has not been computed for $this.")); |
| 2045 return typeCache; | 2048 return typeCache; |
| 2046 } | 2049 } |
| 2047 | 2050 |
| 2048 FunctionElement asFunctionElement() => this; | 2051 FunctionElement asFunctionElement() => this; |
| 2049 | 2052 |
| 2050 @override | 2053 @override |
| 2051 Scope buildScope() => new TypeDeclarationScope(super.buildScope(), this); | 2054 Scope buildScope() => new TypeDeclarationScope(super.buildScope(), this); |
| 2052 | 2055 |
| 2053 String toString() { | 2056 String toString() { |
| 2054 if (isPatch) { | 2057 if (isPatch) { |
| 2055 return 'patch ${super.toString()}'; | 2058 return 'patch ${super.toString()}'; |
| 2056 } else if (isPatched) { | 2059 } else if (isPatched) { |
| 2057 return 'origin ${super.toString()}'; | 2060 return 'origin ${super.toString()}'; |
| 2058 } else { | 2061 } else { |
| 2059 return super.toString(); | 2062 return super.toString(); |
| 2060 } | 2063 } |
| 2061 } | 2064 } |
| 2062 | 2065 |
| 2063 bool get isAbstract => false; | 2066 bool get isAbstract => false; |
| 2064 | 2067 |
| 2065 // A function is defined by the implementation element. | 2068 // A function is defined by the implementation element. |
| 2066 AstElement get definingElement => implementation; | 2069 AstElement get definingElement => implementation; |
| 2067 | 2070 |
| 2068 @override | 2071 @override |
| 2069 List<DartType> get typeVariables => functionSignature.typeVariables; | 2072 List<ResolutionDartType> get typeVariables => functionSignature.typeVariables; |
| 2070 } | 2073 } |
| 2071 | 2074 |
| 2072 abstract class FunctionElementX extends BaseFunctionElementX | 2075 abstract class FunctionElementX extends BaseFunctionElementX |
| 2073 with AnalyzableElementX | 2076 with AnalyzableElementX |
| 2074 implements MethodElement { | 2077 implements MethodElement { |
| 2075 FunctionElementX( | 2078 FunctionElementX( |
| 2076 String name, ElementKind kind, Modifiers modifiers, Element enclosing) | 2079 String name, ElementKind kind, Modifiers modifiers, Element enclosing) |
| 2077 : super(name, kind, modifiers, enclosing); | 2080 : super(name, kind, modifiers, enclosing); |
| 2078 | 2081 |
| 2079 MemberElement get memberContext => this; | 2082 MemberElement get memberContext => this; |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2212 assert(invariant( | 2215 assert(invariant( |
| 2213 this, _constantConstructor == null || _constantConstructor == value, | 2216 this, _constantConstructor == null || _constantConstructor == value, |
| 2214 message: "Constant constructor already computed for $this:" | 2217 message: "Constant constructor already computed for $this:" |
| 2215 "Existing: $_constantConstructor, new: $value")); | 2218 "Existing: $_constantConstructor, new: $value")); |
| 2216 _constantConstructor = value; | 2219 _constantConstructor = value; |
| 2217 } | 2220 } |
| 2218 } | 2221 } |
| 2219 | 2222 |
| 2220 /// Returns the empty list of type variables by default. | 2223 /// Returns the empty list of type variables by default. |
| 2221 @override | 2224 @override |
| 2222 List<DartType> get typeVariables => functionSignature.typeVariables; | 2225 List<ResolutionDartType> get typeVariables => functionSignature.typeVariables; |
| 2223 } | 2226 } |
| 2224 | 2227 |
| 2225 abstract class ConstructorElementX extends FunctionElementX | 2228 abstract class ConstructorElementX extends FunctionElementX |
| 2226 with ConstantConstructorMixin, ConstructorElementCommon | 2229 with ConstantConstructorMixin, ConstructorElementCommon |
| 2227 implements ConstructorElement { | 2230 implements ConstructorElement { |
| 2228 bool isRedirectingGenerativeInternal = false; | 2231 bool isRedirectingGenerativeInternal = false; |
| 2229 | 2232 |
| 2230 ConstructorElementX( | 2233 ConstructorElementX( |
| 2231 String name, ElementKind kind, Modifiers modifiers, Element enclosing) | 2234 String name, ElementKind kind, Modifiers modifiers, Element enclosing) |
| 2232 : super(name, kind, modifiers, enclosing); | 2235 : super(name, kind, modifiers, enclosing); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2244 bool get isRedirectingFactory => immediateRedirectionTarget != null; | 2247 bool get isRedirectingFactory => immediateRedirectionTarget != null; |
| 2245 | 2248 |
| 2246 // TODO(johnniwinther): This should also return true for cyclic redirecting | 2249 // TODO(johnniwinther): This should also return true for cyclic redirecting |
| 2247 // generative constructors. | 2250 // generative constructors. |
| 2248 bool get isCyclicRedirection => effectiveTarget.isRedirectingFactory; | 2251 bool get isCyclicRedirection => effectiveTarget.isRedirectingFactory; |
| 2249 | 2252 |
| 2250 bool get isDefaultConstructor => false; | 2253 bool get isDefaultConstructor => false; |
| 2251 | 2254 |
| 2252 /// These fields are set by the post process queue when checking for cycles. | 2255 /// These fields are set by the post process queue when checking for cycles. |
| 2253 ConstructorElement effectiveTargetInternal; | 2256 ConstructorElement effectiveTargetInternal; |
| 2254 DartType _effectiveTargetType; | 2257 ResolutionDartType _effectiveTargetType; |
| 2255 bool _isEffectiveTargetMalformed; | 2258 bool _isEffectiveTargetMalformed; |
| 2256 | 2259 |
| 2257 bool get hasEffectiveTarget { | 2260 bool get hasEffectiveTarget { |
| 2258 if (isPatched) { | 2261 if (isPatched) { |
| 2259 return patch.hasEffectiveTarget; | 2262 return patch.hasEffectiveTarget; |
| 2260 } | 2263 } |
| 2261 return effectiveTargetInternal != null; | 2264 return effectiveTargetInternal != null; |
| 2262 } | 2265 } |
| 2263 | 2266 |
| 2264 void setImmediateRedirectionTarget( | 2267 void setImmediateRedirectionTarget( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2281 return _immediateRedirectionTarget; | 2284 return _immediateRedirectionTarget; |
| 2282 } | 2285 } |
| 2283 | 2286 |
| 2284 PrefixElement get redirectionDeferredPrefix { | 2287 PrefixElement get redirectionDeferredPrefix { |
| 2285 if (isPatched) { | 2288 if (isPatched) { |
| 2286 return patch.redirectionDeferredPrefix; | 2289 return patch.redirectionDeferredPrefix; |
| 2287 } | 2290 } |
| 2288 return _redirectionDeferredPrefix; | 2291 return _redirectionDeferredPrefix; |
| 2289 } | 2292 } |
| 2290 | 2293 |
| 2291 void setEffectiveTarget(ConstructorElement target, DartType type, | 2294 void setEffectiveTarget(ConstructorElement target, ResolutionDartType type, |
| 2292 {bool isMalformed: false}) { | 2295 {bool isMalformed: false}) { |
| 2293 if (isPatched) { | 2296 if (isPatched) { |
| 2294 patch.setEffectiveTarget(target, type, isMalformed: isMalformed); | 2297 patch.setEffectiveTarget(target, type, isMalformed: isMalformed); |
| 2295 } else { | 2298 } else { |
| 2296 assert(invariant(this, target != null, | 2299 assert(invariant(this, target != null, |
| 2297 message: 'No effective target provided for $this.')); | 2300 message: 'No effective target provided for $this.')); |
| 2298 assert(invariant(this, effectiveTargetInternal == null, | 2301 assert(invariant(this, effectiveTargetInternal == null, |
| 2299 message: 'Effective target has already been computed for $this.')); | 2302 message: 'Effective target has already been computed for $this.')); |
| 2300 assert(invariant(this, !target.isMalformed || isMalformed, | 2303 assert(invariant(this, !target.isMalformed || isMalformed, |
| 2301 message: 'Effective target is not marked as malformed for $this: ' | 2304 message: 'Effective target is not marked as malformed for $this: ' |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2313 if (isPatched) { | 2316 if (isPatched) { |
| 2314 return patch.effectiveTarget; | 2317 return patch.effectiveTarget; |
| 2315 } | 2318 } |
| 2316 if (isRedirectingFactory) { | 2319 if (isRedirectingFactory) { |
| 2317 assert(effectiveTargetInternal != null); | 2320 assert(effectiveTargetInternal != null); |
| 2318 return effectiveTargetInternal; | 2321 return effectiveTargetInternal; |
| 2319 } | 2322 } |
| 2320 return this; | 2323 return this; |
| 2321 } | 2324 } |
| 2322 | 2325 |
| 2323 DartType get effectiveTargetType { | 2326 ResolutionDartType get effectiveTargetType { |
| 2324 if (isPatched) { | 2327 if (isPatched) { |
| 2325 return patch.effectiveTargetType; | 2328 return patch.effectiveTargetType; |
| 2326 } | 2329 } |
| 2327 assert(invariant(this, _effectiveTargetType != null, | 2330 assert(invariant(this, _effectiveTargetType != null, |
| 2328 message: 'Effective target type has not yet been computed for $this.')); | 2331 message: 'Effective target type has not yet been computed for $this.')); |
| 2329 return _effectiveTargetType; | 2332 return _effectiveTargetType; |
| 2330 } | 2333 } |
| 2331 | 2334 |
| 2332 DartType computeEffectiveTargetType(InterfaceType newType) { | 2335 ResolutionDartType computeEffectiveTargetType( |
| 2336 ResolutionInterfaceType newType) { |
| 2333 if (isPatched) { | 2337 if (isPatched) { |
| 2334 return patch.computeEffectiveTargetType(newType); | 2338 return patch.computeEffectiveTargetType(newType); |
| 2335 } | 2339 } |
| 2336 if (!isRedirectingFactory) return newType; | 2340 if (!isRedirectingFactory) return newType; |
| 2337 return effectiveTargetType.substByContext(newType); | 2341 return effectiveTargetType.substByContext(newType); |
| 2338 } | 2342 } |
| 2339 | 2343 |
| 2340 bool get isEffectiveTargetMalformed { | 2344 bool get isEffectiveTargetMalformed { |
| 2341 if (isPatched) { | 2345 if (isPatched) { |
| 2342 return patch.isEffectiveTargetMalformed; | 2346 return patch.isEffectiveTargetMalformed; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2356 ClassElement get enclosingClass => enclosingElement; | 2360 ClassElement get enclosingClass => enclosingElement; |
| 2357 } | 2361 } |
| 2358 | 2362 |
| 2359 class DeferredLoaderGetterElementX extends GetterElementX | 2363 class DeferredLoaderGetterElementX extends GetterElementX |
| 2360 implements GetterElement { | 2364 implements GetterElement { |
| 2361 final PrefixElement prefix; | 2365 final PrefixElement prefix; |
| 2362 | 2366 |
| 2363 DeferredLoaderGetterElementX(PrefixElement prefix) | 2367 DeferredLoaderGetterElementX(PrefixElement prefix) |
| 2364 : this.prefix = prefix, | 2368 : this.prefix = prefix, |
| 2365 super(Identifiers.loadLibrary, Modifiers.EMPTY, prefix, false) { | 2369 super(Identifiers.loadLibrary, Modifiers.EMPTY, prefix, false) { |
| 2366 functionSignature = new FunctionSignatureX(type: new FunctionType(this)); | 2370 functionSignature = |
| 2371 new FunctionSignatureX(type: new ResolutionFunctionType(this)); |
| 2367 } | 2372 } |
| 2368 | 2373 |
| 2369 bool get isClassMember => false; | 2374 bool get isClassMember => false; |
| 2370 | 2375 |
| 2371 bool get isSynthesized => true; | 2376 bool get isSynthesized => true; |
| 2372 | 2377 |
| 2373 bool get isDeferredLoaderGetter => true; | 2378 bool get isDeferredLoaderGetter => true; |
| 2374 | 2379 |
| 2375 bool get isTopLevel => true; | 2380 bool get isTopLevel => true; |
| 2376 | 2381 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2421 _resolvedAst.body, _resolvedAst.elements, _resolvedAst.sourceUri); | 2426 _resolvedAst.body, _resolvedAst.elements, _resolvedAst.sourceUri); |
| 2422 } else { | 2427 } else { |
| 2423 return new SynthesizedResolvedAst(declaration, _resolvedAst.kind); | 2428 return new SynthesizedResolvedAst(declaration, _resolvedAst.kind); |
| 2424 } | 2429 } |
| 2425 } | 2430 } |
| 2426 | 2431 |
| 2427 List<MetadataAnnotation> get metadata => constructor.metadata; | 2432 List<MetadataAnnotation> get metadata => constructor.metadata; |
| 2428 | 2433 |
| 2429 bool get isInstanceMember => true; | 2434 bool get isInstanceMember => true; |
| 2430 | 2435 |
| 2431 FunctionType computeType(Resolution resolution) { | 2436 ResolutionFunctionType computeType(Resolution resolution) { |
| 2432 DiagnosticReporter reporter = resolution.reporter; | 2437 DiagnosticReporter reporter = resolution.reporter; |
| 2433 reporter.internalError(this, '$this.computeType.'); | 2438 reporter.internalError(this, '$this.computeType.'); |
| 2434 return null; | 2439 return null; |
| 2435 } | 2440 } |
| 2436 | 2441 |
| 2437 int get sourceOffset => constructor.sourceOffset; | 2442 int get sourceOffset => constructor.sourceOffset; |
| 2438 | 2443 |
| 2439 Token get position => constructor.position; | 2444 Token get position => constructor.position; |
| 2440 | 2445 |
| 2441 Element get outermostEnclosingMemberOrTopLevel => constructor; | 2446 Element get outermostEnclosingMemberOrTopLevel => constructor; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2466 enclosing) { | 2471 enclosing) { |
| 2467 _resolvedAst = new SynthesizedResolvedAst( | 2472 _resolvedAst = new SynthesizedResolvedAst( |
| 2468 this, ResolvedAstKind.FORWARDING_CONSTRUCTOR); | 2473 this, ResolvedAstKind.FORWARDING_CONSTRUCTOR); |
| 2469 } | 2474 } |
| 2470 | 2475 |
| 2471 SynthesizedConstructorElementX.forDefault( | 2476 SynthesizedConstructorElementX.forDefault( |
| 2472 this.definingConstructor, Element enclosing) | 2477 this.definingConstructor, Element enclosing) |
| 2473 : super('', ElementKind.GENERATIVE_CONSTRUCTOR, Modifiers.EMPTY, | 2478 : super('', ElementKind.GENERATIVE_CONSTRUCTOR, Modifiers.EMPTY, |
| 2474 enclosing) { | 2479 enclosing) { |
| 2475 functionSignature = new FunctionSignatureX( | 2480 functionSignature = new FunctionSignatureX( |
| 2476 type: new FunctionType.synthesized(enclosingClass.thisType)); | 2481 type: new ResolutionFunctionType.synthesized(enclosingClass.thisType)); |
| 2477 _resolvedAst = | 2482 _resolvedAst = |
| 2478 new SynthesizedResolvedAst(this, ResolvedAstKind.DEFAULT_CONSTRUCTOR); | 2483 new SynthesizedResolvedAst(this, ResolvedAstKind.DEFAULT_CONSTRUCTOR); |
| 2479 } | 2484 } |
| 2480 | 2485 |
| 2481 bool get isDefaultConstructor { | 2486 bool get isDefaultConstructor { |
| 2482 return _resolvedAst.kind == ResolvedAstKind.DEFAULT_CONSTRUCTOR; | 2487 return _resolvedAst.kind == ResolvedAstKind.DEFAULT_CONSTRUCTOR; |
| 2483 } | 2488 } |
| 2484 | 2489 |
| 2485 FunctionExpression parseNode(ParsingContext parsing) => null; | 2490 FunctionExpression parseNode(ParsingContext parsing) => null; |
| 2486 | 2491 |
| 2487 bool get hasNode => false; | 2492 bool get hasNode => false; |
| 2488 | 2493 |
| 2489 FunctionExpression get node => null; | 2494 FunctionExpression get node => null; |
| 2490 | 2495 |
| 2491 Token get position => enclosingElement.position; | 2496 Token get position => enclosingElement.position; |
| 2492 | 2497 |
| 2493 bool get isSynthesized => true; | 2498 bool get isSynthesized => true; |
| 2494 | 2499 |
| 2495 bool get hasResolvedAst => true; | 2500 bool get hasResolvedAst => true; |
| 2496 | 2501 |
| 2497 ResolvedAst get resolvedAst => _resolvedAst; | 2502 ResolvedAst get resolvedAst => _resolvedAst; |
| 2498 | 2503 |
| 2499 DartType get type { | 2504 ResolutionDartType get type { |
| 2500 if (isDefaultConstructor) { | 2505 if (isDefaultConstructor) { |
| 2501 return super.type; | 2506 return super.type; |
| 2502 } else { | 2507 } else { |
| 2503 // TODO(johnniwinther): Ensure that the function type substitutes type | 2508 // TODO(johnniwinther): Ensure that the function type substitutes type |
| 2504 // variables correctly. | 2509 // variables correctly. |
| 2505 return definingConstructor.type; | 2510 return definingConstructor.type; |
| 2506 } | 2511 } |
| 2507 } | 2512 } |
| 2508 | 2513 |
| 2509 void _computeSignature(Resolution resolution) { | 2514 void _computeSignature(Resolution resolution) { |
| 2510 if (hasFunctionSignature) return; | 2515 if (hasFunctionSignature) return; |
| 2511 if (definingConstructor.isMalformed) { | 2516 if (definingConstructor.isMalformed) { |
| 2512 functionSignature = new FunctionSignatureX( | 2517 functionSignature = new FunctionSignatureX( |
| 2513 type: new FunctionType.synthesized(enclosingClass.thisType)); | 2518 type: |
| 2519 new ResolutionFunctionType.synthesized(enclosingClass.thisType)); |
| 2514 } | 2520 } |
| 2515 // TODO(johnniwinther): Ensure that the function signature (and with it the | 2521 // TODO(johnniwinther): Ensure that the function signature (and with it the |
| 2516 // function type) substitutes type variables correctly. | 2522 // function type) substitutes type variables correctly. |
| 2517 definingConstructor.computeType(resolution); | 2523 definingConstructor.computeType(resolution); |
| 2518 functionSignature = definingConstructor.functionSignature; | 2524 functionSignature = definingConstructor.functionSignature; |
| 2519 } | 2525 } |
| 2520 | 2526 |
| 2521 accept(ElementVisitor visitor, arg) { | 2527 accept(ElementVisitor visitor, arg) { |
| 2522 return visitor.visitConstructorElement(this, arg); | 2528 return visitor.visitConstructorElement(this, arg); |
| 2523 } | 2529 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2543 * | 2549 * |
| 2544 * The raw type is the generic type base on this element in which the type | 2550 * The raw type is the generic type base on this element in which the type |
| 2545 * arguments are all [dynamic]. For instance [:List<dynamic>:] for [:List:] | 2551 * arguments are all [dynamic]. For instance [:List<dynamic>:] for [:List:] |
| 2546 * and [:Map<dynamic,dynamic>:] for [:Map:]. For non-generic classes [rawType] | 2552 * and [:Map<dynamic,dynamic>:] for [:Map:]. For non-generic classes [rawType] |
| 2547 * is the same as [thisType]. | 2553 * is the same as [thisType]. |
| 2548 * | 2554 * |
| 2549 * The [rawType] field is a canonicalization of the raw type and should be | 2555 * The [rawType] field is a canonicalization of the raw type and should be |
| 2550 * used to distinguish explicit and implicit uses of the [dynamic] | 2556 * used to distinguish explicit and implicit uses of the [dynamic] |
| 2551 * type arguments. For instance should [:List:] be the [rawType] of the | 2557 * type arguments. For instance should [:List:] be the [rawType] of the |
| 2552 * [:List:] class element whereas [:List<dynamic>:] should be its own | 2558 * [:List:] class element whereas [:List<dynamic>:] should be its own |
| 2553 * instantiation of [InterfaceType] with [:dynamic:] as type argument. Using | 2559 * instantiation of [ResolutionInterfaceType] with [:dynamic:] as type |
| 2554 * this distinction, we can print the raw type with type arguments only when | 2560 * argument. Using this distinction, we can print the raw type with type |
| 2555 * the input source has used explicit type arguments. | 2561 * arguments only when the input source has used explicit type arguments. |
| 2556 * | 2562 * |
| 2557 * This type is computed together with [thisType] in [computeType]. | 2563 * This type is computed together with [thisType] in [computeType]. |
| 2558 */ | 2564 */ |
| 2559 T rawTypeCache; | 2565 T rawTypeCache; |
| 2560 | 2566 |
| 2561 T get thisType { | 2567 T get thisType { |
| 2562 assert(invariant(this, thisTypeCache != null, | 2568 assert(invariant(this, thisTypeCache != null, |
| 2563 message: 'This type has not been computed for $this')); | 2569 message: 'This type has not been computed for $this')); |
| 2564 return thisTypeCache; | 2570 return thisTypeCache; |
| 2565 } | 2571 } |
| 2566 | 2572 |
| 2567 T get rawType { | 2573 T get rawType { |
| 2568 assert(invariant(this, rawTypeCache != null, | 2574 assert(invariant(this, rawTypeCache != null, |
| 2569 message: 'Raw type has not been computed for $this')); | 2575 message: 'Raw type has not been computed for $this')); |
| 2570 return rawTypeCache; | 2576 return rawTypeCache; |
| 2571 } | 2577 } |
| 2572 | 2578 |
| 2573 T createType(List<DartType> typeArguments); | 2579 T createType(List<ResolutionDartType> typeArguments); |
| 2574 | 2580 |
| 2575 void setThisAndRawTypes(List<DartType> typeParameters) { | 2581 void setThisAndRawTypes(List<ResolutionDartType> typeParameters) { |
| 2576 assert(invariant(this, thisTypeCache == null, | 2582 assert(invariant(this, thisTypeCache == null, |
| 2577 message: "This type has already been set on $this.")); | 2583 message: "This type has already been set on $this.")); |
| 2578 assert(invariant(this, rawTypeCache == null, | 2584 assert(invariant(this, rawTypeCache == null, |
| 2579 message: "Raw type has already been set on $this.")); | 2585 message: "Raw type has already been set on $this.")); |
| 2580 thisTypeCache = createType(typeParameters); | 2586 thisTypeCache = createType(typeParameters); |
| 2581 if (typeParameters.isEmpty) { | 2587 if (typeParameters.isEmpty) { |
| 2582 rawTypeCache = thisTypeCache; | 2588 rawTypeCache = thisTypeCache; |
| 2583 } else { | 2589 } else { |
| 2584 List<DartType> dynamicParameters = | 2590 List<ResolutionDartType> dynamicParameters = |
| 2585 new List.filled(typeParameters.length, const DynamicType()); | 2591 new List.filled(typeParameters.length, const ResolutionDynamicType()); |
| 2586 rawTypeCache = createType(dynamicParameters); | 2592 rawTypeCache = createType(dynamicParameters); |
| 2587 } | 2593 } |
| 2588 } | 2594 } |
| 2589 | 2595 |
| 2590 List<DartType> get typeVariables => thisType.typeArguments; | 2596 List<ResolutionDartType> get typeVariables => thisType.typeArguments; |
| 2591 | 2597 |
| 2592 /** | 2598 /** |
| 2593 * Creates the type variables, their type and corresponding element, for the | 2599 * Creates the type variables, their type and corresponding element, for the |
| 2594 * type variables declared in [parameter] on [element]. The bounds of the type | 2600 * type variables declared in [parameter] on [element]. The bounds of the type |
| 2595 * variables are not set until [element] has been resolved. | 2601 * variables are not set until [element] has been resolved. |
| 2596 */ | 2602 */ |
| 2597 List<DartType> createTypeVariables(NodeList parameters) { | 2603 List<ResolutionDartType> createTypeVariables(NodeList parameters) { |
| 2598 if (parameters == null) return const <DartType>[]; | 2604 if (parameters == null) return const <ResolutionDartType>[]; |
| 2599 | 2605 |
| 2600 // Create types and elements for type variable. | 2606 // Create types and elements for type variable. |
| 2601 Link<Node> nodes = parameters.nodes; | 2607 Link<Node> nodes = parameters.nodes; |
| 2602 List<DartType> arguments = | 2608 List<ResolutionDartType> arguments = |
| 2603 new List.generate(nodes.slowLength(), (int index) { | 2609 new List.generate(nodes.slowLength(), (int index) { |
| 2604 TypeVariable node = nodes.head; | 2610 TypeVariable node = nodes.head; |
| 2605 String variableName = node.name.source; | 2611 String variableName = node.name.source; |
| 2606 nodes = nodes.tail; | 2612 nodes = nodes.tail; |
| 2607 TypeVariableElementX variableElement = | 2613 TypeVariableElementX variableElement = |
| 2608 new TypeVariableElementX(variableName, this, index, node); | 2614 new TypeVariableElementX(variableName, this, index, node); |
| 2609 TypeVariableType variableType = new TypeVariableType(variableElement); | 2615 ResolutionTypeVariableType variableType = |
| 2616 new ResolutionTypeVariableType(variableElement); |
| 2610 variableElement.typeCache = variableType; | 2617 variableElement.typeCache = variableType; |
| 2611 return variableType; | 2618 return variableType; |
| 2612 }, growable: false); | 2619 }, growable: false); |
| 2613 return arguments; | 2620 return arguments; |
| 2614 } | 2621 } |
| 2615 | 2622 |
| 2616 bool get isResolved => resolutionState == STATE_DONE; | 2623 bool get isResolved => resolutionState == STATE_DONE; |
| 2617 | 2624 |
| 2618 int get resolutionState; | 2625 int get resolutionState; |
| 2619 } | 2626 } |
| 2620 | 2627 |
| 2621 abstract class BaseClassElementX extends ElementX | 2628 abstract class BaseClassElementX extends ElementX |
| 2622 with | 2629 with |
| 2623 AstElementMixin, | 2630 AstElementMixin, |
| 2624 AnalyzableElementX, | 2631 AnalyzableElementX, |
| 2625 ClassElementCommon, | 2632 ClassElementCommon, |
| 2626 TypeDeclarationElementX<InterfaceType>, | 2633 TypeDeclarationElementX<ResolutionInterfaceType>, |
| 2627 PatchMixin<ClassElement>, | 2634 PatchMixin<ClassElement>, |
| 2628 ClassMemberMixin | 2635 ClassMemberMixin |
| 2629 implements ClassElement { | 2636 implements ClassElement { |
| 2630 final int id; | 2637 final int id; |
| 2631 | 2638 |
| 2632 DartType supertype; | 2639 ResolutionDartType supertype; |
| 2633 Link<DartType> interfaces; | 2640 Link<ResolutionDartType> interfaces; |
| 2634 int supertypeLoadState; | 2641 int supertypeLoadState; |
| 2635 int resolutionState; | 2642 int resolutionState; |
| 2636 bool isProxy = false; | 2643 bool isProxy = false; |
| 2637 bool hasIncompleteHierarchy = false; | 2644 bool hasIncompleteHierarchy = false; |
| 2638 | 2645 |
| 2639 OrderedTypeSet allSupertypesAndSelf; | 2646 OrderedTypeSet allSupertypesAndSelf; |
| 2640 | 2647 |
| 2641 BaseClassElementX(String name, Element enclosing, this.id, int initialState) | 2648 BaseClassElementX(String name, Element enclosing, this.id, int initialState) |
| 2642 : supertypeLoadState = initialState, | 2649 : supertypeLoadState = initialState, |
| 2643 resolutionState = initialState, | 2650 resolutionState = initialState, |
| 2644 super(name, ElementKind.CLASS, enclosing); | 2651 super(name, ElementKind.CLASS, enclosing); |
| 2645 | 2652 |
| 2646 int get hashCode => id; | 2653 int get hashCode => id; |
| 2647 | 2654 |
| 2648 bool get isUnnamedMixinApplication => false; | 2655 bool get isUnnamedMixinApplication => false; |
| 2649 | 2656 |
| 2650 @override | 2657 @override |
| 2651 bool get isEnumClass => false; | 2658 bool get isEnumClass => false; |
| 2652 | 2659 |
| 2653 InterfaceType computeType(Resolution resolution) { | 2660 ResolutionInterfaceType computeType(Resolution resolution) { |
| 2654 if (isPatch) { | 2661 if (isPatch) { |
| 2655 origin.computeType(resolution); | 2662 origin.computeType(resolution); |
| 2656 thisTypeCache = origin.thisType; | 2663 thisTypeCache = origin.thisType; |
| 2657 rawTypeCache = origin.rawType; | 2664 rawTypeCache = origin.rawType; |
| 2658 } else if (thisTypeCache == null) { | 2665 } else if (thisTypeCache == null) { |
| 2659 computeThisAndRawType( | 2666 computeThisAndRawType( |
| 2660 resolution, computeTypeParameters(resolution.parsingContext)); | 2667 resolution, computeTypeParameters(resolution.parsingContext)); |
| 2661 } | 2668 } |
| 2662 return thisTypeCache; | 2669 return thisTypeCache; |
| 2663 } | 2670 } |
| 2664 | 2671 |
| 2665 void computeThisAndRawType( | 2672 void computeThisAndRawType( |
| 2666 Resolution resolution, List<DartType> typeVariables) { | 2673 Resolution resolution, List<ResolutionDartType> typeVariables) { |
| 2667 if (thisTypeCache == null) { | 2674 if (thisTypeCache == null) { |
| 2668 if (origin == null) { | 2675 if (origin == null) { |
| 2669 setThisAndRawTypes(typeVariables); | 2676 setThisAndRawTypes(typeVariables); |
| 2670 } else { | 2677 } else { |
| 2671 thisTypeCache = origin.computeType(resolution); | 2678 thisTypeCache = origin.computeType(resolution); |
| 2672 rawTypeCache = origin.rawType; | 2679 rawTypeCache = origin.rawType; |
| 2673 } | 2680 } |
| 2674 } | 2681 } |
| 2675 } | 2682 } |
| 2676 | 2683 |
| 2677 @override | 2684 @override |
| 2678 InterfaceType createType(List<DartType> typeArguments) { | 2685 ResolutionInterfaceType createType(List<ResolutionDartType> typeArguments) { |
| 2679 return new InterfaceType(this, typeArguments); | 2686 return new ResolutionInterfaceType(this, typeArguments); |
| 2680 } | 2687 } |
| 2681 | 2688 |
| 2682 List<DartType> computeTypeParameters(ParsingContext parsing); | 2689 List<ResolutionDartType> computeTypeParameters(ParsingContext parsing); |
| 2683 | 2690 |
| 2684 bool get isObject { | 2691 bool get isObject { |
| 2685 assert(invariant(this, isResolved, | 2692 assert(invariant(this, isResolved, |
| 2686 message: "isObject has not been computed for $this.")); | 2693 message: "isObject has not been computed for $this.")); |
| 2687 return supertype == null; | 2694 return supertype == null; |
| 2688 } | 2695 } |
| 2689 | 2696 |
| 2690 void ensureResolved(Resolution resolution) { | 2697 void ensureResolved(Resolution resolution) { |
| 2691 if (resolutionState == STATE_NOT_STARTED) { | 2698 if (resolutionState == STATE_NOT_STARTED) { |
| 2692 resolution.resolveClass(this); | 2699 resolution.resolveClass(this); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2780 } | 2787 } |
| 2781 return false; | 2788 return false; |
| 2782 } | 2789 } |
| 2783 | 2790 |
| 2784 void setDefaultConstructor( | 2791 void setDefaultConstructor( |
| 2785 FunctionElement constructor, DiagnosticReporter reporter) { | 2792 FunctionElement constructor, DiagnosticReporter reporter) { |
| 2786 // The default constructor, although synthetic, is part of a class' API. | 2793 // The default constructor, although synthetic, is part of a class' API. |
| 2787 addMember(constructor, reporter); | 2794 addMember(constructor, reporter); |
| 2788 } | 2795 } |
| 2789 | 2796 |
| 2790 List<DartType> computeTypeParameters(ParsingContext parsing) { | 2797 List<ResolutionDartType> computeTypeParameters(ParsingContext parsing) { |
| 2791 ClassNode node = parseNode(parsing); | 2798 ClassNode node = parseNode(parsing); |
| 2792 return createTypeVariables(node.typeParameters); | 2799 return createTypeVariables(node.typeParameters); |
| 2793 } | 2800 } |
| 2794 | 2801 |
| 2795 Scope buildScope() => new ClassScope(enclosingElement.buildScope(), this); | 2802 Scope buildScope() => new ClassScope(enclosingElement.buildScope(), this); |
| 2796 | 2803 |
| 2797 String toString() { | 2804 String toString() { |
| 2798 if (origin != null) { | 2805 if (origin != null) { |
| 2799 return 'patch ${super.toString()}'; | 2806 return 'patch ${super.toString()}'; |
| 2800 } else if (patch != null) { | 2807 } else if (patch != null) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2848 bool get isEnumClass => true; | 2855 bool get isEnumClass => true; |
| 2849 | 2856 |
| 2850 @override | 2857 @override |
| 2851 Node parseNode(ParsingContext parsing) => node; | 2858 Node parseNode(ParsingContext parsing) => node; |
| 2852 | 2859 |
| 2853 @override | 2860 @override |
| 2854 accept(ElementVisitor visitor, arg) { | 2861 accept(ElementVisitor visitor, arg) { |
| 2855 return visitor.visitEnumClassElement(this, arg); | 2862 return visitor.visitEnumClassElement(this, arg); |
| 2856 } | 2863 } |
| 2857 | 2864 |
| 2858 List<DartType> computeTypeParameters(ParsingContext parsing) => | 2865 List<ResolutionDartType> computeTypeParameters(ParsingContext parsing) => |
| 2859 const <DartType>[]; | 2866 const <ResolutionDartType>[]; |
| 2860 | 2867 |
| 2861 List<FieldElement> get enumValues { | 2868 List<FieldElement> get enumValues { |
| 2862 assert(invariant(this, _enumValues != null, | 2869 assert(invariant(this, _enumValues != null, |
| 2863 message: "enumValues has not been computed for $this.")); | 2870 message: "enumValues has not been computed for $this.")); |
| 2864 return _enumValues; | 2871 return _enumValues; |
| 2865 } | 2872 } |
| 2866 | 2873 |
| 2867 void set enumValues(List<FieldElement> values) { | 2874 void set enumValues(List<FieldElement> values) { |
| 2868 assert(invariant(this, _enumValues == null, | 2875 assert(invariant(this, _enumValues == null, |
| 2869 message: "enumValues has already been computed for $this.")); | 2876 message: "enumValues has already been computed for $this.")); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3085 return new SourceSpan(enclosingClass.sourcePosition.uri, | 3092 return new SourceSpan(enclosingClass.sourcePosition.uri, |
| 3086 position.charOffset, position.charEnd); | 3093 position.charOffset, position.charEnd); |
| 3087 } | 3094 } |
| 3088 } | 3095 } |
| 3089 | 3096 |
| 3090 abstract class MixinApplicationElementX extends BaseClassElementX | 3097 abstract class MixinApplicationElementX extends BaseClassElementX |
| 3091 with MixinApplicationElementCommon | 3098 with MixinApplicationElementCommon |
| 3092 implements MixinApplicationElement { | 3099 implements MixinApplicationElement { |
| 3093 Link<ConstructorElement> constructors = new Link<ConstructorElement>(); | 3100 Link<ConstructorElement> constructors = new Link<ConstructorElement>(); |
| 3094 | 3101 |
| 3095 InterfaceType mixinType; | 3102 ResolutionInterfaceType mixinType; |
| 3096 | 3103 |
| 3097 MixinApplicationElementX(String name, Element enclosing, int id) | 3104 MixinApplicationElementX(String name, Element enclosing, int id) |
| 3098 : super(name, enclosing, id, STATE_NOT_STARTED); | 3105 : super(name, enclosing, id, STATE_NOT_STARTED); |
| 3099 | 3106 |
| 3100 ClassElement get mixin => mixinType != null ? mixinType.element : null; | 3107 ClassElement get mixin => mixinType != null ? mixinType.element : null; |
| 3101 | 3108 |
| 3102 bool get isMixinApplication => true; | 3109 bool get isMixinApplication => true; |
| 3103 bool get hasConstructor => !constructors.isEmpty; | 3110 bool get hasConstructor => !constructors.isEmpty; |
| 3104 bool get hasLocalScopeMembers => !constructors.isEmpty; | 3111 bool get hasLocalScopeMembers => !constructors.isEmpty; |
| 3105 | 3112 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3123 void addConstructor(FunctionElement constructor) { | 3130 void addConstructor(FunctionElement constructor) { |
| 3124 constructors = constructors.prepend(constructor); | 3131 constructors = constructors.prepend(constructor); |
| 3125 } | 3132 } |
| 3126 | 3133 |
| 3127 void setDefaultConstructor( | 3134 void setDefaultConstructor( |
| 3128 FunctionElement constructor, DiagnosticReporter reporter) { | 3135 FunctionElement constructor, DiagnosticReporter reporter) { |
| 3129 assert(!hasConstructor); | 3136 assert(!hasConstructor); |
| 3130 addConstructor(constructor); | 3137 addConstructor(constructor); |
| 3131 } | 3138 } |
| 3132 | 3139 |
| 3133 List<DartType> computeTypeParameters(ParsingContext parsing) { | 3140 List<ResolutionDartType> computeTypeParameters(ParsingContext parsing) { |
| 3134 NamedMixinApplication named = node.asNamedMixinApplication(); | 3141 NamedMixinApplication named = node.asNamedMixinApplication(); |
| 3135 if (named == null) { | 3142 if (named == null) { |
| 3136 throw new SpannableAssertionFailure( | 3143 throw new SpannableAssertionFailure( |
| 3137 node, | 3144 node, |
| 3138 "Type variables on unnamed mixin applications must be set on " | 3145 "Type variables on unnamed mixin applications must be set on " |
| 3139 "creation."); | 3146 "creation."); |
| 3140 } | 3147 } |
| 3141 return createTypeVariables(named.typeParameters); | 3148 return createTypeVariables(named.typeParameters); |
| 3142 } | 3149 } |
| 3143 | 3150 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3230 bool get isSwitch => statement is SwitchStatement; | 3237 bool get isSwitch => statement is SwitchStatement; |
| 3231 | 3238 |
| 3232 String toString() => 'Target:$statement'; | 3239 String toString() => 'Target:$statement'; |
| 3233 } | 3240 } |
| 3234 | 3241 |
| 3235 class TypeVariableElementX extends ElementX | 3242 class TypeVariableElementX extends ElementX |
| 3236 with AstElementMixin | 3243 with AstElementMixin |
| 3237 implements TypeVariableElement { | 3244 implements TypeVariableElement { |
| 3238 final int index; | 3245 final int index; |
| 3239 final Node node; | 3246 final Node node; |
| 3240 TypeVariableType typeCache; | 3247 ResolutionTypeVariableType typeCache; |
| 3241 DartType boundCache; | 3248 ResolutionDartType boundCache; |
| 3242 | 3249 |
| 3243 TypeVariableElementX( | 3250 TypeVariableElementX( |
| 3244 String name, GenericElement enclosing, this.index, this.node) | 3251 String name, GenericElement enclosing, this.index, this.node) |
| 3245 : super(name, ElementKind.TYPE_VARIABLE, enclosing); | 3252 : super(name, ElementKind.TYPE_VARIABLE, enclosing); |
| 3246 | 3253 |
| 3247 GenericElement get typeDeclaration => enclosingElement; | 3254 GenericElement get typeDeclaration => enclosingElement; |
| 3248 | 3255 |
| 3249 TypeVariableType computeType(Resolution resolution) => type; | 3256 ResolutionTypeVariableType computeType(Resolution resolution) => type; |
| 3250 | 3257 |
| 3251 TypeVariableType get type { | 3258 ResolutionTypeVariableType get type { |
| 3252 assert(invariant(this, typeCache != null, | 3259 assert(invariant(this, typeCache != null, |
| 3253 message: "Type has not been set on $this.")); | 3260 message: "Type has not been set on $this.")); |
| 3254 return typeCache; | 3261 return typeCache; |
| 3255 } | 3262 } |
| 3256 | 3263 |
| 3257 DartType get bound { | 3264 ResolutionDartType get bound { |
| 3258 assert(invariant(this, boundCache != null, | 3265 assert(invariant(this, boundCache != null, |
| 3259 message: "Bound has not been set on $this.")); | 3266 message: "Bound has not been set on $this.")); |
| 3260 return boundCache; | 3267 return boundCache; |
| 3261 } | 3268 } |
| 3262 | 3269 |
| 3263 bool get hasNode => true; | 3270 bool get hasNode => true; |
| 3264 | 3271 |
| 3265 Node parseNode(ParsingContext parsing) => node; | 3272 Node parseNode(ParsingContext parsing) => node; |
| 3266 | 3273 |
| 3267 Token get position => node.getBeginToken(); | 3274 Token get position => node.getBeginToken(); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3414 body = node.asFunctionExpression().body; | 3421 body = node.asFunctionExpression().body; |
| 3415 } | 3422 } |
| 3416 return new ParsedResolvedAst( | 3423 return new ParsedResolvedAst( |
| 3417 declaration, | 3424 declaration, |
| 3418 node, | 3425 node, |
| 3419 body, | 3426 body, |
| 3420 definingElement.treeElements, | 3427 definingElement.treeElements, |
| 3421 definingElement.compilationUnit.script.resourceUri); | 3428 definingElement.compilationUnit.script.resourceUri); |
| 3422 } | 3429 } |
| 3423 } | 3430 } |
| OLD | NEW |