Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Side by Side Diff: dart/lib/compiler/implementation/resolver.dart

Issue 10876008: Remove most superfluous getter arguments from dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 interface TreeElements { 5 interface TreeElements {
6 Element operator[](Node node); 6 Element operator[](Node node);
7 Selector getSelector(Send send); 7 Selector getSelector(Send send);
8 Type getType(TypeAnnotation annotation); 8 Type getType(TypeAnnotation annotation);
9 } 9 }
10 10
(...skipping 20 matching lines...) Expand all
31 void setSelector(Node node, Selector selector) { 31 void setSelector(Node node, Selector selector) {
32 selectors[node] = selector; 32 selectors[node] = selector;
33 } 33 }
34 34
35 Selector getSelector(Node node) => selectors[node]; 35 Selector getSelector(Node node) => selectors[node];
36 } 36 }
37 37
38 class ResolverTask extends CompilerTask { 38 class ResolverTask extends CompilerTask {
39 ResolverTask(Compiler compiler) : super(compiler); 39 ResolverTask(Compiler compiler) : super(compiler);
40 40
41 String get name() => 'Resolver'; 41 String get name => 'Resolver';
42 42
43 TreeElements resolve(Element element) { 43 TreeElements resolve(Element element) {
44 return measure(() { 44 return measure(() {
45 ElementKind kind = element.kind; 45 ElementKind kind = element.kind;
46 if (kind === ElementKind.GENERATIVE_CONSTRUCTOR || 46 if (kind === ElementKind.GENERATIVE_CONSTRUCTOR ||
47 kind === ElementKind.FUNCTION || 47 kind === ElementKind.FUNCTION ||
48 kind === ElementKind.GETTER || 48 kind === ElementKind.GETTER ||
49 kind === ElementKind.SETTER) { 49 kind === ElementKind.SETTER) {
50 return resolveMethodElement(element); 50 return resolveMethodElement(element);
51 } 51 }
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 LabelElement lookup(String labelName) { 677 LabelElement lookup(String labelName) {
678 LabelElement result = caseLabels[labelName]; 678 LabelElement result = caseLabels[labelName];
679 if (result !== null) return result; 679 if (result !== null) return result;
680 return outer.lookup(labelName); 680 return outer.lookup(labelName);
681 } 681 }
682 } 682 }
683 683
684 class EmptyLabelScope implements LabelScope { 684 class EmptyLabelScope implements LabelScope {
685 const EmptyLabelScope(); 685 const EmptyLabelScope();
686 LabelElement lookup(String label) => null; 686 LabelElement lookup(String label) => null;
687 LabelScope get outer() { 687 LabelScope get outer {
688 throw 'internal error: empty label scope has no outer'; 688 throw 'internal error: empty label scope has no outer';
689 } 689 }
690 } 690 }
691 691
692 class StatementScope { 692 class StatementScope {
693 LabelScope labels; 693 LabelScope labels;
694 Link<TargetElement> breakTargetStack; 694 Link<TargetElement> breakTargetStack;
695 Link<TargetElement> continueTargetStack; 695 Link<TargetElement> continueTargetStack;
696 // Used to provide different numbers to statements if one is inside the other. 696 // Used to provide different numbers to statements if one is inside the other.
697 // Can be used to make otherwise duplicate labels unique. 697 // Can be used to make otherwise duplicate labels unique.
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 || element.isGenerativeConstructor(), 902 || element.isGenerativeConstructor(),
903 this.currentClass = element.isMember() ? 903 this.currentClass = element.isMember() ?
904 element.getEnclosingClass() : 904 element.getEnclosingClass() :
905 null, 905 null,
906 this.statementScope = new StatementScope(), 906 this.statementScope = new StatementScope(),
907 typeResolver = new TypeResolver(compiler), 907 typeResolver = new TypeResolver(compiler),
908 scope = element.buildEnclosingScope(), 908 scope = element.buildEnclosingScope(),
909 super(compiler) { 909 super(compiler) {
910 } 910 }
911 911
912 Enqueuer get world() => compiler.enqueuer.resolution; 912 Enqueuer get world => compiler.enqueuer.resolution;
913 913
914 Element lookup(Node node, SourceString name) { 914 Element lookup(Node node, SourceString name) {
915 Element result = scope.lookup(name); 915 Element result = scope.lookup(name);
916 if (!inInstanceContext && result != null && result.isInstanceMember()) { 916 if (!inInstanceContext && result != null && result.isInstanceMember()) {
917 error(node, MessageKind.NO_INSTANCE_AVAILABLE, [node]); 917 error(node, MessageKind.NO_INSTANCE_AVAILABLE, [node]);
918 } 918 }
919 return result; 919 return result;
920 } 920 }
921 921
922 // Create, or reuse an already created, statement element for a statement. 922 // Create, or reuse an already created, statement element for a statement.
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after
1813 variableElement.bound = compiler.objectClass.computeType(compiler); 1813 variableElement.bound = compiler.objectClass.computeType(compiler);
1814 } 1814 }
1815 nodeLink = nodeLink.tail; 1815 nodeLink = nodeLink.tail;
1816 typeLink = typeLink.tail; 1816 typeLink = typeLink.tail;
1817 } 1817 }
1818 assert(typeLink.isEmpty()); 1818 assert(typeLink.isEmpty());
1819 } 1819 }
1820 } 1820 }
1821 1821
1822 class TypedefResolverVisitor extends TypeDefinitionVisitor { 1822 class TypedefResolverVisitor extends TypeDefinitionVisitor {
1823 TypedefElement get element() => super.element; 1823 TypedefElement get element => super.element;
1824 1824
1825 TypedefResolverVisitor(Compiler compiler, TypedefElement typedefElement) 1825 TypedefResolverVisitor(Compiler compiler, TypedefElement typedefElement)
1826 : super(compiler, typedefElement); 1826 : super(compiler, typedefElement);
1827 1827
1828 visitTypedef(Typedef node) { 1828 visitTypedef(Typedef node) {
1829 TypedefType type = element.computeType(compiler); 1829 TypedefType type = element.computeType(compiler);
1830 scope = new TypeDeclarationScope(scope, element); 1830 scope = new TypeDeclarationScope(scope, element);
1831 resolveTypeVariableBounds(node.typeParameters); 1831 resolveTypeVariableBounds(node.typeParameters);
1832 1832
1833 element.functionSignature = SignatureResolver.analyze( 1833 element.functionSignature = SignatureResolver.analyze(
(...skipping 12 matching lines...) Expand all
1846 * This visitor has to be extra careful as it is building the basic 1846 * This visitor has to be extra careful as it is building the basic
1847 * element information, and cannot safely look at other elements as 1847 * element information, and cannot safely look at other elements as
1848 * this may lead to cycles. 1848 * this may lead to cycles.
1849 * 1849 *
1850 * This visitor can assume that the supertypes have already been 1850 * This visitor can assume that the supertypes have already been
1851 * resolved, but it cannot call [ResolverTask.resolveClass] directly 1851 * resolved, but it cannot call [ResolverTask.resolveClass] directly
1852 * or indirectly (through [ClassElement.ensureResolved]) for any other 1852 * or indirectly (through [ClassElement.ensureResolved]) for any other
1853 * types. 1853 * types.
1854 */ 1854 */
1855 class ClassResolverVisitor extends TypeDefinitionVisitor { 1855 class ClassResolverVisitor extends TypeDefinitionVisitor {
1856 ClassElement get element() => super.element; 1856 ClassElement get element => super.element;
1857 1857
1858 ClassResolverVisitor(Compiler compiler, ClassElement classElement) 1858 ClassResolverVisitor(Compiler compiler, ClassElement classElement)
1859 : super(compiler, classElement); 1859 : super(compiler, classElement);
1860 1860
1861 Type visitClassNode(ClassNode node) { 1861 Type visitClassNode(ClassNode node) {
1862 compiler.ensure(element !== null); 1862 compiler.ensure(element !== null);
1863 compiler.ensure(element.resolutionState == ClassElement.STATE_STARTED); 1863 compiler.ensure(element.resolutionState == ClassElement.STATE_STARTED);
1864 1864
1865 InterfaceType type = element.computeType(compiler); 1865 InterfaceType type = element.computeType(compiler);
1866 scope = new TypeDeclarationScope(scope, element); 1866 scope = new TypeDeclarationScope(scope, element);
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
2305 returnType); 2305 returnType);
2306 } 2306 }
2307 2307
2308 // TODO(ahe): This is temporary. 2308 // TODO(ahe): This is temporary.
2309 void resolveExpression(Node node) { 2309 void resolveExpression(Node node) {
2310 if (node == null) return; 2310 if (node == null) return;
2311 node.accept(new ResolverVisitor(compiler, enclosingElement)); 2311 node.accept(new ResolverVisitor(compiler, enclosingElement));
2312 } 2312 }
2313 2313
2314 // TODO(ahe): This is temporary. 2314 // TODO(ahe): This is temporary.
2315 ClassElement get currentClass() { 2315 ClassElement get currentClass {
2316 return enclosingElement.isMember() 2316 return enclosingElement.isMember()
2317 ? enclosingElement.getEnclosingClass() : null; 2317 ? enclosingElement.getEnclosingClass() : null;
2318 } 2318 }
2319 } 2319 }
2320 2320
2321 class ConstructorResolver extends CommonResolverVisitor<Element> { 2321 class ConstructorResolver extends CommonResolverVisitor<Element> {
2322 final ResolverVisitor resolver; 2322 final ResolverVisitor resolver;
2323 2323
2324 ConstructorResolver(Compiler compiler, this.resolver) : super(compiler); 2324 ConstructorResolver(Compiler compiler, this.resolver) : super(compiler);
2325 2325
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
2421 } 2421 }
2422 2422
2423 /** 2423 /**
2424 * [TypeDeclarationScope] defines the outer scope of a type declaration in 2424 * [TypeDeclarationScope] defines the outer scope of a type declaration in
2425 * which the declared type variables and the entities in the enclosing scope are 2425 * which the declared type variables and the entities in the enclosing scope are
2426 * available but where declared and inherited members are not available. This 2426 * available but where declared and inherited members are not available. This
2427 * scope is only used for class/interface declarations during resolution of the 2427 * scope is only used for class/interface declarations during resolution of the
2428 * class hierarchy. In all other cases [ClassScope] is used. 2428 * class hierarchy. In all other cases [ClassScope] is used.
2429 */ 2429 */
2430 class TypeDeclarationScope extends Scope { 2430 class TypeDeclarationScope extends Scope {
2431 TypeDeclarationElement get element() => super.element; 2431 TypeDeclarationElement get element => super.element;
2432 2432
2433 TypeDeclarationScope(parent, TypeDeclarationElement element) 2433 TypeDeclarationScope(parent, TypeDeclarationElement element)
2434 : super(parent, element) { 2434 : super(parent, element) {
2435 assert(parent !== null); 2435 assert(parent !== null);
2436 } 2436 }
2437 2437
2438 Element add(Element newElement) { 2438 Element add(Element newElement) {
2439 throw "Cannot add element to TypeDeclarationScope"; 2439 throw "Cannot add element to TypeDeclarationScope";
2440 } 2440 }
2441 2441
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
2514 } 2514 }
2515 2515
2516 Element add(Element newElement) { 2516 Element add(Element newElement) {
2517 throw "Cannot add an element in a class scope"; 2517 throw "Cannot add an element in a class scope";
2518 } 2518 }
2519 2519
2520 String toString() => '$element > $parent'; 2520 String toString() => '$element > $parent';
2521 } 2521 }
2522 2522
2523 class TopScope extends Scope { 2523 class TopScope extends Scope {
2524 LibraryElement get library() => element; 2524 LibraryElement get library => element;
2525 2525
2526 TopScope(LibraryElement library) : super(null, library); 2526 TopScope(LibraryElement library) : super(null, library);
2527 Element lookup(SourceString name) { 2527 Element lookup(SourceString name) {
2528 return library.find(name); 2528 return library.find(name);
2529 } 2529 }
2530 2530
2531 Element add(Element newElement) { 2531 Element add(Element newElement) {
2532 throw "Cannot add an element in the top scope"; 2532 throw "Cannot add an element in the top scope";
2533 } 2533 }
2534 String toString() => '$element'; 2534 String toString() => '$element';
2535 } 2535 }
OLDNEW
« no previous file with comments | « dart/lib/compiler/implementation/patch_parser.dart ('k') | dart/lib/compiler/implementation/scanner/array_based_scanner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698