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

Side by Side Diff: frog/library.dart

Issue 8481023: cleanup errors and fix a couple field negative tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 1 month 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
« no previous file with comments | « frog/gen.dart ('k') | frog/member.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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 class LibraryImport { 5 class LibraryImport {
6 String prefix; 6 String prefix;
7 Library library; 7 Library library;
8 LibraryImport(this.library, [this.prefix = null]); 8 LibraryImport(this.library, [this.prefix = null]);
9 } 9 }
10 10
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 for (var imported in imports) { 169 for (var imported in imports) {
170 var newRet = null; 170 var newRet = null;
171 if (imported.prefix == null) { 171 if (imported.prefix == null) {
172 newRet = imported.library.types[name]; 172 newRet = imported.library.types[name];
173 } else if (imported.prefix == name) { 173 } else if (imported.prefix == name) {
174 newRet = imported.library.topType; 174 newRet = imported.library.topType;
175 } 175 }
176 if (newRet != null) { 176 if (newRet != null) {
177 // TODO(jimhug): Should not need ret != newRet here or below. 177 // TODO(jimhug): Should not need ret != newRet here or below.
178 if (ret != null && ret != newRet) { 178 if (ret != null && ret != newRet) {
179 world.error('conflicting types for "$name"', ret.span); 179 world.error('conflicting types for "$name"', ret.span, newRet.span);
180 world.error('conflicting types for "$name"', newRet.span);
181 } else { 180 } else {
182 ret = newRet; 181 ret = newRet;
183 } 182 }
184 } 183 }
185 } 184 }
186 return ret; 185 return ret;
187 } 186 }
188 187
189 Member lookup(String name, SourceSpan span) { 188 Member lookup(String name, SourceSpan span) {
190 var retType = findTypeByName(name); 189 var retType = findTypeByName(name);
191 var ret = null; 190 var ret = null;
192 191
193 if (retType != null) { 192 if (retType != null) {
194 ret = retType.typeMember; 193 ret = retType.typeMember;
195 } 194 }
196 195
197 var newRet = topType.getMember(name); 196 var newRet = topType.getMember(name);
198 // TODO(jimhug): Shares too much code with body of loop. 197 // TODO(jimhug): Shares too much code with body of loop.
199 if (newRet != null) { 198 if (newRet != null) {
200 if (ret != null && ret != newRet) { 199 if (ret != null && ret != newRet) {
201 world.error('conflicting members for "$name"', span); 200 world.error('conflicting members for "$name"',
202 world.error('conflicting members for "$name"', ret.span); 201 span, ret.span, newRet.span);
203 world.error('conflicting members for "$name"', newRet.span);
204 } else { 202 } else {
205 ret = newRet; 203 ret = newRet;
206 } 204 }
207 } 205 }
208 206
209 // Check all imports even if ret != null to detect conflicting names. 207 // Check all imports even if ret != null to detect conflicting names.
210 // TODO(jimhug): Only do this on first lookup. 208 // TODO(jimhug): Only do this on first lookup.
211 for (var imported in imports) { 209 for (var imported in imports) {
212 if (imported.prefix == null) { 210 if (imported.prefix == null) {
213 newRet = imported.library.topType.getMember(name); 211 newRet = imported.library.topType.getMember(name);
214 if (newRet != null) { 212 if (newRet != null) {
215 if (ret != null && ret != newRet) { 213 if (ret != null && ret != newRet) {
216 world.error('conflicting members for "$name"', span); 214 world.error('conflicting members for "$name"',
217 world.error('conflicting members for "$name"', ret.span); 215 span, ret.span, newRet.span);
218 world.error('conflicting members for "$name"', newRet.span);
219 } else { 216 } else {
220 ret = newRet; 217 ret = newRet;
221 } 218 }
222 } 219 }
223 } 220 }
224 } 221 }
225 return ret; 222 return ret;
226 } 223 }
227 224
228 resolve() { 225 resolve() {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 344
348 var filename = library.makeFullPath(name); 345 var filename = library.makeFullPath(name);
349 346
350 if (library.imports.some((li) => li.library.baseSource == filename)) { 347 if (library.imports.some((li) => li.library.baseSource == filename)) {
351 // TODO(jimhug): Can you import a lib twice with different prefixes? 348 // TODO(jimhug): Can you import a lib twice with different prefixes?
352 world.error('duplicate import of "$name"', node.span); 349 world.error('duplicate import of "$name"', node.span);
353 return; 350 return;
354 } 351 }
355 352
356 var newLib = library.addImport(filename, prefix); 353 var newLib = library.addImport(filename, prefix);
357 if (newLib.name == null && !filename.startsWith('dart:')) { 354 // TODO(jimhug): Add check that imported library has a #library
358 world.info('imported library "$name" has no #library directive',
359 node.span);
360 }
361 break; 355 break;
362 356
363 case "source": 357 case "source":
364 seenSource = true; 358 seenSource = true;
365 name = getSingleStringArg(node); 359 name = getSingleStringArg(node);
366 addSourceFromName(name, node.span); 360 addSourceFromName(name, node.span);
367 if (seenResource) { 361 if (seenResource) {
368 world.error('#sources must come before any #resource', node.span); 362 world.error('#sources must come before any #resource', node.span);
369 } 363 }
370 break; 364 break;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 443
450 void visitFunctionDefinition(FunctionDefinition node) { 444 void visitFunctionDefinition(FunctionDefinition node) {
451 currentType.addMethod(node.name.name, node); 445 currentType.addMethod(node.name.name, node);
452 } 446 }
453 447
454 void visitFunctionTypeDefinition(FunctionTypeDefinition node) { 448 void visitFunctionTypeDefinition(FunctionTypeDefinition node) {
455 var type = library.addType(node.func.name.name, node, false); 449 var type = library.addType(node.func.name.name, node, false);
456 type.addMethod('\$call', node.func); 450 type.addMethod('\$call', node.func);
457 } 451 }
458 } 452 }
OLDNEW
« no previous file with comments | « frog/gen.dart ('k') | frog/member.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698