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

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

Issue 21242002: Retain elements a finer granularity than library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments Created 7 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 library mock_compiler; 5 library mock_compiler;
6 6
7 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import '../../../sdk/lib/_internal/compiler/compiler.dart' as api; 10 import '../../../sdk/lib/_internal/compiler/compiler.dart' as api;
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 bool get compilationFailed => !errors.isEmpty; 333 bool get compilationFailed => !errors.isEmpty;
334 334
335 void clearWarnings() { 335 void clearWarnings() {
336 warnings = []; 336 warnings = [];
337 } 337 }
338 338
339 void clearErrors() { 339 void clearErrors() {
340 errors = []; 340 errors = [];
341 } 341 }
342 342
343 TreeElementMapping resolveStatement(String text) { 343 CollectingTreeElements resolveStatement(String text) {
344 parsedTree = parseStatement(text); 344 parsedTree = parseStatement(text);
345 return resolveNodeStatement(parsedTree, mainApp); 345 return resolveNodeStatement(parsedTree, mainApp);
346 } 346 }
347 347
348 TreeElementMapping resolveNodeStatement(Node tree, Element element) { 348 TreeElementMapping resolveNodeStatement(Node tree, Element element) {
349 ResolverVisitor visitor = 349 ResolverVisitor visitor =
350 new ResolverVisitor(this, element, new CollectingTreeElements(element)); 350 new ResolverVisitor(this, element, new CollectingTreeElements(element));
351 if (visitor.scope is LibraryScope) { 351 if (visitor.scope is LibraryScope) {
352 visitor.scope = new MethodScope(visitor.scope, element); 352 visitor.scope = new MethodScope(visitor.scope, element);
353 } 353 }
(...skipping 19 matching lines...) Expand all
373 } 373 }
374 374
375 void scanBuiltinLibraries() { 375 void scanBuiltinLibraries() {
376 // Do nothing. The mock core library is already handled in the constructor. 376 // Do nothing. The mock core library is already handled in the constructor.
377 } 377 }
378 378
379 LibraryElement scanBuiltinLibrary(String name) { 379 LibraryElement scanBuiltinLibrary(String name) {
380 // Do nothing. The mock core library is already handled in the constructor. 380 // Do nothing. The mock core library is already handled in the constructor.
381 } 381 }
382 382
383 void importCoreLibrary(LibraryElement library) {
384 scanner.importLibrary(library, coreLibrary, null);
385 }
386
387 Uri translateResolvedUri(LibraryElement importingLibrary, 383 Uri translateResolvedUri(LibraryElement importingLibrary,
388 Uri resolvedUri, Node node) => resolvedUri; 384 Uri resolvedUri, Node node) => resolvedUri;
389 385
390 // The mock library doesn't need any patches. 386 // The mock library doesn't need any patches.
391 Uri resolvePatchUri(String dartLibraryName) => null; 387 Uri resolvePatchUri(String dartLibraryName) => null;
392 388
393 Script readScript(Uri uri, [Node node]) { 389 Script readScript(Uri uri, [Node node]) {
394 SourceFile sourceFile = sourceFiles[uri.toString()]; 390 SourceFile sourceFile = sourceFiles[uri.toString()];
395 if (sourceFile == null) throw new ArgumentError(uri); 391 if (sourceFile == null) throw new ArgumentError(uri);
396 return new Script(uri, sourceFile); 392 return new Script(uri, sourceFile);
(...skipping 23 matching lines...) Expand all
420 fail('Too few warnings'); 416 fail('Too few warnings');
421 } 417 }
422 if (found.hasNext) { 418 if (found.hasNext) {
423 do { 419 do {
424 print('Additional warning "${found.next()}"'); 420 print('Additional warning "${found.next()}"');
425 } while (found.hasNext); 421 } while (found.hasNext);
426 fail('Too many warnings'); 422 fail('Too many warnings');
427 } 423 }
428 } 424 }
429 425
430 void importLibrary(LibraryElement target, LibraryElement imported, 426 void importLibrary(LibraryElement target, LibraryElementX imported,
431 Compiler compiler) { 427 Compiler compiler) {
432 for (var element in imported.localMembers) { 428 for (var element in imported.localMembers) {
433 compiler.withCurrentElement(element, () { 429 compiler.withCurrentElement(element, () {
434 target.addToScope(element, compiler); 430 target.addToScope(element, compiler);
435 }); 431 });
436 } 432 }
437 } 433 }
438 434
439 LibraryElement mockLibrary(Compiler compiler, String source) { 435 LibraryElement mockLibrary(Compiler compiler, String source) {
440 Uri uri = new Uri(scheme: "source"); 436 Uri uri = new Uri(scheme: "source");
(...skipping 18 matching lines...) Expand all
459 } 455 }
460 } 456 }
461 457
462 class MockDeferredLoadTask extends DeferredLoadTask { 458 class MockDeferredLoadTask extends DeferredLoadTask {
463 MockDeferredLoadTask(Compiler compiler) : super(compiler); 459 MockDeferredLoadTask(Compiler compiler) : super(compiler);
464 460
465 void registerMainApp(LibraryElement mainApp) { 461 void registerMainApp(LibraryElement mainApp) {
466 // Do nothing. 462 // Do nothing.
467 } 463 }
468 } 464 }
OLDNEW
« no previous file with comments | « dart/tests/compiler/dart2js/mirrors_used_test.dart ('k') | dart/tests/compiler/dart2js/resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698