| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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'); | 5 #library('elements'); |
| 6 | 6 |
| 7 #import('dart:uri'); | 7 #import('dart:uri'); |
| 8 | 8 |
| 9 #import('../tree/tree.dart'); | 9 #import('../tree/tree.dart'); |
| 10 #import('../scanner/scannerlib.dart'); | 10 #import('../scanner/scannerlib.dart'); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 class Element implements Hashable { | 105 class Element implements Hashable { |
| 106 final SourceString name; | 106 final SourceString name; |
| 107 final ElementKind kind; | 107 final ElementKind kind; |
| 108 final Element enclosingElement; | 108 final Element enclosingElement; |
| 109 Link<Node> metadata = const EmptyLink<Node>(); | 109 Link<Node> metadata = const EmptyLink<Node>(); |
| 110 | 110 |
| 111 Element(this.name, this.kind, this.enclosingElement) { | 111 Element(this.name, this.kind, this.enclosingElement) { |
| 112 assert(getLibrary() !== null); | 112 assert(getLibrary() !== null); |
| 113 } | 113 } |
| 114 | 114 |
| 115 Modifiers get modifiers() => null; | 115 Modifiers get modifiers => null; |
| 116 | 116 |
| 117 Node parseNode(DiagnosticListener listener) { | 117 Node parseNode(DiagnosticListener listener) { |
| 118 listener.cancel("Internal Error: $this.parseNode", token: position()); | 118 listener.cancel("Internal Error: $this.parseNode", token: position()); |
| 119 } | 119 } |
| 120 | 120 |
| 121 Type computeType(Compiler compiler) { | 121 Type computeType(Compiler compiler) { |
| 122 compiler.internalError("$this.computeType.", token: position()); | 122 compiler.internalError("$this.computeType.", token: position()); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void addMetadata(Node node) { | 125 void addMetadata(Node node) { |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 | 313 |
| 314 ErroneousElement(this.errorMessage, Element enclosing) | 314 ErroneousElement(this.errorMessage, Element enclosing) |
| 315 : super(const SourceString('erroneous element'), null, enclosing); | 315 : super(const SourceString('erroneous element'), null, enclosing); |
| 316 | 316 |
| 317 isErroneous() => true; | 317 isErroneous() => true; |
| 318 | 318 |
| 319 unsupported() { | 319 unsupported() { |
| 320 throw 'unsupported operation on erroneous element'; | 320 throw 'unsupported operation on erroneous element'; |
| 321 } | 321 } |
| 322 | 322 |
| 323 SourceString get name() => unsupported(); | 323 SourceString get name => unsupported(); |
| 324 ElementKind get kind() => unsupported(); | 324 ElementKind get kind => unsupported(); |
| 325 Link<Node> get metadata() => unsupported(); | 325 Link<Node> get metadata => unsupported(); |
| 326 } | 326 } |
| 327 | 327 |
| 328 class ErroneousFunctionElement extends ErroneousElement | 328 class ErroneousFunctionElement extends ErroneousElement |
| 329 implements FunctionElement { | 329 implements FunctionElement { |
| 330 ErroneousFunctionElement(errorMessage, Element enclosing) | 330 ErroneousFunctionElement(errorMessage, Element enclosing) |
| 331 : super(errorMessage, enclosing); | 331 : super(errorMessage, enclosing); |
| 332 | 332 |
| 333 get type() => unsupported(); | 333 get type => unsupported(); |
| 334 get cachedNode() => unsupported(); | 334 get cachedNode => unsupported(); |
| 335 get functionSignature() => unsupported(); | 335 get functionSignature => unsupported(); |
| 336 get patch() => unsupported(); | 336 get patch => unsupported(); |
| 337 get defaultImplementation() => unsupported(); | 337 get defaultImplementation => unsupported(); |
| 338 bool get isPatched() => unsupported(); | 338 bool get isPatched => unsupported(); |
| 339 setPatch(patch) => unsupported(); | 339 setPatch(patch) => unsupported(); |
| 340 computeSignature(compiler) => unsupported(); | 340 computeSignature(compiler) => unsupported(); |
| 341 requiredParameterCount(compiler) => unsupported(); | 341 requiredParameterCount(compiler) => unsupported(); |
| 342 optionalParameterCount(compiler) => unsupported(); | 342 optionalParameterCount(compiler) => unsupported(); |
| 343 parameterCount(copmiler) => unsupported(); | 343 parameterCount(copmiler) => unsupported(); |
| 344 | 344 |
| 345 getLibrary() => enclosingElement.getLibrary(); | 345 getLibrary() => enclosingElement.getLibrary(); |
| 346 } | 346 } |
| 347 | 347 |
| 348 class ContainerElement extends Element { | 348 class ContainerElement extends Element { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 bool canUseNative = false; | 464 bool canUseNative = false; |
| 465 LibraryElement patch = null; | 465 LibraryElement patch = null; |
| 466 | 466 |
| 467 LibraryElement(Script script, [Uri uri]) | 467 LibraryElement(Script script, [Uri uri]) |
| 468 : this.uri = ((uri === null) ? script.uri : uri), | 468 : this.uri = ((uri === null) ? script.uri : uri), |
| 469 super(new SourceString(script.name), ElementKind.LIBRARY, null) { | 469 super(new SourceString(script.name), ElementKind.LIBRARY, null) { |
| 470 entryCompilationUnit = new CompilationUnitElement(script, this); | 470 entryCompilationUnit = new CompilationUnitElement(script, this); |
| 471 } | 471 } |
| 472 | 472 |
| 473 | 473 |
| 474 bool get isPatched() => patch !== null; | 474 bool get isPatched => patch !== null; |
| 475 | 475 |
| 476 void addCompilationUnit(CompilationUnitElement element) { | 476 void addCompilationUnit(CompilationUnitElement element) { |
| 477 compilationUnits = compilationUnits.prepend(element); | 477 compilationUnits = compilationUnits.prepend(element); |
| 478 } | 478 } |
| 479 | 479 |
| 480 void addTag(ScriptTag tag, DiagnosticListener listener) { | 480 void addTag(ScriptTag tag, DiagnosticListener listener) { |
| 481 tags = tags.prepend(tag); | 481 tags = tags.prepend(tag); |
| 482 } | 482 } |
| 483 | 483 |
| 484 /** Look up a top-level element in this library. The element could | 484 /** Look up a top-level element in this library. The element could |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 TypedefType computeType(Compiler compiler) { | 572 TypedefType computeType(Compiler compiler) { |
| 573 if (cachedType !== null) return cachedType; | 573 if (cachedType !== null) return cachedType; |
| 574 Typedef node = parseNode(compiler); | 574 Typedef node = parseNode(compiler); |
| 575 Link<Type> parameters = | 575 Link<Type> parameters = |
| 576 TypeDeclarationElement.createTypeVariables(this, node.typeParameters); | 576 TypeDeclarationElement.createTypeVariables(this, node.typeParameters); |
| 577 cachedType = new TypedefType(this, parameters); | 577 cachedType = new TypedefType(this, parameters); |
| 578 compiler.resolveTypedef(this); | 578 compiler.resolveTypedef(this); |
| 579 return cachedType; | 579 return cachedType; |
| 580 } | 580 } |
| 581 | 581 |
| 582 Link<Type> get typeVariables() => cachedType.typeArguments; | 582 Link<Type> get typeVariables => cachedType.typeArguments; |
| 583 | 583 |
| 584 Scope buildScope() => | 584 Scope buildScope() => |
| 585 new TypeDeclarationScope(enclosingElement.buildScope(), this); | 585 new TypeDeclarationScope(enclosingElement.buildScope(), this); |
| 586 | 586 |
| 587 TypedefElement cloneTo(Element enclosing, DiagnosticListener listener) { | 587 TypedefElement cloneTo(Element enclosing, DiagnosticListener listener) { |
| 588 TypedefElement result = new TypedefElement(name, enclosing); | 588 TypedefElement result = new TypedefElement(name, enclosing); |
| 589 return result; | 589 return result; |
| 590 } | 590 } |
| 591 } | 591 } |
| 592 | 592 |
| 593 class VariableElement extends Element { | 593 class VariableElement extends Element { |
| 594 final VariableListElement variables; | 594 final VariableListElement variables; |
| 595 Expression cachedNode; // The send or the identifier in the variables list. | 595 Expression cachedNode; // The send or the identifier in the variables list. |
| 596 | 596 |
| 597 Modifiers get modifiers() => variables.modifiers; | 597 Modifiers get modifiers => variables.modifiers; |
| 598 | 598 |
| 599 VariableElement(SourceString name, | 599 VariableElement(SourceString name, |
| 600 VariableListElement this.variables, | 600 VariableListElement this.variables, |
| 601 ElementKind kind, | 601 ElementKind kind, |
| 602 Element enclosing, | 602 Element enclosing, |
| 603 [Node node]) | 603 [Node node]) |
| 604 : super(name, kind, enclosing), cachedNode = node; | 604 : super(name, kind, enclosing), cachedNode = node; |
| 605 | 605 |
| 606 Node parseNode(DiagnosticListener listener) { | 606 Node parseNode(DiagnosticListener listener) { |
| 607 if (cachedNode !== null) return cachedNode; | 607 if (cachedNode !== null) return cachedNode; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 618 return cachedNode; | 618 return cachedNode; |
| 619 } | 619 } |
| 620 } | 620 } |
| 621 listener.cancel('internal error: could not find $name', node: variables); | 621 listener.cancel('internal error: could not find $name', node: variables); |
| 622 } | 622 } |
| 623 | 623 |
| 624 Type computeType(Compiler compiler) { | 624 Type computeType(Compiler compiler) { |
| 625 return variables.computeType(compiler); | 625 return variables.computeType(compiler); |
| 626 } | 626 } |
| 627 | 627 |
| 628 Type get type() => variables.type; | 628 Type get type => variables.type; |
| 629 | 629 |
| 630 bool isInstanceMember() { | 630 bool isInstanceMember() { |
| 631 return isMember() && !modifiers.isStatic(); | 631 return isMember() && !modifiers.isStatic(); |
| 632 } | 632 } |
| 633 | 633 |
| 634 // Note: cachedNode.getBeginToken() will not be correct in all | 634 // Note: cachedNode.getBeginToken() will not be correct in all |
| 635 // cases, for example, for function typed parameters. | 635 // cases, for example, for function typed parameters. |
| 636 Token position() => findMyName(variables.position()); | 636 Token position() => findMyName(variables.position()); |
| 637 | 637 |
| 638 VariableElement cloneTo(Element enclosing, DiagnosticListener listener) { | 638 VariableElement cloneTo(Element enclosing, DiagnosticListener listener) { |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 // We need to make sure that the position returned is relative to | 784 // We need to make sure that the position returned is relative to |
| 785 // the compilation unit of the abstract element. | 785 // the compilation unit of the abstract element. |
| 786 if (getter !== null | 786 if (getter !== null |
| 787 && getter.getCompilationUnit() === getCompilationUnit()) { | 787 && getter.getCompilationUnit() === getCompilationUnit()) { |
| 788 return getter.position(); | 788 return getter.position(); |
| 789 } else { | 789 } else { |
| 790 return setter.position(); | 790 return setter.position(); |
| 791 } | 791 } |
| 792 } | 792 } |
| 793 | 793 |
| 794 Modifiers get modifiers() { | 794 Modifiers get modifiers { |
| 795 // The resolver ensures that the flags match (ignoring abstract). | 795 // The resolver ensures that the flags match (ignoring abstract). |
| 796 if (getter !== null) { | 796 if (getter !== null) { |
| 797 return new Modifiers.withFlags( | 797 return new Modifiers.withFlags( |
| 798 getter.modifiers.nodes, | 798 getter.modifiers.nodes, |
| 799 getter.modifiers.flags | Modifiers.FLAG_ABSTRACT); | 799 getter.modifiers.flags | Modifiers.FLAG_ABSTRACT); |
| 800 } else { | 800 } else { |
| 801 return new Modifiers.withFlags( | 801 return new Modifiers.withFlags( |
| 802 setter.modifiers.nodes, | 802 setter.modifiers.nodes, |
| 803 setter.modifiers.flags | Modifiers.FLAG_ABSTRACT); | 803 setter.modifiers.flags | Modifiers.FLAG_ABSTRACT); |
| 804 } | 804 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 830 link = link.tail) { | 830 link = link.tail) { |
| 831 function(link.head); | 831 function(link.head); |
| 832 } | 832 } |
| 833 for (Link<Element> link = optionalParameters; | 833 for (Link<Element> link = optionalParameters; |
| 834 !link.isEmpty(); | 834 !link.isEmpty(); |
| 835 link = link.tail) { | 835 link = link.tail) { |
| 836 function(link.head); | 836 function(link.head); |
| 837 } | 837 } |
| 838 } | 838 } |
| 839 | 839 |
| 840 int get parameterCount() => requiredParameterCount + optionalParameterCount; | 840 int get parameterCount => requiredParameterCount + optionalParameterCount; |
| 841 } | 841 } |
| 842 | 842 |
| 843 class FunctionElement extends Element { | 843 class FunctionElement extends Element { |
| 844 FunctionExpression cachedNode; | 844 FunctionExpression cachedNode; |
| 845 Type type; | 845 Type type; |
| 846 final Modifiers modifiers; | 846 final Modifiers modifiers; |
| 847 | 847 |
| 848 FunctionSignature functionSignature; | 848 FunctionSignature functionSignature; |
| 849 | 849 |
| 850 /** | 850 /** |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 885 FunctionElement.tooMuchOverloading(SourceString name, | 885 FunctionElement.tooMuchOverloading(SourceString name, |
| 886 FunctionExpression this.cachedNode, | 886 FunctionExpression this.cachedNode, |
| 887 ElementKind kind, | 887 ElementKind kind, |
| 888 Modifiers this.modifiers, | 888 Modifiers this.modifiers, |
| 889 Element enclosing, | 889 Element enclosing, |
| 890 FunctionSignature this.functionSignature) | 890 FunctionSignature this.functionSignature) |
| 891 : super(name, kind, enclosing) { | 891 : super(name, kind, enclosing) { |
| 892 defaultImplementation = this; | 892 defaultImplementation = this; |
| 893 } | 893 } |
| 894 | 894 |
| 895 bool get isPatched() => patch !== null; | 895 bool get isPatched => patch !== null; |
| 896 | 896 |
| 897 /** | 897 /** |
| 898 * Applies a patch function to this function. The patch function's body | 898 * Applies a patch function to this function. The patch function's body |
| 899 * is used as replacement when parsing this function's body. | 899 * is used as replacement when parsing this function's body. |
| 900 * This method must not be called after the function has been parsed, | 900 * This method must not be called after the function has been parsed, |
| 901 * and it must be called at most once. | 901 * and it must be called at most once. |
| 902 */ | 902 */ |
| 903 void setPatch(FunctionElement patchElement) { | 903 void setPatch(FunctionElement patchElement) { |
| 904 // Sanity checks. The caller must check these things before calling. | 904 // Sanity checks. The caller must check these things before calling. |
| 905 assert(patch === null); | 905 assert(patch === null); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1097 InterfaceType computeType(compiler) { | 1097 InterfaceType computeType(compiler) { |
| 1098 if (type == null) { | 1098 if (type == null) { |
| 1099 ClassNode node = parseNode(compiler); | 1099 ClassNode node = parseNode(compiler); |
| 1100 Link<Type> parameters = | 1100 Link<Type> parameters = |
| 1101 TypeDeclarationElement.createTypeVariables(this, node.typeParameters); | 1101 TypeDeclarationElement.createTypeVariables(this, node.typeParameters); |
| 1102 type = new InterfaceType(this, parameters); | 1102 type = new InterfaceType(this, parameters); |
| 1103 } | 1103 } |
| 1104 return type; | 1104 return type; |
| 1105 } | 1105 } |
| 1106 | 1106 |
| 1107 bool get isPatched() => patch != null; | 1107 bool get isPatched => patch != null; |
| 1108 | 1108 |
| 1109 Link<Type> get typeVariables() => type.arguments; | 1109 Link<Type> get typeVariables => type.arguments; |
| 1110 | 1110 |
| 1111 ClassElement ensureResolved(Compiler compiler) { | 1111 ClassElement ensureResolved(Compiler compiler) { |
| 1112 if (resolutionState == STATE_NOT_STARTED) { | 1112 if (resolutionState == STATE_NOT_STARTED) { |
| 1113 compiler.resolver.resolveClass(this); | 1113 compiler.resolver.resolveClass(this); |
| 1114 } | 1114 } |
| 1115 return this; | 1115 return this; |
| 1116 } | 1116 } |
| 1117 | 1117 |
| 1118 /** | 1118 /** |
| 1119 * Lookup local members in the class. This will ignore constructors. | 1119 * Lookup local members in the class. This will ignore constructors. |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1239 } else { | 1239 } else { |
| 1240 normalizedName = className; | 1240 normalizedName = className; |
| 1241 } | 1241 } |
| 1242 Element result = localLookup(normalizedName); | 1242 Element result = localLookup(normalizedName); |
| 1243 if (result === null || !result.isConstructor()) { | 1243 if (result === null || !result.isConstructor()) { |
| 1244 result = noMatch !== null ? noMatch(result) : null; | 1244 result = noMatch !== null ? noMatch(result) : null; |
| 1245 } | 1245 } |
| 1246 return result; | 1246 return result; |
| 1247 } | 1247 } |
| 1248 | 1248 |
| 1249 bool get hasConstructor() { | 1249 bool get hasConstructor { |
| 1250 // Search in scope to be sure we search patched constructors. | 1250 // Search in scope to be sure we search patched constructors. |
| 1251 for (var element in localScope.getValues()) { | 1251 for (var element in localScope.getValues()) { |
| 1252 if (element.isConstructor()) return true; | 1252 if (element.isConstructor()) return true; |
| 1253 } | 1253 } |
| 1254 return false; | 1254 return false; |
| 1255 } | 1255 } |
| 1256 | 1256 |
| 1257 Link<Element> get constructors() { | 1257 Link<Element> get constructors { |
| 1258 // TODO(ajohnsen): See if we can avoid this method at some point. | 1258 // TODO(ajohnsen): See if we can avoid this method at some point. |
| 1259 Link<Element> result = const EmptyLink<Element>(); | 1259 Link<Element> result = const EmptyLink<Element>(); |
| 1260 for (Element member in localMembers) { | 1260 for (Element member in localMembers) { |
| 1261 if (member.isConstructor()) result = result.prepend(member); | 1261 if (member.isConstructor()) result = result.prepend(member); |
| 1262 } | 1262 } |
| 1263 return result; | 1263 return result; |
| 1264 } | 1264 } |
| 1265 | 1265 |
| 1266 /** | 1266 /** |
| 1267 * Returns the super class, if any. | 1267 * Returns the super class, if any. |
| 1268 * | 1268 * |
| 1269 * The returned element may not be resolved yet. | 1269 * The returned element may not be resolved yet. |
| 1270 */ | 1270 */ |
| 1271 ClassElement get superclass() { | 1271 ClassElement get superclass { |
| 1272 assert(supertypeLoadState == STATE_DONE); | 1272 assert(supertypeLoadState == STATE_DONE); |
| 1273 return supertype === null ? null : supertype.element; | 1273 return supertype === null ? null : supertype.element; |
| 1274 } | 1274 } |
| 1275 | 1275 |
| 1276 /** | 1276 /** |
| 1277 * Runs through all members of this class. | 1277 * Runs through all members of this class. |
| 1278 * | 1278 * |
| 1279 * The enclosing class is passed to the callback. This is useful when | 1279 * The enclosing class is passed to the callback. This is useful when |
| 1280 * [includeSuperMembers] is [:true:]. | 1280 * [includeSuperMembers] is [:true:]. |
| 1281 */ | 1281 */ |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1350 bool isNative() => nativeName != null; | 1350 bool isNative() => nativeName != null; |
| 1351 int hashCode() => id; | 1351 int hashCode() => id; |
| 1352 | 1352 |
| 1353 Scope buildScope() => | 1353 Scope buildScope() => |
| 1354 new ClassScope(enclosingElement.buildScope(), this); | 1354 new ClassScope(enclosingElement.buildScope(), this); |
| 1355 | 1355 |
| 1356 ClassElement cloneTo(Element enclosing, DiagnosticListener listener) { | 1356 ClassElement cloneTo(Element enclosing, DiagnosticListener listener) { |
| 1357 listener.internalErrorOnElement(this, 'unsupported operation'); | 1357 listener.internalErrorOnElement(this, 'unsupported operation'); |
| 1358 } | 1358 } |
| 1359 | 1359 |
| 1360 Link<Type> get allSupertypesAndSelf() { | 1360 Link<Type> get allSupertypesAndSelf { |
| 1361 return allSupertypes.prepend(new InterfaceType(this)); | 1361 return allSupertypes.prepend(new InterfaceType(this)); |
| 1362 } | 1362 } |
| 1363 } | 1363 } |
| 1364 | 1364 |
| 1365 class Elements { | 1365 class Elements { |
| 1366 static bool isLocal(Element element) { | 1366 static bool isLocal(Element element) { |
| 1367 return !Element.isInvalid(element) | 1367 return !Element.isInvalid(element) |
| 1368 && !element.isInstanceMember() | 1368 && !element.isInstanceMember() |
| 1369 && !isStaticOrTopLevelField(element) | 1369 && !isStaticOrTopLevelField(element) |
| 1370 && !isStaticOrTopLevelFunction(element) | 1370 && !isStaticOrTopLevelFunction(element) |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1501 | 1501 |
| 1502 void setBreakTarget() { | 1502 void setBreakTarget() { |
| 1503 isBreakTarget = true; | 1503 isBreakTarget = true; |
| 1504 target.isBreakTarget = true; | 1504 target.isBreakTarget = true; |
| 1505 } | 1505 } |
| 1506 void setContinueTarget() { | 1506 void setContinueTarget() { |
| 1507 isContinueTarget = true; | 1507 isContinueTarget = true; |
| 1508 target.isContinueTarget = true; | 1508 target.isContinueTarget = true; |
| 1509 } | 1509 } |
| 1510 | 1510 |
| 1511 bool get isTarget() => isBreakTarget || isContinueTarget; | 1511 bool get isTarget => isBreakTarget || isContinueTarget; |
| 1512 Node parseNode(DiagnosticListener l) => label; | 1512 Node parseNode(DiagnosticListener l) => label; |
| 1513 | 1513 |
| 1514 Token position() => label.getBeginToken(); | 1514 Token position() => label.getBeginToken(); |
| 1515 String toString() => "${labelName}:"; | 1515 String toString() => "${labelName}:"; |
| 1516 } | 1516 } |
| 1517 | 1517 |
| 1518 // Represents a reference to a statement or switch-case, either by label or the | 1518 // Represents a reference to a statement or switch-case, either by label or the |
| 1519 // default target of a break or continue. | 1519 // default target of a break or continue. |
| 1520 class TargetElement extends Element { | 1520 class TargetElement extends Element { |
| 1521 final Node statement; | 1521 final Node statement; |
| 1522 final int nestingLevel; | 1522 final int nestingLevel; |
| 1523 Link<LabelElement> labels = const EmptyLink<LabelElement>(); | 1523 Link<LabelElement> labels = const EmptyLink<LabelElement>(); |
| 1524 bool isBreakTarget = false; | 1524 bool isBreakTarget = false; |
| 1525 bool isContinueTarget = false; | 1525 bool isContinueTarget = false; |
| 1526 | 1526 |
| 1527 TargetElement(this.statement, this.nestingLevel, Element enclosingElement) | 1527 TargetElement(this.statement, this.nestingLevel, Element enclosingElement) |
| 1528 : super(const SourceString(""), ElementKind.STATEMENT, enclosingElement); | 1528 : super(const SourceString(""), ElementKind.STATEMENT, enclosingElement); |
| 1529 bool get isTarget() => isBreakTarget || isContinueTarget; | 1529 bool get isTarget => isBreakTarget || isContinueTarget; |
| 1530 | 1530 |
| 1531 LabelElement addLabel(Label label, String labelName) { | 1531 LabelElement addLabel(Label label, String labelName) { |
| 1532 LabelElement result = new LabelElement(label, labelName, this, | 1532 LabelElement result = new LabelElement(label, labelName, this, |
| 1533 enclosingElement); | 1533 enclosingElement); |
| 1534 labels = labels.prepend(result); | 1534 labels = labels.prepend(result); |
| 1535 return result; | 1535 return result; |
| 1536 } | 1536 } |
| 1537 | 1537 |
| 1538 Node parseNode(DiagnosticListener l) => statement; | 1538 Node parseNode(DiagnosticListener l) => statement; |
| 1539 | 1539 |
| 1540 bool get isSwitch() => statement is SwitchStatement; | 1540 bool get isSwitch => statement is SwitchStatement; |
| 1541 | 1541 |
| 1542 Token position() => statement.getBeginToken(); | 1542 Token position() => statement.getBeginToken(); |
| 1543 String toString() => statement.toString(); | 1543 String toString() => statement.toString(); |
| 1544 } | 1544 } |
| 1545 | 1545 |
| 1546 class TypeVariableElement extends Element { | 1546 class TypeVariableElement extends Element { |
| 1547 final Node cachedNode; | 1547 final Node cachedNode; |
| 1548 TypeVariableType type; | 1548 TypeVariableType type; |
| 1549 Type bound; | 1549 Type bound; |
| 1550 | 1550 |
| 1551 TypeVariableElement(name, Element enclosing, this.cachedNode, | 1551 TypeVariableElement(name, Element enclosing, this.cachedNode, |
| 1552 [this.type, this.bound]) | 1552 [this.type, this.bound]) |
| 1553 : super(name, ElementKind.TYPE_VARIABLE, enclosing); | 1553 : super(name, ElementKind.TYPE_VARIABLE, enclosing); |
| 1554 | 1554 |
| 1555 TypeVariableType computeType(compiler) => type; | 1555 TypeVariableType computeType(compiler) => type; |
| 1556 | 1556 |
| 1557 Node parseNode(compiler) => cachedNode; | 1557 Node parseNode(compiler) => cachedNode; |
| 1558 | 1558 |
| 1559 String toString() => "${enclosingElement.toString()}.${name.slowToString()}"; | 1559 String toString() => "${enclosingElement.toString()}.${name.slowToString()}"; |
| 1560 | 1560 |
| 1561 Token position() => cachedNode.getBeginToken(); | 1561 Token position() => cachedNode.getBeginToken(); |
| 1562 | 1562 |
| 1563 TypeVariableElement cloneTo(Element enclosing, DiagnosticListener listener) { | 1563 TypeVariableElement cloneTo(Element enclosing, DiagnosticListener listener) { |
| 1564 TypeVariableElement result = | 1564 TypeVariableElement result = |
| 1565 new TypeVariableElement(name, enclosing, cachedNode, type, bound); | 1565 new TypeVariableElement(name, enclosing, cachedNode, type, bound); |
| 1566 return result; | 1566 return result; |
| 1567 } | 1567 } |
| 1568 } | 1568 } |
| OLD | NEW |