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

Side by Side Diff: tests/compiler/dart2js/mock_compiler.dart

Issue 1933403002: Revert "Implements support for ignoring method type arguments in resolution." (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « pkg/compiler/lib/src/tree/nodes.dart ('k') | tests/compiler/dart2js/resolver_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:compiler/compiler.dart' as api; 10 import 'package:compiler/compiler.dart' as api;
11 import 'package:compiler/src/common/names.dart' show 11 import 'package:compiler/src/common/names.dart' show
12 Uris; 12 Uris;
13 import 'package:compiler/src/constants/expressions.dart'; 13 import 'package:compiler/src/constants/expressions.dart';
14 import 'package:compiler/src/dart_types.dart' show DartType;
15 import 'package:compiler/src/diagnostics/diagnostic_listener.dart'; 14 import 'package:compiler/src/diagnostics/diagnostic_listener.dart';
16 import 'package:compiler/src/diagnostics/source_span.dart'; 15 import 'package:compiler/src/diagnostics/source_span.dart';
17 import 'package:compiler/src/diagnostics/spannable.dart'; 16 import 'package:compiler/src/diagnostics/spannable.dart';
18 import 'package:compiler/src/elements/elements.dart'; 17 import 'package:compiler/src/elements/elements.dart';
19 import 'package:compiler/src/elements/visitor.dart'; 18 import 'package:compiler/src/elements/visitor.dart';
20 import 'package:compiler/src/js_backend/backend_helpers.dart' show 19 import 'package:compiler/src/js_backend/backend_helpers.dart' show
21 BackendHelpers; 20 BackendHelpers;
22 import 'package:compiler/src/js_backend/lookup_map_analysis.dart' show 21 import 'package:compiler/src/js_backend/lookup_map_analysis.dart' show
23 LookupMapAnalysis; 22 LookupMapAnalysis;
24 import 'package:compiler/src/io/source_file.dart'; 23 import 'package:compiler/src/io/source_file.dart';
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 } 217 }
219 218
220 CollectingTreeElements resolveStatement(String text) { 219 CollectingTreeElements resolveStatement(String text) {
221 parsedTree = parseStatement(text); 220 parsedTree = parseStatement(text);
222 return resolveNodeStatement(parsedTree, new MockElement(mainApp)); 221 return resolveNodeStatement(parsedTree, new MockElement(mainApp));
223 } 222 }
224 223
225 TreeElementMapping resolveNodeStatement(Node tree, 224 TreeElementMapping resolveNodeStatement(Node tree,
226 ExecutableElement element) { 225 ExecutableElement element) {
227 ResolverVisitor visitor = 226 ResolverVisitor visitor =
228 new ResolverVisitor( 227 new ResolverVisitor(this, element,
229 this,
230 element,
231 new ResolutionRegistry(this, 228 new ResolutionRegistry(this,
232 new CollectingTreeElements(element)), 229 new CollectingTreeElements(element)));
233 scope: new MockTypeVariablesScope( 230 if (visitor.scope is LibraryScope) {
234 element.enclosingElement.buildScope()));
235 if (visitor.scope is LibraryScope ||
236 visitor.scope is MockTypeVariablesScope) {
237 visitor.scope = new MethodScope(visitor.scope, element); 231 visitor.scope = new MethodScope(visitor.scope, element);
238 } 232 }
239 visitor.visit(tree); 233 visitor.visit(tree);
240 visitor.scope = new LibraryScope(element.library); 234 visitor.scope = new LibraryScope(element.library);
241 return visitor.registry.mapping; 235 return visitor.registry.mapping;
242 } 236 }
243 237
244 resolverVisitor() { 238 resolverVisitor() {
245 Element mockElement = new MockElement(mainApp.entryCompilationUnit); 239 Element mockElement = new MockElement(mainApp.entryCompilationUnit);
246 ResolverVisitor visitor = 240 ResolverVisitor visitor =
247 new ResolverVisitor( 241 new ResolverVisitor(this, mockElement,
248 this, 242 new ResolutionRegistry(this,
249 mockElement, 243 new CollectingTreeElements(mockElement)));
250 new ResolutionRegistry(
251 this, new CollectingTreeElements(mockElement)),
252 scope: mockElement.enclosingElement.buildScope());
253 visitor.scope = new MethodScope(visitor.scope, mockElement); 244 visitor.scope = new MethodScope(visitor.scope, mockElement);
254 return visitor; 245 return visitor;
255 } 246 }
256 247
257 parseScript(String text, [LibraryElement library]) { 248 parseScript(String text, [LibraryElement library]) {
258 if (library == null) library = mainApp; 249 if (library == null) library = mainApp;
259 parseUnit(text, this, library, registerSource); 250 parseUnit(text, this, library, registerSource);
260 } 251 }
261 252
262 Future scanBuiltinLibraries() { 253 Future scanBuiltinLibraries() {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 map.remove(node); 314 map.remove(node);
324 } 315 }
325 316
326 List<ConstantExpression> get constants { 317 List<ConstantExpression> get constants {
327 List<ConstantExpression> list = <ConstantExpression>[]; 318 List<ConstantExpression> list = <ConstantExpression>[];
328 forEachConstantNode((_, c) => list.add(c)); 319 forEachConstantNode((_, c) => list.add(c));
329 return list; 320 return list;
330 } 321 }
331 } 322 }
332 323
333 class MockTypeVariablesScope extends TypeVariablesScope {
334 @override
335 List<DartType> get typeVariables => <DartType>[];
336 MockTypeVariablesScope(Scope parent) : super(parent);
337 String toString() => 'MockTypeVariablesScope($parent)';
338 }
339
340 // The mock compiler does not split the program in output units. 324 // The mock compiler does not split the program in output units.
341 class MockDeferredLoadTask extends DeferredLoadTask { 325 class MockDeferredLoadTask extends DeferredLoadTask {
342 MockDeferredLoadTask(Compiler compiler) : super(compiler); 326 MockDeferredLoadTask(Compiler compiler) : super(compiler);
343 327
344 OutputUnit getElementOutputUnit(dynamic dependency) { 328 OutputUnit getElementOutputUnit(dynamic dependency) {
345 return mainOutputUnit; 329 return mainOutputUnit;
346 } 330 }
347 } 331 }
348 332
349 api.DiagnosticHandler createHandler(MockCompiler compiler, String text, 333 api.DiagnosticHandler createHandler(MockCompiler compiler, String text,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 trustTypeAnnotations: trustTypeAnnotations, 386 trustTypeAnnotations: trustTypeAnnotations,
403 enableTypeAssertions: enableTypeAssertions, 387 enableTypeAssertions: enableTypeAssertions,
404 enableUserAssertions: enableUserAssertions, 388 enableUserAssertions: enableUserAssertions,
405 expectedErrors: expectedErrors, 389 expectedErrors: expectedErrors,
406 expectedWarnings: expectedWarnings, 390 expectedWarnings: expectedWarnings,
407 outputProvider: outputProvider); 391 outputProvider: outputProvider);
408 compiler.registerSource(uri, code); 392 compiler.registerSource(uri, code);
409 compiler.diagnosticHandler = createHandler(compiler, code); 393 compiler.diagnosticHandler = createHandler(compiler, code);
410 return compiler; 394 return compiler;
411 } 395 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/tree/nodes.dart ('k') | tests/compiler/dart2js/resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698