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

Side by Side Diff: lib/src/info.dart

Issue 1788973002: Remove code that requires whole-program compile (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: merged Created 4 years, 9 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 | « lib/src/compiler.dart ('k') | lib/src/options.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
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.
4
5 /// Defines static information collected by the type checker and used later by
6 /// emitters to generate code.
7
8 import 'package:analyzer/dart/ast/ast.dart';
9 import 'package:analyzer/dart/element/element.dart';
10 import 'package:analyzer/src/dart/ast/ast.dart';
11 import 'package:analyzer/src/dart/ast/utilities.dart';
12 import 'package:analyzer/src/generated/parser.dart';
13
14 import 'utils.dart' as utils;
15
16 import 'package:analyzer/src/task/strong/info.dart';
17 export 'package:analyzer/src/task/strong/info.dart';
18
19 /// Represents a summary of the results collected by running the program
20 /// checker.
21 class CheckerResults {
22 final List<LibraryInfo> libraries;
23 final bool failure;
24
25 CheckerResults(this.libraries, this.failure);
26 }
27
28 /// Computed information about each library.
29 class LibraryInfo {
30 /// Canonical name of the library. This is unfortunately not derived from the
31 /// library directive as it doesn't have any meaningful rules enforced.
32 /// Instead, this is inferred from the path to the file defining the library.
33 final String name;
34
35 /// Corresponding analyzer element.
36 final LibraryElement library;
37
38 LibraryInfo(library)
39 : library = library,
40 name = utils.canonicalLibraryName(library);
41 }
42
43 class LibraryUnit {
44 final CompilationUnit library;
45 final List<CompilationUnit> parts;
46
47 LibraryUnit(this.library, this.parts);
48
49 Iterable<CompilationUnit> get libraryThenParts sync* {
50 yield library;
51 yield* parts;
52 }
53
54 Iterable<CompilationUnit> get partsThenLibrary sync* {
55 yield* parts;
56 yield library;
57 }
58
59 /// Creates a clone of this library's AST.
60 LibraryUnit clone() {
61 return new LibraryUnit(
62 _cloneUnit(library), parts.map(_cloneUnit).toList(growable: false));
63 }
64
65 static CompilationUnit _cloneUnit(CompilationUnit oldNode) {
66 var newNode = oldNode.accept(new _AstCloner());
67 ResolutionCopier.copyResolutionData(oldNode, newNode);
68 return newNode;
69 }
70 }
71
72 class _AstCloner extends AstCloner {
73 void _cloneProperties(AstNode clone, AstNode node) {
74 if (clone != null) {
75 CoercionInfo.set(clone, CoercionInfo.get(node));
76 DynamicInvoke.set(clone, DynamicInvoke.get(node));
77 }
78 }
79
80 @override
81 AstNode cloneNode(AstNode node) {
82 var clone = super.cloneNode(node);
83 _cloneProperties(clone, node);
84 return clone;
85 }
86
87 @override
88 List cloneNodeList(List list) {
89 var clone = super.cloneNodeList(list);
90 for (int i = 0, len = list.length; i < len; i++) {
91 _cloneProperties(clone[i], list[i]);
92 }
93 return clone;
94 }
95
96 // TODO(jmesserly): ResolutionCopier is not copying this yet.
97 @override
98 BlockFunctionBody visitBlockFunctionBody(BlockFunctionBody node) {
99 var clone = super.visitBlockFunctionBody(node);
100 (clone as FunctionBodyImpl).localVariableInfo =
101 (node as FunctionBodyImpl).localVariableInfo;
102 return clone;
103 }
104
105 @override
106 ExpressionFunctionBody visitExpressionFunctionBody(
107 ExpressionFunctionBody node) {
108 var clone = super.visitExpressionFunctionBody(node);
109 (clone as FunctionBodyImpl).localVariableInfo =
110 (node as FunctionBodyImpl).localVariableInfo;
111 return clone;
112 }
113 }
OLDNEW
« no previous file with comments | « lib/src/compiler.dart ('k') | lib/src/options.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698