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

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

Issue 10855125: Ensure supertypes are loaded safely. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: More cleanup of ClassElement.cloneMembersTo Created 8 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("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");
11 #import('../../../lib/compiler/implementation/source_file.dart'); 11 #import('../../../lib/compiler/implementation/source_file.dart');
12 #import("../../../lib/compiler/implementation/tree/tree.dart"); 12 #import("../../../lib/compiler/implementation/tree/tree.dart");
13 #import("../../../lib/compiler/implementation/util/util.dart"); 13 #import("../../../lib/compiler/implementation/util/util.dart");
14 #import('../../../lib/compiler/compiler.dart', prefix: 'api');
14 #import("parser_helper.dart"); 15 #import("parser_helper.dart");
15 16
16 class WarningMessage { 17 class WarningMessage {
17 Node node; 18 Node node;
18 Message message; 19 Message message;
19 WarningMessage(this.node, this.message); 20 WarningMessage(this.node, this.message);
20 21
21 toString() => message.toString(); 22 toString() => message.toString();
22 } 23 }
23 24
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 } 99 }
99 100
100 void reportError(Node node, var message) { 101 void reportError(Node node, var message) {
101 if (message is String && message.startsWith("no #library tag found in")) { 102 if (message is String && message.startsWith("no #library tag found in")) {
102 // TODO(ahe): Fix the MockCompiler to not have this problem. 103 // TODO(ahe): Fix the MockCompiler to not have this problem.
103 return; 104 return;
104 } 105 }
105 errors.add(new WarningMessage(node, message.message)); 106 errors.add(new WarningMessage(node, message.message));
106 } 107 }
107 108
109 void reportMessage(SourceSpan span, var message, api.Diagnostic kind) {
110 var diagnostic = new WarningMessage(null, message.message);
111 if (kind === api.Diagnostic.ERROR) {
112 errors.add(diagnostic);
113 } else {
114 warnings.add(diagnostic);
115 }
116 }
117
108 void reportDiagnostic(SourceSpan span, String message, var kind) { 118 void reportDiagnostic(SourceSpan span, String message, var kind) {
109 print(message); 119 print(message);
110 } 120 }
111 121
112 void clearWarnings() { 122 void clearWarnings() {
113 warnings = []; 123 warnings = [];
114 } 124 }
115 125
116 void clearErrors() { 126 void clearErrors() {
117 errors = []; 127 errors = [];
118 } 128 }
119 129
120 TreeElementMapping resolveStatement(String text) { 130 TreeElementMapping resolveStatement(String text) {
121 parsedTree = parseStatement(text); 131 parsedTree = parseStatement(text);
122 return resolveNodeStatement(parsedTree, mainApp); 132 return resolveNodeStatement(parsedTree, mainApp);
123 } 133 }
124 134
125 TreeElementMapping resolveNodeStatement(Node tree, Element element) { 135 TreeElementMapping resolveNodeStatement(Node tree, Element element) {
126 ResolverVisitor visitor = new ResolverVisitor(this, element); 136 ResolverVisitor visitor = new ResolverVisitor(this, element);
127 if (visitor.scope is TopScope) { 137 if (visitor.scope is TopScope) {
128 visitor.scope = new BlockScope(visitor.scope); 138 visitor.scope = new BlockScope(visitor.scope);
129 } 139 }
130 visitor.visit(tree); 140 visitor.visit(tree);
131 visitor.scope = new TopScope(element.getLibrary()); 141 visitor.scope = new TopScope(element.getLibrary());
132 // Resolve the type annotations encountered in the code.
133 while (!resolver.toResolve.isEmpty()) {
134 resolver.toResolve.removeFirst().ensureResolved(this);
135 }
136 return visitor.mapping; 142 return visitor.mapping;
137 } 143 }
138 144
139 resolverVisitor() { 145 resolverVisitor() {
140 Element mockElement = 146 Element mockElement =
141 new Element(buildSourceString(''), ElementKind.FUNCTION, mainApp); 147 new Element(buildSourceString(''), ElementKind.FUNCTION, mainApp);
142 ResolverVisitor visitor = new ResolverVisitor(this, mockElement); 148 ResolverVisitor visitor = new ResolverVisitor(this, mockElement);
143 visitor.scope = new BlockScope(visitor.scope); 149 visitor.scope = new BlockScope(visitor.scope);
144 return visitor; 150 return visitor;
145 } 151 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 }); 203 });
198 } 204 }
199 } 205 }
200 206
201 LibraryElement mockLibrary(Compiler compiler, String source) { 207 LibraryElement mockLibrary(Compiler compiler, String source) {
202 Uri uri = new Uri.fromComponents(scheme: "source"); 208 Uri uri = new Uri.fromComponents(scheme: "source");
203 var library = new LibraryElement(new Script(uri, new MockFile(source))); 209 var library = new LibraryElement(new Script(uri, new MockFile(source)));
204 importLibrary(library, compiler.coreLibrary, compiler); 210 importLibrary(library, compiler.coreLibrary, compiler);
205 return library; 211 return library;
206 } 212 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698