| OLD | NEW |
| 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 /** The one true [World]. */ | 5 /** The one true [World]. */ |
| 6 World world; | 6 World world; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Should be called exactly once to setup singleton world. | 9 * Should be called exactly once to setup singleton world. |
| 10 * Can use world.reset() to reinitialize. | 10 * Can use world.reset() to reinitialize. |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 return new SourceFile(filename, ''); | 318 return new SourceFile(filename, ''); |
| 319 } | 319 } |
| 320 } | 320 } |
| 321 | 321 |
| 322 Library getOrAddLibrary(String filename) { | 322 Library getOrAddLibrary(String filename) { |
| 323 Library library = libraries[filename]; | 323 Library library = libraries[filename]; |
| 324 | 324 |
| 325 if (library == null) { | 325 if (library == null) { |
| 326 library = new Library(readFile(filename)); | 326 library = new Library(readFile(filename)); |
| 327 info('read library ${filename}'); | 327 info('read library ${filename}'); |
| 328 if (!library.isCore) { | 328 if (!library.isCore && |
| 329 !library.imports.some((li) => li.library.isCore)) { |
| 329 library.imports.add(new LibraryImport(corelib)); | 330 library.imports.add(new LibraryImport(corelib)); |
| 330 } | 331 } |
| 331 libraries[filename] = library; | 332 libraries[filename] = library; |
| 332 _todo.add(library); | 333 _todo.add(library); |
| 333 } | 334 } |
| 334 return library; | 335 return library; |
| 335 } | 336 } |
| 336 | 337 |
| 337 process() { | 338 process() { |
| 338 while (_todo.length > 0) { | 339 while (_todo.length > 0) { |
| 339 final todo = _todo; | 340 final todo = _todo; |
| 340 _todo = []; | 341 _todo = []; |
| 341 for (var lib in todo) { | 342 for (var lib in todo) { |
| 342 // TODO(jimhug): I don't like such active constructors. | 343 lib.visitSources(); |
| 343 new LibraryVisitor(lib); | |
| 344 } | 344 } |
| 345 } | 345 } |
| 346 } | 346 } |
| 347 | 347 |
| 348 Library processScript(String filename) { | 348 Library processScript(String filename) { |
| 349 Library library = getOrAddLibrary(filename); | 349 Library library = getOrAddLibrary(filename); |
| 350 process(); | 350 process(); |
| 351 return library; | 351 return library; |
| 352 } | 352 } |
| 353 | 353 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 | 429 |
| 430 withTiming(String name, f()) { | 430 withTiming(String name, f()) { |
| 431 final sw = new StopWatch(); | 431 final sw = new StopWatch(); |
| 432 sw.start(); | 432 sw.start(); |
| 433 var result = f(); | 433 var result = f(); |
| 434 sw.stop(); | 434 sw.stop(); |
| 435 info('$name in ${sw.elapsedInMs()}msec'); | 435 info('$name in ${sw.elapsedInMs()}msec'); |
| 436 return result; | 436 return result; |
| 437 } | 437 } |
| 438 } | 438 } |
| OLD | NEW |