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

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

Issue 96623004: Add a visitor for Elements (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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:async'; 8 import 'dart:async';
9 import 'dart:collection'; 9 import 'dart:collection';
10 10
11 import '../../../sdk/lib/_internal/compiler/compiler.dart' as api; 11 import '../../../sdk/lib/_internal/compiler/compiler.dart' as api;
12 import '../../../sdk/lib/_internal/compiler/implementation/elements/elements.dar t'; 12 import '../../../sdk/lib/_internal/compiler/implementation/elements/elements.dar t';
13 import '../../../sdk/lib/_internal/compiler/implementation/resolution/resolution .dart'; 13 import '../../../sdk/lib/_internal/compiler/implementation/resolution/resolution .dart';
14 import '../../../sdk/lib/_internal/compiler/implementation/source_file.dart'; 14 import '../../../sdk/lib/_internal/compiler/implementation/source_file.dart';
15 import '../../../sdk/lib/_internal/compiler/implementation/tree/tree.dart'; 15 import '../../../sdk/lib/_internal/compiler/implementation/tree/tree.dart';
16 import '../../../sdk/lib/_internal/compiler/implementation/util/util.dart'; 16 import '../../../sdk/lib/_internal/compiler/implementation/util/util.dart';
17 import 'parser_helper.dart'; 17 import 'parser_helper.dart';
18 18
19 import '../../../sdk/lib/_internal/compiler/implementation/elements/modelx.dart' 19 import '../../../sdk/lib/_internal/compiler/implementation/elements/modelx.dart'
20 show ElementX, 20 show ElementX,
21 LibraryElementX, 21 LibraryElementX,
22 ErroneousElementX; 22 ErroneousElementX,
23 FunctionElementX;
23 24
24 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' 25 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart'
25 hide TreeElementMapping; 26 hide TreeElementMapping;
26 27
27 import '../../../sdk/lib/_internal/compiler/implementation/deferred_load.dart' 28 import '../../../sdk/lib/_internal/compiler/implementation/deferred_load.dart'
28 show DeferredLoadTask; 29 show DeferredLoadTask;
29 30
30 31
31 class WarningMessage { 32 class WarningMessage {
32 Spannable node; 33 Spannable node;
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 if (visitor.scope is LibraryScope) { 388 if (visitor.scope is LibraryScope) {
388 visitor.scope = new MethodScope(visitor.scope, element); 389 visitor.scope = new MethodScope(visitor.scope, element);
389 } 390 }
390 visitor.visit(tree); 391 visitor.visit(tree);
391 visitor.scope = new LibraryScope(element.getLibrary()); 392 visitor.scope = new LibraryScope(element.getLibrary());
392 return visitor.mapping; 393 return visitor.mapping;
393 } 394 }
394 395
395 resolverVisitor() { 396 resolverVisitor() {
396 Element mockElement = 397 Element mockElement =
397 new ElementX('', ElementKind.FUNCTION, mainApp.entryCompilationUnit); 398 new FunctionElementX('', ElementKind.FUNCTION, Modifiers.EMPTY,
399 mainApp.entryCompilationUnit, false);
398 ResolverVisitor visitor = 400 ResolverVisitor visitor =
399 new ResolverVisitor(this, mockElement, 401 new ResolverVisitor(this, mockElement,
400 new CollectingTreeElements(mockElement)); 402 new CollectingTreeElements(mockElement));
401 visitor.scope = new MethodScope(visitor.scope, mockElement); 403 visitor.scope = new MethodScope(visitor.scope, mockElement);
402 return visitor; 404 return visitor;
403 } 405 }
404 406
405 parseScript(String text, [LibraryElement library]) { 407 parseScript(String text, [LibraryElement library]) {
406 if (library == null) library = mainApp; 408 if (library == null) library = mainApp;
407 parseUnit(text, this, library, registerSource); 409 parseUnit(text, this, library, registerSource);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 } else { 511 } else {
510 sourceFile = compiler.sourceFiles[uri.toString()]; 512 sourceFile = compiler.sourceFiles[uri.toString()];
511 } 513 }
512 if (sourceFile != null && begin != null && end != null) { 514 if (sourceFile != null && begin != null && end != null) {
513 print(sourceFile.getLocationMessage(message, begin, end, true, (x) => x)); 515 print(sourceFile.getLocationMessage(message, begin, end, true, (x) => x));
514 } else { 516 } else {
515 print(message); 517 print(message);
516 } 518 }
517 }; 519 };
518 } 520 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698