| 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 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 } | 641 } |
| 642 listener.cancel('internal error: could not find $name', node: variables); | 642 listener.cancel('internal error: could not find $name', node: variables); |
| 643 } | 643 } |
| 644 | 644 |
| 645 DartType computeType(Compiler compiler) { | 645 DartType computeType(Compiler compiler) { |
| 646 return variables.computeType(compiler); | 646 return variables.computeType(compiler); |
| 647 } | 647 } |
| 648 | 648 |
| 649 DartType get type => variables.type; | 649 DartType get type => variables.type; |
| 650 | 650 |
| 651 bool isInstanceMember() => variables.isInstanceMember(); | 651 bool isInstanceMember() { |
| 652 return isMember() && !modifiers.isStatic(); |
| 653 } |
| 652 | 654 |
| 653 // Note: cachedNode.getBeginToken() will not be correct in all | 655 // Note: cachedNode.getBeginToken() will not be correct in all |
| 654 // cases, for example, for function typed parameters. | 656 // cases, for example, for function typed parameters. |
| 655 Token position() => findMyName(variables.position()); | 657 Token position() => findMyName(variables.position()); |
| 656 | 658 |
| 657 VariableElement cloneTo(Element enclosing, DiagnosticListener listener) { | 659 VariableElement cloneTo(Element enclosing, DiagnosticListener listener) { |
| 658 VariableListElement clonedVariables = | 660 VariableListElement clonedVariables = |
| 659 variables.cloneTo(enclosing, listener); | 661 variables.cloneTo(enclosing, listener); |
| 660 VariableElement result = new VariableElement( | 662 VariableElement result = new VariableElement( |
| 661 name, clonedVariables, kind, enclosing, cachedNode); | 663 name, clonedVariables, kind, enclosing, cachedNode); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 | 752 |
| 751 VariableListElement cloneTo(Element enclosing, DiagnosticListener listener) { | 753 VariableListElement cloneTo(Element enclosing, DiagnosticListener listener) { |
| 752 VariableListElement result; | 754 VariableListElement result; |
| 753 if (cachedNode !== null) { | 755 if (cachedNode !== null) { |
| 754 result = new VariableListElement.node(cachedNode, kind, enclosing); | 756 result = new VariableListElement.node(cachedNode, kind, enclosing); |
| 755 } else { | 757 } else { |
| 756 result = new VariableListElement(kind, modifiers, enclosing); | 758 result = new VariableListElement(kind, modifiers, enclosing); |
| 757 } | 759 } |
| 758 return result; | 760 return result; |
| 759 } | 761 } |
| 760 | |
| 761 bool isInstanceMember() { | |
| 762 return isMember() && !modifiers.isStatic(); | |
| 763 } | |
| 764 | |
| 765 Scope buildScope() { | |
| 766 Scope result = new VariableScope(enclosingElement.buildScope(), this); | |
| 767 if (enclosingElement.isClass()) { | |
| 768 ClassScope clsScope = result.parent; | |
| 769 clsScope.inStaticContext = !isInstanceMember(); | |
| 770 } | |
| 771 return result; | |
| 772 } | |
| 773 } | 762 } |
| 774 | 763 |
| 775 class ForeignElement extends Element { | 764 class ForeignElement extends Element { |
| 776 ForeignElement(SourceString name, ContainerElement enclosingElement) | 765 ForeignElement(SourceString name, ContainerElement enclosingElement) |
| 777 : super(name, ElementKind.FOREIGN, enclosingElement); | 766 : super(name, ElementKind.FOREIGN, enclosingElement); |
| 778 | 767 |
| 779 DartType computeType(Compiler compiler) { | 768 DartType computeType(Compiler compiler) { |
| 780 return compiler.types.dynamicType; | 769 return compiler.types.dynamicType; |
| 781 } | 770 } |
| 782 | 771 |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 | 978 |
| 990 FunctionElement asFunctionElement() => this; | 979 FunctionElement asFunctionElement() => this; |
| 991 | 980 |
| 992 FunctionElement cloneTo(Element enclosing, DiagnosticListener listener) { | 981 FunctionElement cloneTo(Element enclosing, DiagnosticListener listener) { |
| 993 FunctionElement result = new FunctionElement.tooMuchOverloading( | 982 FunctionElement result = new FunctionElement.tooMuchOverloading( |
| 994 name, cachedNode, kind, modifiers, enclosing, functionSignature); | 983 name, cachedNode, kind, modifiers, enclosing, functionSignature); |
| 995 result.defaultImplementation = defaultImplementation; | 984 result.defaultImplementation = defaultImplementation; |
| 996 result.type = type; | 985 result.type = type; |
| 997 return result; | 986 return result; |
| 998 } | 987 } |
| 999 | |
| 1000 Scope buildScope() { | |
| 1001 Scope result = new MethodScope(enclosingElement.buildScope(), this); | |
| 1002 if (enclosingElement.isClass()) { | |
| 1003 ClassScope clsScope = result.parent; | |
| 1004 clsScope.inStaticContext = !isInstanceMember() && !isConstructor(); | |
| 1005 } | |
| 1006 return result; | |
| 1007 } | |
| 1008 } | 988 } |
| 1009 | 989 |
| 1010 | 990 |
| 1011 class ConstructorBodyElement extends FunctionElement { | 991 class ConstructorBodyElement extends FunctionElement { |
| 1012 FunctionElement constructor; | 992 FunctionElement constructor; |
| 1013 | 993 |
| 1014 ConstructorBodyElement(FunctionElement constructor) | 994 ConstructorBodyElement(FunctionElement constructor) |
| 1015 : this.constructor = constructor, | 995 : this.constructor = constructor, |
| 1016 super(constructor.name, | 996 super(constructor.name, |
| 1017 ElementKind.GENERATIVE_CONSTRUCTOR_BODY, | 997 ElementKind.GENERATIVE_CONSTRUCTOR_BODY, |
| (...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1672 | 1652 |
| 1673 MetadataAnnotation ensureResolved(Compiler compiler) { | 1653 MetadataAnnotation ensureResolved(Compiler compiler) { |
| 1674 if (resolutionState == STATE_NOT_STARTED) { | 1654 if (resolutionState == STATE_NOT_STARTED) { |
| 1675 compiler.resolver.resolveMetadataAnnotation(this); | 1655 compiler.resolver.resolveMetadataAnnotation(this); |
| 1676 } | 1656 } |
| 1677 return this; | 1657 return this; |
| 1678 } | 1658 } |
| 1679 | 1659 |
| 1680 String toString() => 'MetadataAnnotation($value, $resolutionState)'; | 1660 String toString() => 'MetadataAnnotation($value, $resolutionState)'; |
| 1681 } | 1661 } |
| OLD | NEW |