| 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('mock_compiler'); | 5 #library('mock_compiler'); |
| 6 | 6 |
| 7 #import("dart:uri"); | 7 #import("dart:uri"); |
| 8 | 8 |
| 9 #import("../../../lib/compiler/implementation/elements/elements.dart"); | 9 #import("../../../lib/compiler/implementation/elements/elements.dart"); |
| 10 #import("../../../lib/compiler/implementation/leg.dart"); | 10 #import("../../../lib/compiler/implementation/leg.dart"); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 errors = []; | 117 errors = []; |
| 118 } | 118 } |
| 119 | 119 |
| 120 TreeElementMapping resolveStatement(String text) { | 120 TreeElementMapping resolveStatement(String text) { |
| 121 parsedTree = parseStatement(text); | 121 parsedTree = parseStatement(text); |
| 122 return resolveNodeStatement(parsedTree, mainApp); | 122 return resolveNodeStatement(parsedTree, mainApp); |
| 123 } | 123 } |
| 124 | 124 |
| 125 TreeElementMapping resolveNodeStatement(Node tree, Element element) { | 125 TreeElementMapping resolveNodeStatement(Node tree, Element element) { |
| 126 ResolverVisitor visitor = new ResolverVisitor(this, element); | 126 ResolverVisitor visitor = new ResolverVisitor(this, element); |
| 127 if (visitor.context is TopScope) { | 127 if (visitor.scope is TopScope) { |
| 128 visitor.context = new BlockScope(visitor.context); | 128 visitor.scope = new BlockScope(visitor.scope); |
| 129 } | 129 } |
| 130 visitor.visit(tree); | 130 visitor.visit(tree); |
| 131 visitor.context = new TopScope(element.getLibrary()); | 131 visitor.scope = new TopScope(element.getLibrary()); |
| 132 // Resolve the type annotations encountered in the code. | 132 // Resolve the type annotations encountered in the code. |
| 133 while (!resolver.toResolve.isEmpty()) { | 133 while (!resolver.toResolve.isEmpty()) { |
| 134 resolver.toResolve.removeFirst().ensureResolved(this); | 134 resolver.toResolve.removeFirst().ensureResolved(this); |
| 135 } | 135 } |
| 136 return visitor.mapping; | 136 return visitor.mapping; |
| 137 } | 137 } |
| 138 | 138 |
| 139 resolverVisitor() { | 139 resolverVisitor() { |
| 140 Element mockElement = | 140 Element mockElement = |
| 141 new Element(buildSourceString(''), ElementKind.FUNCTION, mainApp); | 141 new Element(buildSourceString(''), ElementKind.FUNCTION, mainApp); |
| 142 ResolverVisitor visitor = new ResolverVisitor(this, mockElement); | 142 ResolverVisitor visitor = new ResolverVisitor(this, mockElement); |
| 143 visitor.context = new BlockScope(visitor.context); | 143 visitor.scope = new BlockScope(visitor.scope); |
| 144 return visitor; | 144 return visitor; |
| 145 } | 145 } |
| 146 | 146 |
| 147 parseScript(String text, [LibraryElement library]) { | 147 parseScript(String text, [LibraryElement library]) { |
| 148 if (library === null) library = mainApp; | 148 if (library === null) library = mainApp; |
| 149 parseUnit(text, this, library); | 149 parseUnit(text, this, library); |
| 150 } | 150 } |
| 151 | 151 |
| 152 void scanBuiltinLibraries() { | 152 void scanBuiltinLibraries() { |
| 153 // Do nothing. The mock core library is already handled in the constructor. | 153 // Do nothing. The mock core library is already handled in the constructor. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 }); | 197 }); |
| 198 } | 198 } |
| 199 } | 199 } |
| 200 | 200 |
| 201 LibraryElement mockLibrary(Compiler compiler, String source) { | 201 LibraryElement mockLibrary(Compiler compiler, String source) { |
| 202 Uri uri = new Uri(scheme: "source"); | 202 Uri uri = new Uri(scheme: "source"); |
| 203 var library = new LibraryElement(new Script(uri, new MockFile(source))); | 203 var library = new LibraryElement(new Script(uri, new MockFile(source))); |
| 204 importLibrary(library, compiler.coreLibrary, compiler); | 204 importLibrary(library, compiler.coreLibrary, compiler); |
| 205 return library; | 205 return library; |
| 206 } | 206 } |
| OLD | NEW |